Skip to content

Commit 4d6e3f7

Browse files
Docs: Move Modals tutorial to Bolt for Python site. (#1250)
1 parent 2d02f08 commit 4d6e3f7

File tree

7 files changed

+102
-1
lines changed

7 files changed

+102
-1
lines changed

docs/content/tutorial/modals.md

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# Modals
2+
3+
If you're learning about Slack apps, modals, or slash commands for the first time, you've come to the right place! In this tutorial, we'll take a look at setting up your very own server using Glitch, and using that server to run your Slack app.
4+
5+
Let's take a look at the technologies we'll use in this tutorial:
6+
7+
* Glitch is a online IDE that allows you to collaboratively work on code and host your own server. Glitch should only be used for development purposes and should not be used in production.
8+
* We'll use Python in conjunction with our [Bolt for Python](https://github.com/SlackAPI/bolt-python) SDK.
9+
* [Block Kit](https://api.slack.com/block-kit/building) is a UI framework for Slack apps that allows you to create beautiful, interactive messages within Slack. If you've ever seen a message in Slack with buttons or a select menu, that's Block Kit.
10+
* Modals are similar to a pop-up window that displays right in Slack. They grab the attention of the user, and are normally used to prompt users to provide some kind of information or input.
11+
12+
---
13+
14+
## Final product overview {#final_product}
15+
If you follow through with the extra credit tasks, your final app will look like this:
16+
17+
![Final product](/img/modals/final_product.gif)
18+
19+
---
20+
21+
## The process {#steps}
22+
23+
1. [Create a new app](https://api.slack.com/apps/new) and name it whatever you like.
24+
25+
2. [Remix (or clone)](https://glitch.com/edit/#!/remix/intro-to-modals-bolt) the Glitch template.
26+
27+
Here's a copy of what the modal payload looks like — this is what powers the modal.
28+
29+
```json
30+
{
31+
"type": "modal",
32+
"callback_id": "gratitude-modal",
33+
"title": {
34+
"type": "plain_text",
35+
"text": "Gratitude Box",
36+
"emoji": true
37+
},
38+
"submit": {
39+
"type": "plain_text",
40+
"text": "Submit",
41+
"emoji": true
42+
},
43+
"close": {
44+
"type": "plain_text",
45+
"text": "Cancel",
46+
"emoji": true
47+
},
48+
"blocks": [
49+
{
50+
"type": "input",
51+
"block_id": "my_block",
52+
"element": {
53+
"type": "plain_text_input",
54+
"action_id": "my_action"
55+
},
56+
"label": {
57+
"type": "plain_text",
58+
"text": "Say something nice!",
59+
"emoji": true
60+
}
61+
}
62+
]
63+
}
64+
```
65+
66+
3. Find the base path to your server by clicking **Share**, then copy the Live site link.
67+
68+
![Get the base link](/img/modals/base_link.gif)
69+
70+
4. On your app page, navigate to **Interactivity & Shortcuts**. Append "/slack/events" to your base path URL and enter it into the **Request URL** e.g., `https://festive-harmonious-march.glitch.me/slack/events`. This allows your server to retrieve information from the modal. You can see the code for this within the Glitch project.
71+
72+
![Interactivity URL](/img/modals/interactivity_url.png)
73+
74+
5. Create the slash command so you can access it within Slack. Navigate to the **Slash Commands** section and create a new command. Note the **Request URL** is the same link as above, e.g. `https://festive-harmonious-march.glitch.me/slack/events` . The code that powers the slash command and opens a modal can be found within the Glitch project.
75+
76+
![Slash command details](/img/modals/slash_command.png)
77+
78+
6. Select **Install App**. After you've done this, you'll see a **Bot User OAuth Access Token**, copy this.
79+
80+
7. Navigate to your Glitch project and click the `.env` file where the credentials are stored, and paste your bot token where the `SLACK_BOT_TOKEN` variable is shown. This allows your server to send authenticated requests to the Slack API. You'll also need to head to your app's settings page under **Basic Information** and copy the _Signing secret_ to place into the `SLACK_SIGNING_SECRET` variable.
81+
82+
![Environment variables](/img/modals/heart_icon.gif)
83+
84+
8. Test by heading to Slack and typing `/thankyou`.
85+
86+
All done! 🎉 You've created your first slash command using Block Kit and modals! The world is your oyster; you can create more complex modals by playing around with [Block Kit Builder](https://app.slack.com/block-kit-builder).
87+
88+
### Extra credit {#extra_credit}
89+
90+
For a little extra credit, let's post the feedback we received in a channel.
91+
92+
1. Add the `chat:write` bot scope, which allows your bot to post messages within Slack. You can do this in the **OAuth & Permissions** section for your Slack app.
93+
2. Reinstall your app to apply the scope.
94+
3. Create a channel and name it `#thanks`. Get its ID by right clicking the channel name, copying the link, and copying the last part starting with the letter `C`. For example, if your channel link looks like this: https://my.slack.com/archives/C123FCN2MLM, the ID is `C123FCN2MLM`.
95+
4. Add your bot to the channel by typing the command `/invite @your_bots_name`.
96+
5. Uncomment the `Extra Credit` code within your Glitch project and make sure to replace `your_channel_id` with the ID above.
97+
6. Test it out by typing `/thankyou`, and watching all the feedback come into your channel!
98+
99+
## Next steps {#next-steps}
100+
101+
If you want to learn more about Bolt for Python, refer to the [Getting Started guide](/bolt-python/getting-started).

docs/sidebars.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ const sidebars = {
8686
{
8787
type: "category",
8888
label: "Tutorials",
89-
items: ["tutorial/ai-chatbot", "tutorial/custom-steps-for-jira"],
89+
items: ["tutorial/ai-chatbot", "tutorial/custom-steps-for-jira", "tutorial/modals"],
9090
},
9191
{ type: "html", value: "<hr>" },
9292
{
411 KB
Loading
398 KB
Loading
143 KB
Loading
186 KB
Loading
46.2 KB
Loading

0 commit comments

Comments
 (0)