Deploying your Watson Assistant to Slack
See [[Creating a Watson Chatbot with Discovery]], [[Integrating Discovery and Assistant]], and the [[Main AI Page]].
Also see [[Deploying your Watson Assistant to Facebook Messenger]]
The instructions for adding an already-built Watson Assistant to Facebook Messenger are available on the Coursera Website.
The assistant has been deployed to the Bot Personhood Initiative Slack channel.
Lab 7: Deploying to Slack (1h)
Objective for Exercise:
- How to integrate the basic chatbot with Slack.
Deploying Your Chatbot On Slack
Slack is a communication tool, typically used by people working in a team. It can also be a channel for you to connect with friends, family or anyone that you want to share information with. You can improve the workflow in your team or set reminders of important events with your friends and family by deploying chatbots on Slack.
For this lab you will integrate our chatbot with Slack.
CREATE A SLACK APP
-
Head over to Slack.com, click on the Try Slack button, then click on Create a Slack Workspace.
-
Next, enter your email address and click on the Confirm button. You might be asked to enter a confirmation code that will be sent to the email address you specified.
-
Specify a team and project name of choice. Feel free to skip inviting teammates.
-
Now that we have a Slack workspace and channel, we need to proceed to create a Slack App to use to communicate with our existing chatbot.
-
Check your email to find the URL of your slack as shown in the figure below.
-
Sign into your slack workspace with the following link: https://slack.com/signin?redir=/api/apps. Enter your URL (minus the .slack.com part) and click Continue.
-
Once you are signed in, click on Create an App.
-
Give your app a name and specify the workspace that you want to deploy this app on. Then click on Create App.
ADD PERMISSIONS
Now that we have a Slack App (e.g., Slack Chatbot Demo), we need to ensure that the chatbot will have the right permission.
-
Click on App Home in the sidebar and then scroll to the Scopes section. Click on Review Scopes to Add.
-
Scroll to scopes section. You'll want to click on Add OAuth Scope button under Bot Token Scopes as shown in figure.
-
Select app_mentions:read. The new scope will be added as shown in the figure below. This permission enables the bot to detect mentions from Slack users.
-
Repeat the process of clicking on Add an OAuth Scope under Bot Token Scopes, to add the following permissions: chat:write, im:history, and im:read. Once you are done, the list will be shown as seen in the image below.
-
Click on Basic Information in the left sidebar. Then copy and make note of your Verification Token. We'll need this information when integrating Slack within Watson Assistant.
-
Now we need to install our Slack app within our workspace. Click on OAuth & Permissions in the left sidebar, then click on Install App to Workspace.
-
Click on Allow when asked to confirm your authorization.
-
Copy and make note of the Bot User OAuth Access Token that will be provided to you.
INTEGRATE SLACK WITHIN WATSON ASSISTANT
Now that we have the Verification Token, and Bot User OAuth Access Token for our Slack app, we can proceed to add a Watson Assistant integration for Slack.
-
From the Student Advisor Chatbot assistant within Watson Assistant, click on Add integration - much like we did in the previous lab - but this time select Slack.
-
Scroll to Step 2 on the page, and paste your Verification Token in the Verification token input field.
-
Paste your Bot User OAuth Access Token (that you made note of, earlier) in both the OAuth access token and Bot user OAuth access token input fields.
-
Scroll to Step 3 on the page, and click on the Generate request URL button.
-
This will generate a URL that we'll need to provide to Slack. (You may need to scroll back to Step 3 if the page refreshed.) Copy and make note of the Generated request URL.
-
Go back to the page for your Slack App. If you closed it, you can find it at the following URL https://api.slack.com/apps. In the left sidebar, under the Features section click on Incoming Webhooks. Turn Activate Incoming Webhooks on. In the warning message that appears, click on reinstall your app.
-
You'll be asked to specify a channel (e.g., # watson-assistant-chatbot-demo). Select the one that was generated for you earlier on when you specified the project name.
-
Now click on Event Subscriptions in the sidebar and switch on Enable Events. Then paste the request URL you saved from Watson Assistant.
-
Next, click on Subscribe to bot events, as shown by the arrow in the figure below.
-
This will open the section that will allow you to subscribe to specific events.
-
Click on Add Bot User Event and select the event type message.im. Then repeat the process to add app_mention. This will enable both direct messages and mentions to trigger a response from the chatbot.
-
Then click on Save Changes.
(If the Save Changes is disabled/grey, please paste the Request URL again so that Slack can validate the URL and turn the Save Changes button to enabled/green.)
You're done! Your bot will now be available within your Slack workspace. Any direct message or mention will be sent in input to your Watson Assistant chatbot, and its response provided back to the user in Slack.
The chatbot will also respond to mentions in channels, provided you invite it to the given channel, after mentioning it as shown in the image below.
Author(s)
- public document at doc.anagora.org/deploying-your-watson-assistant-to-slack
- video call at meet.jit.si/deploying-your-watson-assistant-to-slack
(none)
(none)