Slack

Setting

SLACK_TOKEN (secret)

Client

slack_sdk.WebClient

Code

tasks/notifications.py (notify_on_slack, SlackCache)

Every notification to a recipient whose task assignee_type is user also queues notify_on_slack. On the Worker it:

  1. renders TEMPLATES["slack"][action] (HTML in the change list is flattened to text);

  2. finds the Slack user whose profile email equals the recipient’s email, using users.list cached per execution environment (SlackCache, retried up to 5 times on a KeyError);

  3. posts chat.postMessage to @<username> as "Task notifications" with :exclamation:.

Unknown users and SlackApiError are logged as errors and otherwise ignored.

Scopes needed: chat:write, chat:write.customize (custom username and icon), users:read, users:read.email.

The Zappa deployment used a Slack user token (xoxp-…) that is committed to this repository’s history (zappa_settings.json). Replace it with a bot token (xoxb-…) of a dedicated Slack app with the scopes above, store it as SLACK_TOKEN in actionstools/<env>, and revoke the old token.