Dialogflow's Slack Integration makes it easy to create your own Slack apps and bots and train them to understand natural language.
Limitations
Only the default agent language is supported by this integration.
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 Appbutton
Add a Bot User
- Click on OAuth & Permissionsin the left hand menu
- Go to Scopessection and make sure the following OAuth Scopes are in the
Bot Token Scopes section
- Click on App Homein the left hand menu
- Enable Always Show My Bot as Onlineand edit App Display Nameif needed (this is what users will see for your bot)
Enabling Integration in Dialogflow
In the Slack Developer Console, click on Basic Informationin the left hand menu and scroll down to the App Credentialssection. Make note of the Client ID, Client Secret, and Verification Token.
Link Slack to Dialogflow
- In Dialogflow, go to Integrationsin the left hand menu
- Click on the Slacktile
- 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 URLfrom Dialogflow's Slack setting page
- Go to the Slack Developer Console and click on OAuth & Permissionsin the left hand menu
- Click on the Add a new Redirect URLbutton and paste the OAuth URL
- Click Add
- Click Save URLsbutton
Add Event Request URL and Enable Event Subscriptions
- Copy the Event Request URLfrom Dialogflow's Slack setting page
- Go to the Slack Developer Console and click on Event Subscriptionsin the left menu
- Click on the switch to enable Events, and paste the Event Subscription URL in
to Request URLfield
After a few moments you should see a green "Verified" above the Request URL field. -
Under the Subscribe to Bot Events, click on the Add Bot User Eventbutton
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. Under the Subscribe to events on behalf of users section, click the Add Workspace Event button to add the im_created event, then press Save Changes . -
Once you're done updating these settings, click the Save Changesbutton at the bottom of the page.
Add Your Slack Bot to a Team
- In the Slack Developer Console, click on Manage Distributionin the left menu
- Under the Share Your App with Your Workplacesection, click the Add to
Slackbutton
- On the next page, click the Authorizebutton to add the agent
Testing
You can test your agent without creating a public Slack bot. To do so, go to the Integrationspage for your agent and click the switch on the Slacktile. In the pop-up window, click the Test In Slackbutton.
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.
Events
The following events are invoked by this integration:
Event | Description |
---|---|
SLACK_WELCOME
|
Triggered when a user starts a conversation with your Slack bot. |
Rich response messages
The following rich response messages are supported.
Image responses
Supported formats and sizes:
- gif
- jpeg
- png
- bmp
Card responses
There are no mandatory fields for cards in Slack – any combination of elements can be used.
Buttons with a URL and with a text postback are supported. Buttons with a URL are displayed as hyperlinks.
Quick reply responses
Quick replies are supported in one-click Slack integrations and correspond to a text version of Slack interactive buttons .
Custom payload responses
Formatted text in one-click Slack integration
Your Slack bots can send formatted text , as the following example shows:
{ "slack" : { "text" : "This is an example of *bold*, _italic_, and `code`." } }