Skip to content

Commit ec26011

Browse files
commit
1 parent 2266ac7 commit ec26011

1 file changed

Lines changed: 58 additions & 208 deletions

File tree

‎docs/english/getting-started.md‎

Lines changed: 58 additions & 208 deletions
Original file line numberDiff line numberDiff line change
@@ -3,193 +3,83 @@ sidebar_label: Quickstart
33
title: Quickstart guide with Bolt for Python
44
---
55

6-
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!
77

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.
109

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
1211

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.]
4513

4614
We recommend using [developer sandboxes](/tools/developer-sandboxes) to avoid disruptions where real work gets done.
4715

4816
:::
4917

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-
<Tabs groupId="cli-or-terminal">
57-
<TabItem value="cli" label="Slack CLI">
58-
59-
A starter template can be used to start with project scaffolding:
60-
61-
```sh
62-
$ slack create first-bolt-app --template slack-samples/bolt-python-getting-started-app
63-
$ cd first-bolt-app
64-
```
65-
66-
After a project is created you'll have a `requirements.txt` file for app dependencies and a `.slack` directory for Slack CLI configuration.
67-
68-
A few other files exist too, but we'll visit these later.
69-
70-
</TabItem>
71-
<TabItem value="terminal" label="Terminal">
72-
73-
A starter template can be cloned to start with project scaffolding:
74-
75-
```sh
76-
$ git clone https://github.com/slack-samples/bolt-python-getting-started-app first-bolt-app
77-
$ cd first-bolt-app
78-
```
79-
80-
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)):
94-
95-
```sh
96-
$ which python3
97-
# Output: /path/to/first-bolt-app/.venv/bin/python3
98-
```
99-
100-
## Running the app {#running-the-app}
101-
102-
Before you can start developing with Bolt, you will want a running Slack app.
103-
104-
<Tabs groupId="cli-or-terminal">
105-
<TabItem value="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-
<TabItem value="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-
![Basic Information page](/img/bolt-python/basic-information-page.png "Basic Information page")
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**:
158-
159-
![OAuth Tokens](/img/bolt-python/bot-token.png "Bot OAuth Token")
160-
161-
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-
```
18+
import QuickstartGuide from '@site/src/components/QuickstartGuide';
19+
20+
<QuickstartGuide
21+
steps={[
22+
{
23+
number: 1,
24+
title: 'Install the Slack CLI',
25+
description: 'Download the command-line tool for developing Slack apps.',
26+
commands: {
27+
macos: 'curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash',
28+
windows: 'irm https://downloads.slack-edge.com/slack-cli/install-windows.ps1 | iex'
29+
}
30+
},
31+
{
32+
number: 2,
33+
title: 'Connect to your workspace',
34+
description: 'Log in and authenticate with your Slack workspace.',
35+
commands: {
36+
macos: 'slack login',
37+
windows: 'slack login'
38+
}
39+
},
40+
{
41+
number: 3,
42+
title: 'Use the starter app as a template',
43+
description: 'Select "Starter app" after running the command',
44+
commands: {
45+
macos: 'slack create',
46+
windows: 'slack create'
47+
}
48+
},
49+
{
50+
number: 4,
51+
title: 'Run your app',
52+
description: 'See your app working in Slack.',
53+
commands: {
54+
macos: 'slack run',
55+
windows: 'slack run'
56+
}
57+
}
58+
]}
59+
buttonText="View app code"
60+
buttonLink="https://github.com/slack-samples/bolt-python-getting-started-app"
61+
buttonIcon={true}
62+
/>
63+
64+
## Testing the app {#testing-the-app}
17465

17566
With the app running, you can test it out with the following steps in Slack:
17667

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+
17872
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.
18073

18174
After confirming the app responds, celebrate, then interrupt the process by pressing `CTRL+C` in the terminal to stop your app from running.
18275

183-
</TabItem>
184-
</Tabs>
185-
18676
## Updating the app
18777

18878
At this point, you've successfully run the getting started Bolt for Python [app](https://github.com/slack-samples/bolt-python-getting-started-app)!
18979

19080
The defaults included leave opportunities abound, so to personalize this app let's now edit the code to respond with a kind farewell.
19181

192-
#### Responding to a farewell
82+
### Responding to a farewell
19383

19484
Chat is a common thing apps do and responding to various types of messages can make conversations more interesting.
19585

@@ -207,9 +97,6 @@ def message_goodbye(say):
20797

20898
Once the file is updated, save the changes and then we'll make sure those changes are being used.
20999

210-
<Tabs groupId="cli-or-terminal">
211-
<TabItem value="cli" label="Slack CLI">
212-
213100
Run the following command and select the app created earlier to start, or restart, your app with the latest changes:
214101

215102
```sh
@@ -226,35 +113,10 @@ After finding the above output appears, open Slack to perform these steps:
226113

227114
Your app can be stopped again by pressing `CTRL+C` in the terminal to end these chats.
228115

229-
</TabItem>
230-
<TabItem value="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
252117

253118
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.
254119

255-
<Tabs groupId="cli-or-terminal">
256-
<TabItem value="cli" label="Slack CLI">
257-
258120
Open app settings for your app with the following command:
259121

260122
```sh
@@ -265,24 +127,12 @@ This will open the following page in a web browser:
265127

266128
![Basic Information page](/img/bolt-python/basic-information-page.png "Basic Information page")
267129

268-
</TabItem>
269-
<TabItem value="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-
![Basic Information page](/img/bolt-python/basic-information-page.png "Basic Information page")
276-
277-
</TabItem>
278-
</Tabs>
279-
280130
On these pages you're free to make changes such as updating your app icon, configuring app features, and perhaps even distributing your app!
281131

282132
## Next steps {#next-steps}
283133

284134
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:
285135

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.
287137
- Check out the [Agent quickstart](/ai/agent-quickstart) to get up and running with an agent.
288138
- Browse our [curated catalog of samples](/samples) for more apps to use as a starting point for development.

0 commit comments

Comments
 (0)