Skip to content

Configure your bot for Slack

If you followed the guide Create your first bot with Tock Studio, you have declared a Slack-type connector but it is not yet configured so that the bot actually speaks on Slack.

With a little configuration on the Slack and Tock sides, a bot can receive messages and respond on this channel.

If you wish, you can also skip this step and configure a Messenger channel or go directly to the rest.

What you'll create

  • A setup (in Slack and Tock) to receive and send Slack messages

  • A bot that talks in a Slack channel

Prerequisites

  • About 15 minutes

  • A working Tock bot (e.g. following the first Tock bot guide)

  • A Slack account and a workspace / channel to integrate the bot into

If you're new to Slack, head over to https://slack.com/

Create an app in Slack

  • Go to the Create a Slack app page

  • Enter a name for the app

  • Select a workspace

  • Finish with Create App

Enable sending messages to Slack

  • Open Incoming Webhooks and check Activate Incoming Webhooks

  • Click Add New Webhook to Workspace

  • Select a channel or a person for the conversation with the bot

  • Finish with Install

  • Copy the Webhook URL that was just created

The Webhook URL looks something like this in its format:

https://hooks.slack.com/services/{workspaceToken}/{webhookToken}/{authToken}

  • In Tock Studio go to Configuration > Bot Configurations

  • Find your Slack connector type (or create a new one if needed) and open the Connector Custom Configuration section

  • Enter the tokens from the previously copied address in the three tokens fields:

  • Token 1: the first token of the WebhookURL, or workspaceToken

  • Token 2: the second token of the WebhookURL, or webhookToken

  • Token 3: the last token of the WebhookURL, or authToken

  • Finish with Update

Warning: if you reinstall the Slack application in the workspace, the URL and tokens are changed and must be reported in the configuration on the Tock side.

Enable receiving messages from Slack

  • In your Slack application page, go to Event Subscriptions and enable Enable Events

  • Enter in the Request URL field the full address of your Slack connector in Tock.

On the Tock demo platform, this address will be like https://demo.tock.ai/{relative_path_to_the_slack_connector}

The relative path to the connector is indicated in the Bot Configurations page. On the line corresponding to your Slack connector, it is the Relative REST path field

  • Open Add Workspace Event and select the message.channels event to use the bot on a Slack channel.

    Other "message" events are also available: message.im for private messages, message.groups, etc. See the Slack documentation.

  • Validate with Save Changes

  • Go to Interactive Components and enable Interactivity

  • Enter the same Request URL as before

  • Validate with Save Changes

Create a Slack bot (and talk to it)

  • In your Slack app page, go to Bot Users and do Add a Bot User

  • Choose a name / identifier for the bot in Slack

  • Validate with Add Bot User

  • Go to Install App and Reinstall App

  • Select the Slack channel then Install

  • In Slack, go to the channel and add the bot to the channel

  • Talk to the bot (e.g. "hello"). It now answers you in Slack!

Watch the conversation in Tock Studio (optional)

Regardless of the channels used to converse with the bot, you can follow the conversations directly in all Tock Studio screens, for example: Language Understanding > Inbox and Logs, or any view in the Analytics menu:

  • In Tock, open Analytics > Users and click on the Display dialog icon to see the entire conversation coming from Slack

Congratulations!

You have now configured your bot to also talk on Slack.

As you can see, connecting a Tock bot to one (or more) external channels is just a matter of configuration. You can build the conversational model, features, and personality of your assistant independently of the channels you want to talk to it on, today or in the future.

Continue...

In the following sections you will learn how to:

To learn more about the Slack connector provided with Tock, go to the connector-slack folder on GitHub, where you will find the sources and the README of the connector.

Chat with Tock
×