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
@@ -18,56 +18,70 @@ In search of the complete guide to building an app from scratch? Check out the [
18
18
19
19
#### Prerequisites
20
20
21
-
A few tools are needed for the following steps:
22
-
* A workspace where development can happen is also needed. We recommend using [developer sandboxes](/tools/developer-sandboxes) to avoid disruptions where real work gets done.
23
-
* Git
24
-
*[Python 3.7 or later](https://www.python.org/downloads/). Refer to [Python's setup and building guide](https://devguide.python.org/getting-started/setup-building/) for more details.
25
-
26
-
27
-
import QuickstartGuide from '@site/src/components/QuickstartGuide';
28
-
29
-
<QuickstartGuide
30
-
steps={[
31
-
{
32
-
number: 1,
33
-
title: 'Install the Slack CLI',
34
-
description: 'Download the command-line tool for developing Slack apps.',
You now have the Slack CLI and the starter sample app ready for use. Open up the app in your editor of choice and let's explore what the agent can actually do.
63
-
64
-
65
-
## Setting up your environment
66
-
67
-
After the project is created you'll have a `requirements.txt` file for app dependencies and a `.slack` directory for Slack CLI configuration.
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.
45
+
46
+
We recommend using [developer sandboxes](/tools/developer-sandboxes) to avoid disruptions where real work gets done.
47
+
48
+
:::
49
+
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
+
71
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/):
72
86
73
87
```sh
@@ -87,6 +101,9 @@ $ which python3
87
101
88
102
Before you can start developing with Bolt, you will want a running Slack app.
89
103
104
+
<TabsgroupId="cli-or-terminal">
105
+
<TabItemvalue="cli"label="Slack CLI">
106
+
90
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:
91
108
92
109
```sh
@@ -103,6 +120,69 @@ With the app running, you can test it out with the following steps in Slack:
103
120
104
121
After confirming the app responds, celebrate, then interrupt the process by pressing `CTRL+C` in the terminal to stop your app from running.
105
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**:
3. Copy the bot token beginning with `xoxb` from the **OAuth & Permissions page** and then store it in a new environment variable:
162
+
163
+
```sh
164
+
$ export SLACK_BOT_TOKEN=xoxb-<your-bot-token>
165
+
```
166
+
167
+
After saving tokens for the app you created, it is time to run it:
168
+
169
+
```sh
170
+
$ python3 app.py
171
+
...
172
+
⚡️ Bolt app is running!
173
+
```
174
+
175
+
With the app running, you can test it out with the following steps in Slack:
176
+
177
+
1. Open a direct message with your app or invite the bot `@BoltApp` to a public channel.
178
+
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
+
181
+
After confirming the app responds, celebrate, then interrupt the process by pressing `CTRL+C` in the terminal to stop your app from running.
182
+
183
+
</TabItem>
184
+
</Tabs>
185
+
106
186
## Updating the app
107
187
108
188
At this point, you've successfully run the getting started Bolt for Python [app](https://github.com/slack-samples/bolt-python-getting-started-app)!
@@ -127,6 +207,9 @@ def message_goodbye(say):
127
207
128
208
Once the file is updated, save the changes and then we'll make sure those changes are being used.
129
209
210
+
<TabsgroupId="cli-or-terminal">
211
+
<TabItemvalue="cli"label="Slack CLI">
212
+
130
213
Run the following command and select the app created earlier to start, or restart, your app with the latest changes:
131
214
132
215
```sh
@@ -143,10 +226,35 @@ After finding the above output appears, open Slack to perform these steps:
143
226
144
227
Your app can be stopped again by pressing `CTRL+C` in the terminal to end these chats.
145
228
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
+
146
251
#### Customizing app settings
147
252
148
253
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.
149
254
255
+
<TabsgroupId="cli-or-terminal">
256
+
<TabItemvalue="cli"label="Slack CLI">
257
+
150
258
Open app settings for your app with the following command:
151
259
152
260
```sh
@@ -157,6 +265,18 @@ This will open the following page in a web browser:
157
265
158
266

159
267
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
+
160
280
On these pages you're free to make changes such as updating your app icon, configuring app features, and perhaps even distributing your app!
0 commit comments