Skip to content

Slack connector

The Slack connector connects a bot to Slack: the bot receives the messages of a Slack channel through the Slack Events API, and answers with an incoming webhook.

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 Settings > 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 Settings > Configurations page. On the line corresponding to your Slack connector, it is the Relative REST path field

  • In Subscribe to bot events, add the message.channels event to use the bot on a Slack channel.

    Other "message" events are also available: message.im for direct messages, message.groups for private channels, 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

Install the bot (and talk to it)

  • In your Slack app page, go to OAuth & Permissions and add, in Bot Token Scopes, the scopes required by the events you subscribed to: channels:history for message.channels, im:history for message.im, groups:history for message.groups

  • Go to Install App and install (or reinstall) the app in the workspace

  • In Slack, add the bot to the channel (for instance with /invite @<bot name>)

  • 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 sentences and Sentences 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

Going further

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
×