Skip to content

Commit b421bf3

Browse files
Joel GerberJoel Gerber
authored andcommitted
First stab at documenting Slack integration procedure
1 parent 6e78e06 commit b421bf3

1 file changed

Lines changed: 99 additions & 0 deletions

File tree

README.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,105 @@ poetry run flake8
6868
poetry run isort -rc .
6969
```
7070

71+
## How to Test Integration With Slack
72+
73+
After having developed some new feature, or having in hand what you believe is
74+
a fix for an existing bug, how do you test it out in a real system in order to
75+
make sure that your changes do all that you hope they do? The answer; bring up
76+
the application in your own environment and hook it up to Slack!
77+
78+
In order to do this, there are 6 main things you need to accomplish:
79+
80+
1. Setup your own Slack workspace.
81+
2. Grab a signing secret from Slack that pybot can utilize.
82+
3. Launch pybot locally, passing it your Slack signing secret.
83+
4. Attach your pybot instance to the public internet so that Slack can speak
84+
with it.
85+
5. Point Slack at your running pybot instance, and properly configure it.
86+
6. Relish in your success!
87+
88+
The following sections will guide you through each of these stages.
89+
90+
### 1 - Setup Your Own Slack Workspace
91+
92+
To start, you'll want to visit Slack's [Getting
93+
Started](https://slack.com/get-started) page. From this page, choose the option
94+
to create a new workspace. It will request that you enter in an email address,
95+
feel free to enter in an email address that you have access to and continue
96+
through the process. It will email you a 6 digit code, check your email for
97+
this code and then input it into Slack to continue the process. Enter in the
98+
name of the workspace that you're going to play around with the pybot in. When
99+
it asks for a project you're working on, put in whatever you want. Maybe pybot
100+
would be a good choice? It will ask you to input other team members that you'd
101+
like to join in. Feel free to put in other emails here, or just skip this step
102+
altogether. Then, it gives you an option to login to your new workspace. Go
103+
ahead and do that!
104+
105+
With your new workspace created, you'll see that it has created a channel for
106+
the project name you entered. Congratulations, you've completed the first stage!
107+
108+
### 2 - Create a pybot App in Your Slack Workspace
109+
110+
While logged in to your Slack workspace, click on the drop-down menu in the top
111+
left corner, find the administration menu and then select _Manage Apps_. Once
112+
here, to the top right, find the build option and select it. It will bring you
113+
to the Slack API page. Click on the _Start Building_ option. From here, it will
114+
prompt you to enter in an application name and to attach it to a workspace. Go
115+
ahead and name your new pybot bot and attach it to your newly created workspace.
116+
Then click _Create App_ to do the deed. It will bring you to a new page. On this
117+
page, find the app credentials section, and from here, copy out your app's new
118+
signing secret. This is what you'll configure pybot with so that it can
119+
authenticate inbound requests.
120+
121+
Next, near the top of the screen select Add features and functionality and
122+
then chose _Bots_. Click on the _Add a Bot User_ button, add in a display name,
123+
enable _Always Show My Bot as Online_ and then select _Add Bot User_. Then, to
124+
the left, under Settings, choose _Install App_ and then click on _Install App to
125+
Workspace_, click _Allow- and then copy off the bot user OAuth access token for
126+
later. You'll also be configuring pybot with this so that it can authenticate
127+
itself with Slack.
128+
129+
### 3 - Launch pybot Locally, Passing in Your Signing Secret
130+
131+
Either configure a pybot.env file in the root of this repository, or set an
132+
exported variable in your shell environment. Here's the required parameters
133+
shown as being configured in pybot.env (these also can be set as environment
134+
variables in your shell of choice instead.)
135+
136+
Example _pybot.env_:
137+
138+
```text
139+
SLACK_BOT_SIGNING_SECRET=SUPER-SECRET-SIGNING-SECRET-HERE
140+
BOT_OAUTH_TOKEN=BOT-USER-OAUTH-ACCESS-TOKEN-HERE
141+
SLACK_BOT_USER_ID=BOT-DISPLAY-NAME
142+
```
143+
144+
### 4 - Attach Your pybot Instance to the Public Internet
145+
146+
You can easily utilize serveo to publish your pybot instance to the public
147+
internet. Just run the following command from your UNIX like workstation to
148+
setup an SSH port tunnel to serveo:
149+
150+
```bash
151+
ssh -R 80:localhost:5000 serveo.net
152+
```
153+
154+
Pay attention to copy out the response you get and keep this command running.
155+
Here's an example output from the command:
156+
157+
```text
158+
Forwarding HTTP traffic from https://supersecret.serveo.net
159+
Press g to start a GUI session and ctrl-c to quit.
160+
```
161+
162+
### 5 - Point Slack at Your Running pybot Instance
163+
164+
From the Slack API interface that you used to create your bot, under Features
165+
on the left, select _Event Subscriptions_, slide it to on, paste in your serveo
166+
Base-URI followed by _/pybot/api/v1/slack/verify_ (IE:
167+
_https://cool.serveo.net/pybot/api/v1/slack/verify_) and then save your changes.
168+
169+
Everything should now be done!
71170

72171
## License
73172
This package is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

0 commit comments

Comments
 (0)