Skip to content

Slack

By connecting a DialoX bot to Slack, it is possible to have conversations between Slack users and your bot. To do this, you need to connect the bot to a Slack workspace that you own. As soon as that is set up, the bot will handle the messages that are sent to it.

Installation

When clicking the "Add Slack" button in the studio, a manifest file is presented which you can copy-paste into the Slack app creation process to make the setup easier. Use this manifest to create a new Slack App. Don't forget to add the new app to your workspace.

After having done that, fill in the App ID, Client ID, Client Secret and Signing Secret, which can be found on the Basic Information page:

Then, copy the Bot User OAuth token which can be found on the OAuth and Permissions page:

Now click 'save' to create the Slack channel on DialoX. You can now start chatting with the bot on Slack and it will start running your bot's code.

Conversations and users

When the bot is added to a slack channel, the channel itself will be the "user" that the bot sees. Therefore, the bot reacts to all messages that any user in that channel sends.

When replying to a message in a thread, the bot treats the thread as a new conversation, but for the same "user" (e.g. the channel).

Slash commands

Incoming slash commands are treated as incoming events. The name of the event is $slack_command, and the event.payload contains an object with the following keys:

  • command — the command name including the slash, e.g. "/joke"
  • text — the text that was typed after the command
  • user_name — the name of the user that typed the command
  • user_id — the id of the user that typed the command

For instance:

dialog event: "$slack_command" when event.payload.command == "/joke" do
  say event.payload.user_name + " requested a joke."
  pause 3
  say "The joke is about " + event.payload.text
end