Our future generation platform is in closed beta. Please request to participate. During the beta, expect some rough edges, broken windows overlooking blue sky vistas, and regularly scheduled changes.

Using the Slack Command Line Interface (CLI)

The command line interface makes it easier to create, run, and deploy new apps.

During the current alpha testing phase, the command is slack, however you should expect this to change at some point.

Install the CLI

The binaries for the CLI are available from the downloads page, with builds for both macOS, Windows, and Linux.

Deno required
Deno is currently a pre-requisite for using the CLI — if you do not have Deno installed, please do so first.

  1. Install the Deno JavaScript runtime
  2. Download the latest binary for your platform. You can always find the latest version on the downloads page.
  3. Decompress the downloaded file. On macOS, copy the slack binary to a destination in your path (we recommend /usr/local/bin). For Windows, copy the .exe file into any location accessible in your path.
  4. Test the app is properly installed by running slack version and verifying the version matches the one you downloaded.

Login with your Slack account

Before you can create an app, you must authenticate.

  1. Run slack login — this will display some instructional text and a string to copy and paste in any channel in the test workspace.
    /hermesauthticket ABC123DEF...XYZ
  1. Copy the entire string, including the leading /, and paste it into any channel in any workspace enabled for the beta. You are essentially calling a special slash command that will authenticate your app with Slack.
  2. Run slack auth info for information about your current auth session

Version Update Notifications

Once a day, the CLI will check for updates after running any command. When an update is available, a notification will be displayed with a link where you can find and download the new version.

Update notifications can be disabled using a command-line flag or an environment variable. When running any command, you can append the --skip-update or -s flag. Alternatively, you can set the SLACK_SKIP_UPDATE environment variable and assign it any value.

Commands

help

$ slack help [command-name]

Usage

Provides help for the CLI as well as any command and sub-command name, for example:

$ slack help create

Additionally, the -h or --help flag can be used with any command and subcommand, e.g.:

$ slack workspace list --help
$ slack var add -h

create

$ slack app create [app-name] [flags]
$ slack create [app-name] [flags]

Flags

  • -t, --template string Template URL for your app

Usage

Creates and initializes a new Slack app on your local machine from an optional template.

The command begins by creating the local app in a directory called (e.g. slack_project ). If the directory happens to already exist, then it will try -1, -2, until an available directory is found. Once the directory is created, the default Slack app template for Node.js is copied over and the node dependencies are installed. To finish off, the slack.yaml file will be updated use as the app's name.

After creating your local app, the command will now create the app manifest configuration. When it's complete, you'll see your app on https://api.slack.com/apps.

At this point, you have everything you need to start coding and deploying your app to Slack Cloud!

Using Templates

You can create an app from a template using the --template flag. This command supports many sources:

  • https:// Git repository:
    • Example: https://github.com:slackapi/bolt-js-getting-started-app
  • git@ repository:
    • Example: git@github.com:slackapi/bolt-js-getting-started-app.git
  • git:// repository:
    • Example: git://github.com/slackapi/bolt-js-getting-started-app
  • ssh:// Git repository:
    • Example: ssh://username@host.xz/path/to/repo.git/
  • GitHub relative url:
    • Example: slackapi/bolt-js-getting-started-app
  • Local path:
    • Example: ../path/to/bolt-js-getting-started-app
    • Directory does not have to be a Git repository.

When an app is created from a template, the slack.yaml and environments.yaml files will be created when missing.


auth login

$ slack auth login [flags]
$ slack login [flags]

Flags

  • --auth string An existing user token (e.g. xoxp-abc123...)

Aliases

  • login

Usage

Login to a new workspace, or a previously authed workspace that has become inactive. Logging in is required before an app can be installed to a workspace or deployed to Slack's infrastructure.

A single developer can auth with multiple workspaces and authing with a new workspace does not invalidate any existing authentications. The auth list command will return a list of workspaces you are authed to.

If you are logged into multiple workspaces, running slack login will let you interactively choose a different workspace to make active. The active workspace determines where the app gets installed, deployed, run, etc.


auth info

$ slack auth info [flags]
$ slack info [flags]

Alias

  • info

Usage

View information about your current active authorization. Includes who owns the app and which workspace the app is installed to.


auth logout

$ slack auth logout [flags]
$ slack logout [flags]

Aliases

  • logout

Usage

Invalidate the session with a Slack workspace and delete your credentials.


cloud activity

$ slack cloud activity [flags]
$ slack activity [flags]
$ slack log [flags]
$ slack logs [flags]

Flags

  • --idle int time, in minutes, to continue without results before exiting (default: 5)
  • -i, --interval int polling interval, in seconds (default: 3)
  • -t, --tail continuously poll for new activity

Aliases

  • activity
  • log
  • logs

Get app activity and log information for the hosted app. Anything that is logged via console.log() in an app's code will be shown here as well, which can be helpful for debugging. Use the -t or --tail flag to continuously poll for new activity while the app is running.


cloud deploy

$ slack cloud deploy [flags]
$ slack deploy [flags]

Deploys the app to Slack-hosted infrastructure. Your app will be listed on the developer UI but you will only be able to manage it via the slack cli tool. You can also run this command to sync any changes you've made to your code to the installed version of the app.


cloud run

$ slack cloud run [flags]
$ slack run [flags]

Aliases

  • run
  • dev
  • start-dev

Usage

Develop locally without needing to deploy to Slack-hosted infrastructure. The cloud run command will automatically create a secure connection between your local machine and your Slack workspace (using Socket Mode) so that you can develop and test you application quickly and easily.

