Skip to content

Slack

Alfred-OS posts simple agent reports via an incoming webhook. slack_post() resolves the URL via env -> 30-day disk cache -> AWS Secrets Manager, so steady-state firings don’t pay an AWS round-trip every time. Agents that use lib/slack_format.py can also post Block Kit firing threads with an optional Slack bot token.

Full guide at docs/SLACK_SETUP.md. Highlights:

https://api.slack.com/appsCreate New AppFrom scratch → name it (e.g. <yourstartup>-agents) → pick the workspace.

App settings → Features → Incoming Webhooks → toggle on → Add New Webhook to Workspace → pick the channel → Allow.

Copy the URL. It’s a secret. Anyone with it can post to your channel.

Terminal window
curl -X POST -H 'Content-Type: application/json' \
--data '{"text":"hello from alfred-os setup"}' \
'https://hooks.slack.com/services/T.../B.../...'

Should appear in the channel within a second.

Three options:

Terminal window
echo 'SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T.../B.../...' >> ~/.alfredrc
exec $SHELL
Section titled “Option B: AWS Secrets Manager (recommended for prod)”
Terminal window
aws --profile <admin> secretsmanager create-secret \
--name alfred/slack-webhook \
--description "Slack incoming webhook for the agent fleet" \
--secret-string 'https://hooks.slack.com/services/T.../B.../...' \
--region us-east-1

The framework’s default secret ID is alfred/slack-webhook. See AWS setup for the IAM policy your scheduled-agent identity needs.

Set SLACK_WEBHOOK_URL only to override the AWS-stored value (e.g. testing a rotation).

import sys
sys.path.insert(0, "lib")
from agent_runner import slack_post
slack_post("alfred-os setup test", severity="info")

You should see the message in your channel.

slack_post(text, severity="info" | "warn" | "alert"). See Severity routing.

Required for firing_thread_root, firing_thread_reply, and firing_thread_close in lib/slack_format.py.

Terminal window
SLACK_BOT_TOKEN=xoxb-...
SLACK_HOME_CHANNEL=alfred

Or store the token in AWS Secrets Manager at alfred/slack-bot-token and leave SLACK_BOT_TOKEN unset. See Slack setup → Optional: bot token.

Required only for Socket Mode (slash commands, button clicks). See Slack setup → Optional: app-level token.

If you accidentally paste the URL somewhere it shouldn’t be:

  1. https://api.slack.com/apps → your app → Incoming Webhooks → trash icon on the compromised URL.
  2. Add a new webhook to the same channel.
  3. Update wherever you stored it (env var or AWS).
  4. rm $HERMES_HOME/state/slack-webhook.cache so the next firing re-fetches.