Sample app for Pycon 2018 Slack app workshop
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
Pycon 2018 Workshop.pdf


Slack Pycon Workshop Bot

This repo is to complement the live demonstration being given at Pycon 2018.

This example app shows how easy it is to implement the Slack Events API Adapter to receive Slack Events and respond to messages using Slack's Web API via python-slackclient, with the added flair of message buttons to provide a neat feedback mechanism.

We'll be starting off with, which is a very basic echo bot based on the Slack Evants API Adapter example app available in that library's github repo. From there, we'll incrementally add additional functionality to end up in the same state as If you're checking this out on your own, you may want to start with to see the completed [but still pretty basic] app.

πŸ€– Setup and running the app

Set up your Python environment:

We're using virtualenv to keep the dependencies and environmental variables specific to this app. See virtualenv docs for more info.

This example app works best in Python 2.7. If 2.7 is your default version, create a virtual environment by running:

virtualenv env

Otherwise, if Python 3+ is your default, specify the path to your 2.7 instance:

virtualenv -p /your/path/to/python2 env

Then initialize the virtualenv:

source env/bin/activate

Install the app's dependencies:

pip install -r requirements.txt

πŸ€– Create a Slack app

Create a Slack app on

πŸ€– Add a bot user to your app

πŸ€– Install your app on your team

Visit your app's Install App page and click Install App to Team.

Authorize your app

πŸ€– Save your app's credentials

Once you've authorized your app, you'll be presented with your app's tokens.

Copy your app's Bot User OAuth Access Token and add it to your python environmental variables

export SLACK_BOT_TOKEN=xxxXXxxXXxXXxXXXXxxxX.xXxxxXxxxx

Next, go back to your app's Basic Information page

Add your app's Verification Token to your python environmental variables


πŸ€– Start ngrok

In order for Slack to contact your local server, you'll need to run a tunnel. We recommend ngrok or localtunnel. We're going to use ngrok for this example.

If you don't have ngrok, download it here.

Here's a rudimentary diagream of how ngrok allows Slack to connect to your server

πŸ’‘ Slack requires event requests be delivered over SSL, so you'll want to
use the HTTPS URL provided by ngrok.

Run ngrok and copy the HTTPS URL

ngrok http 3000
ngrok by @inconshreveable (Ctrl+C to quit)

Session status                      online
Version                             2.1.18
Region                  United States (us)
Web Interface

Forwarding -> localhost:9292
Forwarding -> localhost:9292

πŸ€– Run the app:

You'll need to have your server and ngrok running to complete your app's Event Subscription setup


πŸ€– Subscribe your app to events

Add your Request URL (your ngrok URL + /slack/events) and subscribe your app to reaction_added, message.channels and app_mentions under bot events. Save and toggle Enable Events to on

πŸŽ‰ Once your app has been installed and subscribed to Bot Events, you will begin receiving event data from Slack

πŸ‘‹ Interact with your bot:

Invite your bot to a public channel, then say hi and your bot will respond

hi @bot πŸ‘‹

React to your bot's greeting and the bot will echo back the eomi you reacted with

@roach reacted with 😎

Next, mention your app's bot user directly and the bot will promt you for feedback


@bot I have feedback!


Hi @roach! How do you feel this workshop is going?

More neat things:

Check out the other events you can subscribe to 😎

Play with our Message Builder to see more message formatting options πŸ˜„

Browse our example apps on Github for more functionality, like Dialogs 🀩

πŸ€” Support

Need help? Join Bot Developer Hangout and talk to us in #slack-api.

You can also create an Issue right here on GitHub.