Changes made to your app will be automatically reflected live in your workspace when you save with no interventions required. Once you are happy with the state of your app, you can deploy using cloud deploy


tables put

$ slack tables put <row details> [flags]

Usage

The tables command interacts with the Tables API via the command line. The put subcommand adds a single row to an existing table, using the standard format for putting a new row, with the addition of the ID of the app. The app ID is required because the command could be run from anywhere, not just in the context of a particular app, or as part of an automation.

The JSON following the command should be enclosed in single quotes (').

$ slack tables put '{"table": "todos", "app": "A0123A45BCD", "row": {"id": "42", "description": "Create a PR", "status": "Done"}}'

tables query

$ slack tables query <query details> [flags]

Usage

The tables command interacts with the Tables API via the command line. The query subcommand queries a given table using the query expression syntax. The query command takes a full JSON expression, with the addition of the ID of the app. The app ID is required because the command could be run from anywhere, not just in the context of a particular app, or as part of an external automation.

$ slack tables query '{"table": "tasks", "app": "A0123A45BCD", "expression": "#status = :status", "expression_columns": {"#status": "status"}, "expression_values": {":status": "In Progress"}}'

It's also possible to omit the expression fields, which will return all the rows for a table.

$ slack tables query '{"table": "tasks", "app": "A0123A45BCD"}'

tables get

$ slack tables get <row details> [flags]

Usage

The tables command interacts with the Tables API via the command line. The get subcommand returns a single row given a table name and the ID of a row. The app ID is required because the command could be run from anywhere, not just in the context of a particular app, or as part of an automation.

$ slack tables get '{"table": "tasks", "app": "A0123A45BCD", "id": "3"}'

tables delete

$ slack tables delete <row details> [flags]

Usage

The tables command interacts with the Tables API via the command line. The delete subcommand will remove a row by ID.

$ slack tables delete '{"table": "tasks", "app": "A0123A45BCD", "id": "3"}'

var add

$ slack var add <variable name> <variable value> [flags]

Usage

Environment variables allow for persistent data storage for your application's runtime and behave similarly to the way standard Unix environment variables work. They are useful for storing configuration data for your app, such as an access token to another API, that you don't want to hard code into your app for security reasons or that you may need to update without wanting to re-deploy the application. The environment variable will be available locally

Environment variables are accessible in your application's code via the env object made available by the TypeScript SDK. For example, an environment variable named FOO would be accessed via:

${env["FOO"]}

Running var add command with a variable that already exists and a new value will set the variable to the new value.


var list

$ slack var list [flags]

Usage

Shows a list of all variables set. The values are obscured for security.


var remove

$ slack var remove <variable name> [flags]

Usage

Removes a variable from usage. Any calls to the removed variable in code will almost certainly generate an error.


workspace install

$ slack workspace install [flags]

Usage

Install the app to a workspace. You will have the option to install to a workspace that you have already authenticated into or have the option to auth into a new workspace.

This is the equivalent of installing an app to a workspace via the traditional app console or using the OAuth flow.

The first time the run or deploy commands are run, the app will be installed if it isn't already. You may need to call install again if you request new OAuth scopes for your application.


workspace list

$ slack workspace list [flags]

Usage

List all of the workspaces where an app is installed.


workspace uninstall

$ slack environment remove <env> [flags]

Usage

Remove an app from a workspace and deletes the app's manifest.


doctor

$ slack doctor [flags]

Usage

Checks to make sure your local development environment has all the required prerequisites and system requirements for running and deploying an app.


version

$ slack version

Print the current version of the CLI.


Global Flags

$ slack --apihost string

Slack API host (default https://slack.com)

$ slack -e, --environment string

Specify the app environment

$ slack -f, --force

Force update app manifest

$ slack -h, --help

Help for slack commands. Use this flag with any command (e.g. slack create --help) to get more information about a specific command

$ slack -v, --verbose

When set, prints verbose debug logging

$ slack -s, --skip-update

Use to disable version update notifications.

Integrating the CLI into a pipeline

In addition to being useful for setting up new projects and local development, the CLI can be integrated into test and deployment pipelines, for continuous integration and continuous deployment and other "headless" automation.

Running in a headless mode first requires authenticating using the --auth flag and passing along a user token. This will generate the authentication credentials required in a ~/.slack directory. Removing this directory will remove the authentication.

Once authenticated, any slack command can be run as normal and will use the established auth.

Integrated SDK

To make development easier, the CLI includes an integrated SDK. The most common use of the SDK will be the client object, which works similarly to the the way it does in Bolt for JavaScript. The client object can be used to call any Slack API method, like so:

const client = new SlackAPIClient("");

try{
	client.call("conversations.list");
} catch (ex) { console.log("error: ", ex)};

The SDK is written in TypeScript with defined types, allows for features like code completion in supported IDEs. If you are using VS Code, new projects already include a .vscode folder with all of the type definitions needed to activate IntelliSense.

The SDK can also be versioned via the import_map.json file in the root of a project directory. This allows you to specify which version of the SDK you prefer to use by pointing to a versioned URL.

The latest version of the SDK will always point to https://slack.com/cloud/static/common/sdk/. Specific versions can be specified like so: https://slack.com/cloud/static/common/sdk@0.1.0/

Deprecated Commands

These commands are deprecated and will no longer be supported. Please migrate to the updated commands.

new

$ slack new

Please use slack create instead.

Was this page helpful?