Skip to main content

Skip right to the code

TLDR: Want to jump right into the code, checkout the code here: https://replit.com/join/kjfwuwqdet-ishaan-jaff

Prerequisites

A Slack account A Slack app with Bot Token Scopes and User Token Scopes set up

Step 1. Import the necessary libraries:

Step 2. Create the OAuth settings object with your client ID, client secret, and desired scopes. You’ll also need to specify the installation and state store directories, as well as the redirect URI for the OAuth flow.

Step 3. Create the Slack Bolt app object with your signing secret and OAuth settings object.

Step 4. Create a WebClient object with your bot token. This will be used to send messages later.

Step 5. Define any event handlers that you want to use with your app. In this case, there are two event handlers: one for message events and one for app_mention events.

This code responds with a “Hi from your Slackbot!” message and calls the API endpoint at https://jsonplaceholder.typicode.com/todos/1. It retrieves the title field from the API response and sends it back as a message to the channel.

Step 6. Create a Flask app and a Slack request handler for your app.

Step 7. Define a route for Slack events and use the request handler to handle requests.

Step 8. Enjoy :)

Link to a demo slack bot we built at Berri: https://replit.com/join/kjfwuwqdet-ishaan-jaff