Errbot SlackV3 backend plugin
Project description
err-backend-slackv3
Slack Events and Real Time Messaging backend for Errbot
Purpose
This backend has been developed to support both the Slack Events and Real Time Messaging APIs using the latest SDK from Slack.
The backend has been made available outside the core errbot project to allow development and user feedback to happen on independent release cycles.
Connection Methods
Slack has been making changes to their OAuth and API architecture that can seem quite confusing.
No matter which OAuth bot token you're using or the API architecture in your environment, slackv3
has got you covered.
The backend will automatically detect which token and architecture you have and start listening for Slack events in the right way:
- Legacy tokens (OAuthv1) with Real Time Messaging (RTM) API
- Current token (OAuthv2) with Event API using the Event Subscriptions and Request URL.
- Current token (Oauthv2) with Event API using the Socket-mode client.
Backend Installation
These instructions are for errbot running inside a Python virtual environment. You will need to adapt these steps to your own errbot instance setup.
The virtual environment is created in /opt/errbot/virtualenv
and errbot initialised in /opt/errbot
. The extra backend directory is in /opt/erbot/backend
.
-
Create the errbot virtual environment
mkdir -p /opt/errbot/backend virtualenv --python=python3 /opt/errbot/virtualenv
or
mkdir -p /opt/errbot/backend python3 -m venv /opt/errbot/virtualenv
-
Install and initialise errbot. See here for details
source /opt/errbot/virtualenv/bin/activate pip install errbot cd /opt/errbot errbot --init
-
Configure the slackv3 backend and extra backend directory. Located in
/opt/errbot/config.py
BACKEND="SlackV3" BOT_EXTRA_BACKEND_DIR="/opt/errbot/backend"
-
Clone
err-backend-slackv3
into the backend directory and install module dependencies.cd /opt/errbot/backend git clone https://github.com/errbotio/err-backend-slackv3 # to get a specific release use `--branch <release-tag>`, e.g. `--branch v0.1.0` git clone --depth 1 https://github.com/errbotio/err-backend-slackv3 pip install .
-
Configure the slack bot token, signing secret (Events API with Request URLs) and/or app token (Events API with Socket-mode). Located in
/opt/errbot/config.py
BOT_IDENTITY = { 'token': 'xoxb-...', 'signing_secret': "<hexadecimal value>", 'app_token': "xapp-..." }
Setting up Slack application
Legacy token with RTM
This was the original method for connecting a bot to Slack. Create a bot token, configure errbot with it and start using Slack. Pay attention when reading this document explaining how to create a "classic slack application". Slack does not allow Legacy bot tokens to use the Events API.
Current token with Events Request URLs
This is by far the most complex method of having errbot communicate with Slack. The architecture involves server to client communication over HTTP. This means the Slack server must be able to reach errbot's /slack/events
endpoint via the internet using a valid SSL connection.
How to set up such an architecture is outside the scope of this readme and is left as an exercise for the reader. Read this document for details on how to configure the Slack app and request URL.
Current token with Events Socket-mode client
Create a current bot token, enable socket mode. Configure errbot to use the bot and app tokens and start using Slack. Read this document for instructions on setting up Socket-mode.
Ensure the bot is also subscribed to the following events:
file_created
file_public
message.channels
message.groups
message.im
Moving from older slack backends
Bot Admins
Slack changed the way users are uniquely identified from display name @some_name
to user id Uxxxxxx
.
Errbot configuration will need to be updated before administrators can be correctly identified aginst
the ACL sets.
The UserID is in plain text format. It can be found in the the Slack full profile page or using the !whoami
command (person
field).
Because BOT_ADMINS is defined as plain text User IDs, they can not be used to send notifications. The mention format
<@Uxxxxx>
must be used in the BOT_ADMINS_NOTIFICATIONS configuration setting for errbot to initiate message to bot administrators.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file errbot-backend-slackv3-0.2.1.tar.gz
.
File metadata
- Download URL: errbot-backend-slackv3-0.2.1.tar.gz
- Upload date:
- Size: 31.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3eb2850b9571c11125d2638bc4c3e5688492c69d2c7642a992afbcc612118efb |
|
MD5 | b4721fd803907d44e2b51524be67e99f |
|
BLAKE2b-256 | 200a2e1b8538d430cad5fdf85a56824a88074e02710db56035056fc62f6ff260 |