Dialogflow's Slack Integration makes it easy to create your own Slack apps and bots and train them to understand natural language.
Setting Up Slack
In order to set up the Slack integration for your agent, you'll need the following:
- a Slack account
- a Slack Team
Create a Slack App
- Navigate to the Slack Developer Console
- Enter a name for your app
- Choose a Team you would like the app associated with
- Click the Create App button
Add a Bot User
- Click on Bot Users in the left hand menu
- Click the Add a Bot User button
- Enter a name for your Slack bot (this is what users will see they add your bot)
- Enable Always Show My Bot as Online
- Click the Add Bot User button
Enabling Integration in Dialogflow
In the Slack Developer Console, click on Basic Information in the left hand menu and scroll down to the App Credentials section. Make note of the Client ID, Client Secret, and Verification Token.
Link Slack to Dialogflow
- In Dialogflow, go to Integrations in the left hand menu
- Click on the Slack tile
- Enter the related values into the following fields:
- Client ID
- Client Secret
- Verification Token
- Click Start
Continuing Slack Setup
Now that you've set up Slack and Dialogflow, you'll enable OAuth, Event Requests URLs (provided by Dialogflow) and Event Subscriptions.
Add OAuth URL
- Copy the OAuth URL from Dialogflow's Slack setting page
- Go to the Slack Developer Console and click on OAuth & Permissions in the left hand menu
- Click on the Add a new Redirect URL button and paste the OAuth URL
- Click Add
Add Event Request URL
- Copy the Event Request URL from Dialogflow's Slack setting page
- Go to the Slack Developer Console and click on Event Subscriptions in the left menu
- Click on the switch to enable Events, and paste the Event Subscription URL in
to Request URL field
After a few moments you should see a green "Verified" above the Request URL field.
- Once you're done updating these two settings, click the Save Changes button at the bottom of the page.
Enable Event Subscriptions
- Click on Event Subscriptions in the left menu
- Click the switch to enable the option
Under the Subscribe to Bot Events , click on the Add Bot User Event button
This will reveal text field and list of events. You can enter terms into this field to search for events you want your bot to respond to. Here's a list of events we suggest adding:
Event Name Event Description message.im A message was posted in a direct message channel message.groups A message was posted to a private channel message.channels A message was posted to a channel im\_created A DM was created
Once you've added the events, click the Save Changes button at the bottom of the screen
Add Your Slack Bot to a Team
- In the Slack Developer Console, click on Manage Distribution in the left menu
- Under the Share Your App with Your Team section, click the Add to Slack button
- On the next page, click the Authorize button to add the agent
You can test your agent without creating a public Slack bot. To do so, go to the Integrations page for your agent and click the switch on the Slack tile. In the pop-up window, click the Test In Slack button.
You'll be prompted to log in to Slack. Once logged in, navigate to the instance and locate the bot user called @dialogflow-bot. You can direct message the agent to test it or add it to channels in your instance.