This guide will cover how to get started with your next-gen platform using Bolt for Python, by setting up the Slack CLI and installing the required dependencies.
Find out about the next-generation platform on Slack’s official introduction page.
This guide will cover how to get started with your next-gen platform using Bolt for Python, by setting up the Slack CLI and installing the required dependencies.
Find out about the next-generation platform on Slack’s official introduction page.
Bolt for Python supports app development using next-gen platform features like Functions, Workflows and tools such as the Slack CLI alongside all current generally available Slack Platform features.
💡 If you’d like to deploy your app with Slack infrastructure, consider building your next-generation application with the Deno Slack API. You can get started with that here.
To build a next-generation app with Bolt for Python, you’ll need to get the Slack CLI.
Install the Slack CLI by following this Quickstart. Since we won’t be using Deno to build our next-generation app, you can skip any instructions related to installing Deno or creating an app using a Deno template. Once you’ve logged into the CLI using slack login
and verified your login using slack auth list
, you can proceed with the instructions in this guide.
Once the CLI is set up, make sure your machine has the most recent version of Python installed. You can install Python through a package manager (such as Homebrew for macOS) or directly from the website.
Before you start developing with Bolt, you’ll want to create a Slack app.
To create the app, you’ll run the following command:
1
slack create my-app -t slack-samples/bolt-python-starter-template -b future
This command creates an app through the CLI by cloning a specified template. In this case, the template is the Bolt for Python Starter Template on the future
branch. This starter template includes a “Hello World” example that demonstrates how to use built-in and custom Functions, Triggers and Workflows.
Once the app is successfully created, you should see a message like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
✨ my-app successfully created
🧭 Explore your project's README.md for documentation and code samples, and at any time run slack help to display a list of available commands
🧑🚀 Follow the steps below to try out your new project
1️⃣ Change into your project directory with: cd my-app
2️⃣ Develop locally and see changes in real-time with: slack run
3️⃣ When you're ready to deploy for production use: slack deploy
🔔 If you leave the workspace, you won’t be able to manage any apps you’ve deployed to it. Apps you deploy will belong to the workspace even if you leave the workspace
As mentioned, this app comes with pre-existing functionality - it uses Functions, Workflows and a Link Trigger that will allow users in Slack to initiate the functionality provided by the app. Let’s run a command to initialize that Link Trigger via the CLI.
First, make sure you’re in the project directory in your command line: cd my-app
Then, run the following command to create a Trigger:
1
slack triggers create --trigger-def "triggers/sample-trigger.json"
The above command will create a Link Trigger for the selected workspace. Make sure to select the workspace you want. Once the trigger is successfully created, you should see an output like this:
1
2
3
4
5
⚡ Trigger created
Trigger ID: [ID]
Trigger Type: shortcut
Trigger Name: Sample Trigger
URL: https://slack.com/shortcuts/[ID]/[Some ID]
The provided URL can be pasted into Slack; Slack will unfurl it into a button that users can interact with to initiate your app’s functionality! Copy this URL and save it somewhere; you’ll need it for later.
Now that your app and Trigger are successfully created, let’s try running it!
1
2
3
4
5
# install the required project dependencies
pip install -r requirements.txt
# start a local development server
slack run
Executing pip install -r requirements.txt
installs all the project requirements to your machine.
Executing slack run
starts a local development server, syncing changes to your workspace’s development version of your app.
You’ll be prompted to select a workspace to install the app to—select the development instance of your workspace (you’ll know it’s the development version because the name has the string (dev)
appended).
💡 If you don’t see the workspace you’d like to use in the list, you can
CTRL + C
out of theslack run
command and runslack auth login
. This will allow you to authenticate in your desired workspace to have it show up in the list forslack run
.
You’ll see an output in your Terminal to indicate your app is running, similar to what you would see with any other Bolt for Python app. You can search for the ⚡️ Bolt app is running! ⚡️
message to make sure that your app has successfully started up.
With your app running, access your workspace and paste the URL from the Trigger you created in the previous step into a message in a public channel.
💡 App Triggers are automatically saved as a channel bookmark under “Workflows” for easy access.
Send the message and click the “Run” button that appears. A modal will appear prompting you to enter information to greet someone in your Slack workspace. Fill out the requested information.
Then, submit the form. In the specified channel submitted in the form, you should receive a message from the app tagging the submitted user. The message will also contain a randomly generated greeting and the message you wrote in the form.
The full app flow can be seen here:
Now we have a working instance of a next-generation app in your workspace and you’ve seen it in action! You can explore on your own and dive into the code yourself here or continue your learning journey by diving into App Manifests or looking into adding more Functions, Workflows, and Triggers to your app!