You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This quickstart guide aims to help you get a Slack app using Bolt for Python up and running as soon as possible!
6
+
This quickstart guide aims to help you get a Slack app using Bolt for Python up and running as soon as possible!
7
7
8
-
import Tabs from '@theme/Tabs';
9
-
import TabItem from '@theme/TabItem';
8
+
When complete, you'll have a local environment configured with a customized [app](https://github.com/slack-samples/bolt-python-getting-started-app) that responds to "hello" messages. You'll then be able to modify it and make it your own.
10
9
11
-
When complete, you'll have a local environment configured with a customized [app](https://github.com/slack-samples/bolt-python-getting-started-app) running to modify and make your own.
10
+
## Setting up the app
12
11
13
-
:::tip[Reference for readers]
14
-
15
-
In search of the complete guide to building an app from scratch? Check out the [building an app](/tools/bolt-python/building-an-app) guide.
16
-
17
-
:::
18
-
19
-
#### Prerequisites
20
-
21
-
A few tools are needed for the following steps. We recommend using the [**Slack CLI**](/tools/slack-cli/) for the smoothest experience, but other options remain available.
22
-
23
-
You can also begin by installing git and downloading [Python 3.7 or later](https://www.python.org/downloads/), or the latest stable version of Python. Refer to [Python's setup and building guide](https://devguide.python.org/getting-started/setup-building/) for more details.
24
-
25
-
Install the latest version of the Slack CLI to get started:
26
-
27
-
-[Slack CLI for macOS & Linux](/tools/slack-cli/guides/installing-the-slack-cli-for-mac-and-linux)
28
-
-[Slack CLI for Windows](/tools/slack-cli/guides/installing-the-slack-cli-for-windows)
29
-
30
-
Then confirm a successful installation with the following command:
31
-
32
-
```sh
33
-
$ slack version
34
-
```
35
-
36
-
An authenticated login is also required if this hasn't been done before:
37
-
38
-
```sh
39
-
$ slack login
40
-
```
41
-
42
-
:::info[A place to belong]
43
-
44
-
A workspace where development can happen is also needed.
12
+
:::info[A workspace where development can happen is needed.]
45
13
46
14
We recommend using [developer sandboxes](/tools/developer-sandboxes) to avoid disruptions where real work gets done.
47
15
48
16
:::
49
17
50
-
## Creating a project {#creating-a-project}
51
-
52
-
With the toolchain configured, it's time to set up a new Bolt project. This contains the code that handles logic for your app.
53
-
54
-
If you don’t already have a project, let’s create a new one!
55
-
56
-
<TabsgroupId="cli-or-terminal">
57
-
<TabItemvalue="cli"label="Slack CLI">
58
-
59
-
A starter template can be used to start with project scaffolding:
Outlines of a project are taking shape, so we can move on to running the app!
81
-
82
-
</TabItem>
83
-
</Tabs>
84
-
85
-
We recommend using a [Python virtual environment](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#creating-a-virtual-environment) to manage your project's dependencies. This is a great way to prevent conflicts with your system's Python packages. Let's create and activate a new virtual environment with [Python 3.7 or later](https://www.python.org/downloads/):
86
-
87
-
```sh
88
-
$ python3 -m venv .venv
89
-
$ source .venv/bin/activate
90
-
$ pip install -r requirements.txt
91
-
```
92
-
93
-
Confirm the virtual environment is active by checking that the path to `python3` is _inside_ your project ([a similar command is available on Windows](https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/#activating-a-virtual-environment)):
Before you can start developing with Bolt, you will want a running Slack app.
103
-
104
-
<TabsgroupId="cli-or-terminal">
105
-
<TabItemvalue="cli"label="Slack CLI">
106
-
107
-
The getting started app template contains a `manifest.json` file with details about an app that we will use to get started. Use the following command and select "Create a new app" to install the app to the team of choice:
108
-
109
-
```sh
110
-
$ slack run
111
-
...
112
-
⚡️ Bolt app is running!
113
-
```
114
-
115
-
With the app running, you can test it out with the following steps in Slack:
116
-
117
-
1. Open a direct message with your app or invite the bot `@first-bolt-app (local)` to a public channel.
118
-
2. Send "hello" to the current conversation and wait for a response.
119
-
3. Click the attached button labelled "Click Me" to post another reply.
120
-
121
-
After confirming the app responds, celebrate, then interrupt the process by pressing `CTRL+C` in the terminal to stop your app from running.
122
-
123
-
</TabItem>
124
-
<TabItemvalue="terminal"label="Browser">
125
-
126
-
Navigate to your list of apps and [create a new Slack app](https://api.slack.com/apps/new) using the "from a manifest" option:
127
-
128
-
1. Select the workspace to develop your app in.
129
-
2. Copy and paste the `manifest.json` file contents to create your app.
130
-
3. Confirm the app features and click "Create".
131
-
132
-
You'll then land on your app's **Basic Information** page, which is an overview of your app and which contains important credentials:
133
-
134
-

135
-
136
-
To listen for events happening in Slack (such as a new posted message) without opening a port or exposing an endpoint, we will use [Socket Mode](/tools/bolt-python/concepts/socket-mode). This connection requires a specific app token:
137
-
138
-
1. On the **Basic Information** page, scroll to the **App-Level Tokens** section and click **Generate Token and Scopes**.
139
-
2. Name the token "Development" or something similar and add the `connections:write` scope, then click **Generate**.
140
-
3. Save the generated `xapp` token as an environment variable within your project:
141
-
142
-
```sh
143
-
$ export SLACK_APP_TOKEN=<your-app-level-token>
144
-
```
145
-
146
-
The above command works on Linux and macOS but [similar commands are available on Windows](https://superuser.com/questions/212150/how-to-set-env-variable-in-windows-cmd-line/212153#212153).
147
-
148
-
:::warning[Keep it secret. Keep it safe.]
149
-
150
-
Treat your tokens like a password and [keep it safe](/security). Your app uses these to retrieve and send information to Slack.
151
-
152
-
:::
153
-
154
-
A bot token is also needed to interact with the Web API methods as your app's bot user. We can gather this as follows:
155
-
156
-
1. Navigate to the **OAuth & Permissions** on the left sidebar and install your app to your workspace to generate a token.
157
-
2. After authorizing the installation, you'll return to the **OAuth & Permissions** page and find a **Bot User OAuth Token**:
With the app running, you can test it out with the following steps in Slack:
176
67
177
-
1. Open a direct message with your app or invite the bot `@BoltApp` to a public channel.
68
+
1. Invite the bot `@first-bolt-app (local)` to a public channel. You can do this a few ways:
69
+
Option A: @-mention them in a message in a channel. You will be prompted to add them
70
+
Option B: Click the channel name, go to the "Integrations" tab, and click the "Add apps" button
71
+
178
72
2. Send "hello" to the current conversation and wait for a response.
179
-
3. Click the attached button labelled "Click Me" to post another reply.
180
73
181
74
After confirming the app responds, celebrate, then interrupt the process by pressing `CTRL+C` in the terminal to stop your app from running.
182
75
183
-
</TabItem>
184
-
</Tabs>
185
-
186
76
## Updating the app
187
77
188
78
At this point, you've successfully run the getting started Bolt for Python [app](https://github.com/slack-samples/bolt-python-getting-started-app)!
189
79
190
80
The defaults included leave opportunities abound, so to personalize this app let's now edit the code to respond with a kind farewell.
191
81
192
-
####Responding to a farewell
82
+
### Responding to a farewell
193
83
194
84
Chat is a common thing apps do and responding to various types of messages can make conversations more interesting.
195
85
@@ -207,9 +97,6 @@ def message_goodbye(say):
207
97
208
98
Once the file is updated, save the changes and then we'll make sure those changes are being used.
209
99
210
-
<TabsgroupId="cli-or-terminal">
211
-
<TabItemvalue="cli"label="Slack CLI">
212
-
213
100
Run the following command and select the app created earlier to start, or restart, your app with the latest changes:
214
101
215
102
```sh
@@ -226,35 +113,10 @@ After finding the above output appears, open Slack to perform these steps:
226
113
227
114
Your app can be stopped again by pressing `CTRL+C` in the terminal to end these chats.
228
115
229
-
</TabItem>
230
-
<TabItemvalue="terminal"label="Terminal">
231
-
232
-
Run the following command to start, or restart, your app with the latest changes:
233
-
234
-
```sh
235
-
$ python3 app.py
236
-
...
237
-
⚡️ Bolt app is running!
238
-
```
239
-
240
-
After finding the above output appears, open Slack to perform these steps:
241
-
242
-
1. Return to the direct message or public channel with your bot.
243
-
2. Send "goodbye" to the conversation.
244
-
3. Receive a parting response from before and repeat "goodbye" to find another one.
245
-
246
-
Your app can be stopped again by pressing `CTRL+C` in the terminal to end these chats.
247
-
248
-
</TabItem>
249
-
</Tabs>
250
-
251
-
#### Customizing app settings
116
+
### Customizing app settings
252
117
253
118
The created app will have some placeholder values and a small set of [scopes](/reference/scopes) to start, but we recommend exploring the customizations possible on app settings.
254
119
255
-
<TabsgroupId="cli-or-terminal">
256
-
<TabItemvalue="cli"label="Slack CLI">
257
-
258
120
Open app settings for your app with the following command:
259
121
260
122
```sh
@@ -265,24 +127,12 @@ This will open the following page in a web browser:
265
127
266
128

267
129
268
-
</TabItem>
269
-
<TabItemvalue="terminal"label="Browser">
270
-
271
-
Browse to https://api.slack.com/apps and select your app "Getting Started Bolt App" from the list.
272
-
273
-
This will open the following page:
274
-
275
-

276
-
277
-
</TabItem>
278
-
</Tabs>
279
-
280
130
On these pages you're free to make changes such as updating your app icon, configuring app features, and perhaps even distributing your app!
281
131
282
132
## Next steps {#next-steps}
283
133
284
134
You can now continue customizing your app with various features to make it right for whatever job's at hand. Here are some ideas about what to explore next:
285
135
286
-
-Follow along with the steps that went into making this app on the [creating an app](/tools/bolt-python/creating-an-app) guide for an educational overview.
136
+
-Learn the steps that went into making this app on the [creating an app](/tools/bolt-python/creating-an-app) guide for an educational overview. This is also where you can learn how to create the app without using the Slack CLI.
287
137
- Check out the [Agent quickstart](/ai/agent-quickstart) to get up and running with an agent.
288
138
- Browse our [curated catalog of samples](/samples) for more apps to use as a starting point for development.
0 commit comments