25 Slack bot setup
Chris Bobbe edited this page 2021-05-24 17:04:11 -04:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

A Matterbridge integration for your Slack Workspace

Contents

Bot-based Setup
Legacy Setup
Issues


Bot-based Setup

Slacks model for bot users and other third-party integrations revolves around Slack Apps. They have been around for a while and are the only and default way of integrating services like Matterbridge going forward.

Slack Docs: Bot user tokens

Create the classic Slack App

Its important that you create a “Slack App (Classic)”. Dont use the “Create New App” button, and dont opt in to the “granular permissions” feature.

  1. Navigate to Slacks “Your Apps” page and log into an account that has administrative permissions over the Slack Workspace (server) that you want to sync with Matterbridge.

    Slack's 'Your Apps' page

  2. Use THIS LINK to create a “Slack App (Classic)”. Choose any name for your app and select the desired workspace, and then submit. ⚠️ USE THE LINK AND DONT CLICK THE “Create New App” BUTTON.

    Create a 'Slack App (Classic)'

  3. Navigate to the “App Home” page via the menu on the left. Click “Add Legacy Bot User”, fill in the bots details, and submit.

    Add Legacy Bot User

Grant scopes and install the Slack App

Youll need to give your new Slack App (Classic), and thus the bot, the right permissions on your Slack Workspace.

  1. Click “OAuth & Permissions” in the menu on the left, and scroll down to the “Scopes” section. Dont click the prominent “Update Scopes” button. Instead, click “Add an OAuth Scope”.

    Add an OAuth Scope

  2. Add the following permission scopes to your app:

    • Modify your public channels (channels:write)
    • Send messages as <App name> (chat:write:bot)
    • Send messages as user (chat:write:user)
    • Access users profile and workspace profile fields (users.profile:read)

    App with scopes

  3. Scroll to the top of the same “OAuth & Permissions” page and click on the “Install to Workspace” (or “Reinstall to Workspace”) button:

    Install to Workspace

Confirm that the authorizations you just added are OK:

Confirm install

  1. Once the App has been installed, the top of the OAuth & Permissions page will show two tokens: a “User OAuth Token” starting with xoxp-... and a “Bot User OAuth Token” starting with xoxb-.... You will need to use the second in your Matterbridge configuration:

    Bot User OAuth Token

Invite the bot to channels synced with Matterbridge

The only thing that remains now is to set up the newly created bot on the Slack Workspace itself.

  1. On your Slack server you need to add the newly created bot to the relevant channels. Simply use the /invite @<botname> command in the chatbox.

    Invite the bot user to a channel

  2. Repeat the invite process for each channel that Matterbridge needs to sync. ⚠️ Also, dont forget to do this in the future when you want to sync more channels.

Now you are all set to go. Just configure and start your Matterbridge instance and see the messages flowing.

Hello from Zulip!

Legacy setup

Update: 2020-04-03 - this setup is not working anymore. (See https://github.com/42wim/matterbridge/issues/964#issuecomment-607629250)

🛑 This setup is not recommended and will disappear in future versions of Matterbridge. Please use it only if you are absolutely sure that you can not use the normal setup. Legacy tokens are, as their name indicates, a legacy feature and Slack can in the future deprecate them at short notice as they have a weak security model and give access to a wide-range of privileged actions. Always store your token securely!

Slack Docs: Legacy tokens


In order to use this setup your channel configuration should use the slack-legacy setup instead of slack:

[slack-legacy]
[slack-legacy.myslack]
Token="xoxp-123456789-mytoken"

Steps to follow: 1. First create a dedicated user (a new account specifically for the bot) in Slack.

  1. Next log in as this user and go to the legacy tokens page and click “Create token” for your team and your new user. Create token screen The token will look something like xoxp-123456789-LowerAndUPpercase.

  2. Use the obtained token in your configuration file for the channel setup as in the example above.

Issues

If you get the message: ERROR slack: Connection failed "not_allowed_token_type" &errors.errorString{s:"not_allowed_token_type"}

For more information look at https://github.com/slackapi/node-slack-sdk/issues/921#issuecomment-570662540 and https://github.com/nlopes/slack/issues/654 and our issue https://github.com/42wim/matterbridge/issues/964