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
{{ message }}
This repository was archived by the owner on May 28, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+10-7Lines changed: 10 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ First you'll want to clone this project locally. This project is structured with
21
21
22
22
At each step, feel free to ask questions in the _#help_ channel, or ask your neighbor if they can help! :raised_hands:
23
23
24
-
To get started, checkout the first branch
24
+
To get started, check out the first branch
25
25
26
26
```bash
27
27
git checkout chapter-1
@@ -30,7 +30,7 @@ git checkout chapter-1
30
30
If you'd like to follow along without any of the code, all of the documentation for each chapter is located in the `docs` folder in the `master` branch.
31
31
32
32
***[Chapter 1: Setting Things Up](docs/Chapter-1.md)**:point_left:
33
-
*[Chapter 2: App.py and OAuth](docs/Chapter-2.md)
33
+
*[Chapter 2: OMG OAuth](docs/Chapter-2.md)
34
34
*[Chapter 3: Handle Hello with Class](docs/Chapter-3.md)
@@ -41,15 +41,16 @@ If you'd like to follow along without any of the code, all of the documentation
41
41
42
42
##### Slack Documentation
43
43
44
-
*[Getting started with Slack apps](https://api.slack.com/slack-apps)
45
-
*[Slack Events API documentation](https://api.slack.com/events)
46
-
*[Slack Web API documentation](https://api.slack.com/web)
44
+
*[Getting started with Slack apps](https://api.slack.com/slack-apps?utm_source=events&utm_campaign=build-bot-workshop&utm_medium=workshop)
45
+
*[Slack Events API documentation](https://api.slack.com/events?utm_source=events&utm_campaign=build-bot-workshop&utm_medium=workshop)
46
+
*[Slack Web API documentation](https://api.slack.com/web?utm_source=events&utm_campaign=build-bot-workshop&utm_medium=workshop)
@@ -59,9 +60,9 @@ Wondering what to do if you can't get this dang tutorial to work for you?
59
60
The Slack Developer community is an awesome place to get help when you're confused
60
61
or stuck. We have an excellent 'search first' culture and Slack is committed to
61
62
improving our tutorials and documentation based on your feedback. If you've
62
-
checked the [Slack API documentation](https://api.slack.com/), reached the end
63
+
checked the [Slack API documentation](https://api.slack.com/?utm_source=events&utm_campaign=build-bot-workshop&utm_medium=workshop), reached the end
63
64
of your google patience and found [StackOverflow](http://stackoverflow.com/questions/tagged/slack-api)
64
-
to be unhelpful, try asking for help in the [Slack Developer Hangout](http://dev4slack.xoxco.com/)
65
+
to be unhelpful, try asking for help in the [Bot Developer Hangout](http://dev4slack.xoxco.com/)
65
66
Slack team.
66
67
67
68
### Feedback
@@ -70,3 +71,5 @@ I'd love to improve this project, so if you've got some ideas :bulb:, feedback
70
71
:raising_hand: or praise :love_letter: please file an issue, submit a PR or
71
72
reach out to me through [Github](https://github.com/karishay) or on
If you want to keep up with Slack platform updates chat with us on [Twitter](https://twitter.com/slackapi).
Copy file name to clipboardExpand all lines: docs/Chapter-1.md
+31-14Lines changed: 31 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Chapter 1: Setting Things Up
2
2
3
-
Before we get to the core of bot building, we need to get set up. First, we'll add everything you need for creating a local web server where our bot will live and an https ngrok tunnel so that our bot can connect to Slack. After we've set up our development environment, we'll set up a new Slack App and bot user and then we'll connect Slack to our local environment.
3
+
Before we get to the core of bot building, we need to get set up. First, we'll add everything you need for creating a local web server where our bot will live and an https ngrok tunnel so that our bot can connect to Slack. After we've set up our development environment, we'll set up a new Slack App and bot user and then we'll connect Slack to our local environment. Once our environment is set up, we'll get our Flask application server running.
4
4
5
5
## Setting up Your Development Environment
6
6
@@ -23,11 +23,7 @@ tool to manage a virtual environment
23
23
-**[Ngrok](https://ngrok.com/)**, an easy to use tunneling tool that supports HTTPS,
24
24
which we'll use to connect our app to Slack over _teh interwebz._
25
25
26
-
Once you've installed Python, pip, virtualenv and ngrok you can install all additional
27
-
dependent libraries using pip and the `requirements.txt` file included in this
28
-
project, including [Flask](http://flask.pocoo.org/), a web development micro
29
-
framework for Python and [python-slackclient](http://python-slackclient.readthedocs.io/en/latest/), a
30
-
Slack client for Python. :snake:
26
+
After you’ve installed Python, pip, ngrok and virtualenv you’ll need to generate and activate a new virtualenv. Once your virtualenv is turned on you can install all the additional dependent libraries using pip and the `requirements.txt` file in this project, including [Flask](http://flask.pocoo.org/), a web development microframework for Python, [python-slackclient](http://python-slackclient.readthedocs.io/en/latest/), a Slack client for Python and the [Slack Events Adapter for Python](https://github.com/slackapi/python-slack-events-api). :snake:
31
27
32
28
First, you'll want to create a virtual environment to keep the dependencies for this project isolated from any other project you may be working on. You'll need to open a terminal or command prompt to enter these and the following commands.
Now that we've got our local environment set up we'll need to create a new Slack App. :tada:
57
53
58
-
### Creating a New Slack App on [api.slack.com](https://api.slack.com/apps)
54
+
### Creating a New Slack App on [api.slack.com](https://api.slack.com/apps?utm_source=events&utm_campaign=build-bot-workshop&utm_medium=workshop)
59
55
60
-
In your browser, on [api.slack.com/apps](https://api.slack.com/apps) you'll find
61
-
a green button labeled [Create New App](https://api.slack.com/apps/new) on the
56
+
In your browser, on [api.slack.com/apps](https://api.slack.com/apps?utm_source=events&utm_campaign=build-bot-workshop&utm_medium=workshop) you'll find
57
+
a green button labeled [Create New App](https://api.slack.com/apps/new?utm_source=events&utm_campaign=build-bot-workshop&utm_medium=workshop) on the
@@ -79,16 +75,18 @@ Once you've got your fancy new automaton, we have it subscribe to events in Slac
79
75
80
76
### Subscribe to Events
81
77
82
-
By using Slack's [Events API](https://api.slack.com/events-api) we can ask Slack to send us a JSON payload of information when something particular happens inside of Slack. If we want our bot respond when a user says hello, we can have our bot subscribe to `message.channels` and when a user posts a message, Slack will send the information about the message event to the URL we specify. If the message matches our criteria we can choose to respond to it with an additional step. Unneeded events are discarded.
78
+
By using Slack's [Events API](https://api.slack.com/events-api?utm_source=events&utm_campaign=build-bot-workshop&utm_medium=workshop) we can ask Slack to send us a JSON payload of information when something particular happens inside of Slack. If we want our bot respond when a user says hello to our bot in a DM, we can have our bot subscribe to `message.im` and when a user posts a message, Slack will send the information about the message event to the URL we specify. If the message matches our criteria we can choose to respond to it with an additional step. Unneeded events are discarded.
83
79
84
80
On the left navigation bar of your app's settings page you'll find **Event Subscriptions**.
85
-
To start off right, go ahead and subscribe your bot to `message.channels` events under the **Bot Events** section of the page.
81
+
To start off right, go ahead and subscribe your bot to `message.im` events under the **Bot Events** section of the page.
@@ -120,9 +118,28 @@ set VERIFICATION_TOKEN='xxxXXXxxXXxxX'
120
118
121
119
Our app will grab these secrets from our environment.
122
120
121
+
## Let's Make an [app.py](app.py)
122
+
123
+
In this project directory, you'll find a file called [app.py](app.py). Slack will be delivering events to your application securely, so your application server will need to be able to receive incoming HTTPS traffic. In [app.py](app.py) we'll use the [Slack Events Adapter](https://github.com/slackapi/python-slack-events-api) to create a Flask server to handle all incoming events from Slack. But first, you'll need a web page where people can install your bot onto their teams!
124
+
125
+
When you open [app.py](app.py) you'll see that we've created an instance of _SlackEventAdapter_ called `events_adapter` and added a couple of routes to it's Flask server.
126
+
127
+
To verify that our server is associated with our app, Slack will make a request to the `/slack` endpoint created by the Flask server in our [Slack Events Adapter](https://github.com/slackapi/python-slack-events-api) by sending a `challenge` parameter that it will expect us to return back. The events adapter will handle this verification for us.
128
+
129
+
First, we'll need to add an `/install` route that renders an HTML template where users will eventually be able to install your app. The second route called `/thanks` will return an HTML page to let our users know that our app has been sucessfully installed on their Slack team.
130
+
131
+
Let's fire up our app and test that our Flask server is working properly. With your virtual environment turned on and your secrets exported to the environment, go ahead and start your app:
Check our your shiny app is running locally in a browser by navigating to [localhost:5000/install](http://localhost:5000/install). :boom:
139
+
123
140
## You Did It! :sparkles:
124
141
125
-
You're all set up! Time to checkout the next chapter.
142
+
You're all set up! Time to check out the next chapter and move on to OAuth.
0 commit comments