I have deployed the bot to an ec2 nano instance. You can test it directly without any additional setup
-
Sign into
topbot-workspace.slack.com
usingdmessinger@topcoder.com
. This user has already been invited to the workspace. -
You will need another user for testing. Invite another user by clicking the
Invite people
button. Sign intotopbot-workspace.slack.com
with that user on a different browser. Let's call this usertestuser@topcoder.com
. Now go back todmessinger@topcoder.com
account. -
By default, all launched task messages are posted to
#tasks
-
Create a new channel for testing, say
#test
-
Invite the bot,
/invite @topbot
. You will see a welcome message in#test
. The bot is also automatically added to the#tasks
channel if it is not already a member. You will see a welcome message on#tasks
if it is a fresh add. This is to notify all members of#tasks
who are not a part of#test
that a bot is availabe. -
Issue
help
command,@topbot help
. You will see a list of commands supported by the bot. -
Launch a task.
@topbot launch Horizon - Create New Project Mock API Integration - Part 2
. You will see a message posted in#tasks
-
Accept this task as
testuser@topcoder.com
by clicking theStart a thread
and then reply@topcoder accept
-
A new channel will be created with the name
<first_15_characters of task description>__<taskUUid>
. The uuid is added to avoid conflicts incase two tasks have similar descriptions. Slack limits channel names to 21 characters.
The channel will have two users, dmessinger@topcoder.com
and testuser@topcoder.com
. The bot will also automatically be added.
-
As
dmessinger@topcoder.com
, approve the task inside the newly created channel.@topbot approve
. You will see a confirmation message.
There are several error scenarios which the bot handles. These are,
launch
task with no description
-
accept
command in a non thread. -
accept
a task which is already accepted. -
accept
in a thread but not for a launched task. -
accept
a task launched by the same user -
approve
in a channel which is not the one created for a task. -
approve
task as a user who did not launch the task -
approve
task which is already approved as a launcher
-
Node.js v10.14.2 or higher. Download link: https://nodejs.org/en/download/
-
ngrok. Download link: https://ngrok.com/download
-
Slack account
-
Mongodb community edition. Download link: https://www.mongodb.com/download-center/community
-
Start ngrok and obtain a https url.
./ngrok http 3000
. -
Make sure you have
/data/db
directory created with write access to current user. Start mongodbmongod
. Create a database, saytopbot
. -
Login to slack and create a channel to post tasks to. Update the name of this channel in
config/default.js -> CHANNEL_TO_POST_TASKS
(make sure to include the '#') -
The instructions here, https://botkit.ai/docs/provisioning/slack-events-api.html are really comprehensive. You can follow steps 1 to 6 and ignore step 2. The only change is, in step 3 (Configure OAuth), make sure to add the
channels.write
scope and clickSave changes
.
- Before step 7, go to the
Basic information
tab of your app. Collect these values fromApp credentials
section,Client id
,Client secret
,Signing Secret
.
-
Update
.env
file with the information from above steps. -
Start your node app.
npm i
followed bynpm start
. -
Now follow step 7. i.e open the ngrok url on a browser.
-
On the home page of the
ngrok
url, clickAdd to Slack
.
- Click
Authorize
on the next page.
- You will recieve a bot added message.
- IMPORTANT Before proceeding further, go to the
OAuth and permissions
page of you bot. (From step 3, Configure OAuth). You will see a banner saying permissions have changed. Reinstall the app by clickingclick here
. Authorize on the following page.
- Now you can follow the same steps as in "Testing directly on Slack".
Configuration is defined in config/default.js
. The comments there explain each field.
You need to get team and channel id where you want to send your requests and paste them in "TEAM_TO_POST" and "CHANNEL_TO_POST" config variables
Run npm run lint
-
Signing Secret
is very important for security. So make sure to update that field too in the.env
file if not already. It is used to verify that the incoming messages from slack to the bot are indeed from slack and not from an attacker. This check happens in,component/routes/incoming_webhooks.js
-
Logs are written to files,
combined.log
for all logs anderror.log
for errors by winston. -
Tasks are created in the
tasks
collection in MongoDB. -
npm audit
shows one vulnerability. Installing the fix is a major dependency update which might break features of botkit as it was a dependency that was installed by botkit. So I have not updated it.