Skip to content

Commit 5570219

Browse files
author
Rodney Urquhart
committed
Adding last step to tutorial
1 parent 6b576cf commit 5570219

4 files changed

Lines changed: 33 additions & 7 deletions

File tree

tutorial/01-creating-the-slack-app.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# 01 - Create a Slack app
2-
3-
## Slack Apps
1+
# Create a Slack app
42
> 💡 Build useful apps, internal tools, simplified workflows, or brillant bots for just your team or Slack's millions of users.
53
64
- To get started, create a new Slack App on [api.slack.com](https://api.slack.com/apps?new_app=1).

tutorial/02-building-a-message.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Building a message
2-
The code for this step is also available [here](/tutorial/PythOnBoardingBot/onboarding_tutorial.py).
2+
The code for this step is available [here](/tutorial/PythOnBoardingBot/onboarding_tutorial.py).
33

44
> 💡 **[Block Kit](https://api.slack.com/block-kit)** is a new UI framework that offers you more control and flexibility when building messages for Slack. Comprised of "blocks," stackable bits of message UI, you can customize the order and appearance of information delivered by your app in Slack. Using the **[Block Kit Builder](https://api.slack.com/tools/block-kit-builder)** you can shuffle and stack blocks to quickly prototype app messages on Slack. When you're ready, we'll provide the message payload so all you have to do is copy and paste it into your app's code.
55

tutorial/03-responding-to-slack-events.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The code for this step is also available [here](/tutorial/PythOnBoardingBot).
1010
slackclient>=2.0.0
1111
certifi
1212
```
13-
> 💡 Certifi is a carefully curated collection of Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts. It has been extracted from the Requests project.
13+
> 💡 **[Certifi](https://github.com/certifi/python-certifi)** is a carefully curated collection of Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts. It has been extracted from the Requests project.
1414
1515
- Next you can install those dependencies by running the following command from your terminal:
1616
```
@@ -62,7 +62,7 @@ def start_onboarding(web_client: slack.WebClient, user_id: str, channel: str):
6262
onboarding_tutorials_sent[channel] = {}
6363
onboarding_tutorials_sent[channel][user_id] = onboarding_tutorial
6464
```
65-
*Note:* We're using the `WebClient` to send messages into Slack.
65+
**Note:** We're using the `WebClient` to send messages into Slack.
6666
> 💡 **[WebClient](/slack/web/client.py)** A WebClient allows apps to communicate with the Slack Platform's Web API. This client handles constructing and sending HTTP requests to Slack as well as parsing any responses received into a `SlackResponse` dictionary-like object.
6767
6868
### Responding to events in Slack
@@ -177,10 +177,12 @@ Finally, we need to make our app runnable.
177177
- 🏁 Add the following lines of code to the end of `app.py`.
178178
```Python
179179
if __name__ == "__main__":
180+
ssl_context = ssl_lib.create_default_context(cafile=certifi.where())
180181
slack_token = os.environ["SLACK_BOT_TOKEN"]
181-
rtm_client = slack.RTMClient(slack_token)
182+
rtm_client = slack.RTMClient(token=slack_token, ssl=ssl_context)
182183
rtm_client.start()
183184
```
185+
**Note:** When running in a virtual environment you often need to specify the location of the SSL Certificate(`cacert.pem`). To make this easy we use Certifi's built-in `where()` function to locate the installed certificate authority (CA) bundle.
184186

185187
---
186188

tutorial/04-running-the-app.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Running your app
2+
### Set App Credentials
3+
Before you can run your app you need to put your bot token into the environment.
4+
5+
**Note:** This is the same token you copied at the end of [Step 1](/tutorial/01-creating-the-slack-app.md#add-a-bot-user).
6+
<img width="786" alt="Copy the Bot token" src="https://user-images.githubusercontent.com/3329665/56845230-ec357e80-6872-11e9-83d4-5f953aee20b5.png">
7+
8+
- Add this token to your environment variables:
9+
```
10+
$ export SLACK_BOT_TOKEN='xoxb-XXXXXXXXXXXX-xxxxxxxxxxxx-XXXXXXXXXXXXXXXXXXXXXXXX'
11+
```
12+
13+
- 🏁Run your app
14+
```
15+
$ python3 app.py
16+
-> The Websocket connection has been opened.
17+
```
18+
19+
### Demo time!
20+
🎉 That's it. Congradulations! You've just built a Slack app. 🤖
21+
![Onboarding](https://user-images.githubusercontent.com/3329665/56870674-ab02b300-69c7-11e9-9101-eb823235f3c2.gif)
22+
---
23+
24+
**Previous section: - [03 - Responding to Slack events](/tutorial/03-responding-to-slack-events.md).**
25+
26+
**Back to the [Table of contents](/tutorial/#table-of-contents).**

0 commit comments

Comments
 (0)