This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Interact with Slack from the command line

Project Description

Interact with Slack from the command line: send messages, upload files, send command output, pipe content, all from the confort of your terminal.

This was initially a fork of but the two projects have now considerably diverged.


pip install slack-cli

You should obtain an API token from Slack. To obtain a token, go to the API token generator.


$ slack-cli -h
usage: slack-cli [-h] [-t TOKEN] [-d DST] [-s SRC] [-f FILE] [--pre] [--run]
                 [messages [messages ...]]

Send, pipe, upload and receive Slack messages from the CLI

positional arguments:
  messages              Messages to send. Pass "-" to send content from stdin.

optional arguments:
  -h, --help            show this help message and exit
  -t TOKEN, --token TOKEN
                        Slack token which will be saved to
                        /home/username/.config/slack-cli/slack_token. This
                        argument only needs to be specified once.
  -d DST, --dst DST     Send message to a Slack channel, group or username
  -s SRC, --src SRC     Receive messages from a Slack channel, group or
  -f FILE, --file FILE  Upload file
  --pre                 Send as verbatim `message`
  --run                 Run the message as a shell command and send both the
                        message and the command output

Note that the Slack token may optionally be stored in an environment variable (although it is not recommended for security reasons):

export SLACK_TOKEN="slack_token_string"

Send message

The destination argument may be any user, group or channel:

slack-cli -d general "Hello everyone!"
slack-cli -d slackbot "Hello!"

Pipe content

cat /etc/hosts | slack-cli -d devteam -

Usually you will want to format piped content as verbatim content with triple backticks (““`”). This is achieved with the –pre option:

tail -f /var/log/nginx/access.log | slack-cli -d devteam --pre -

Upload file

slack-cli -f /etc/nginx/sites-available/default.conf -d alice

Run command and send output

This is really convenient for showing both the result of a command and the command itself:

slack-cli -d john --run "git log -1"

will send to user john:

$ git log -1
commit 013798f5c85043d31f0221a9a32b39298e97fb08
Author: Régis Behmo <>
Date:   Thu Jun 22 15:20:36 2017 +0200

    Replace all commands by a single command

    Our first 1.0 release!

Stream content from slack

For monitoring a Slack channel from the terminal:

slack-cli -s general


v1.0 (2017-07-06):

  • Refactor command line by reducing all commands to a single “slack-cli” command.
  • Interactive API token input.
  • Automatic token creation check.


I am very much open to comments! Please don’t be afraid to raise issues or open pull requests.


  • Support for multiple Slack teams
Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
slack-cli-1.0.1.tar.gz (5.6 kB) Copy SHA256 Checksum SHA256 Source Jul 6, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting