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:
1. Create the app
Section titled “1. Create the app”https://api.slack.com/apps → Create New App → From scratch → name it (e.g. <yourstartup>-agents) → pick the workspace.
2. Add Incoming Webhooks
Section titled “2. Add Incoming Webhooks”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.
3. Test it
Section titled “3. Test it”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.
4. Store it
Section titled “4. Store it”Three options:
Option A: Env var (simplest)
Section titled “Option A: Env var (simplest)”echo 'SLACK_WEBHOOK_URL=https://hooks.slack.com/services/T.../B.../...' >> ~/.alfredrcexec $SHELLOption B: AWS Secrets Manager (recommended for prod)
Section titled “Option B: AWS Secrets Manager (recommended for prod)”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-1The framework’s default secret ID is alfred/slack-webhook. See AWS setup for the IAM policy your scheduled-agent identity needs.
Option C: Both
Section titled “Option C: Both”Set SLACK_WEBHOOK_URL only to override the AWS-stored value (e.g. testing a rotation).
5. Verify in Python
Section titled “5. Verify in Python”import syssys.path.insert(0, "lib")from agent_runner import slack_postslack_post("alfred-os setup test", severity="info")You should see the message in your channel.
Severity routing
Section titled “Severity routing”slack_post(text, severity="info" | "warn" | "alert"). See Severity routing.
Optional: bot token (xoxb-)
Section titled “Optional: bot token (xoxb-)”Required for firing_thread_root, firing_thread_reply, and
firing_thread_close in lib/slack_format.py.
SLACK_BOT_TOKEN=xoxb-...SLACK_HOME_CHANNEL=alfredOr store the token in AWS Secrets Manager at alfred/slack-bot-token and leave
SLACK_BOT_TOKEN unset. See Slack setup → Optional: bot token.
Optional: app-level token (xapp-1-)
Section titled “Optional: app-level token (xapp-1-)”Required only for Socket Mode (slash commands, button clicks). See Slack setup → Optional: app-level token.
Rotating
Section titled “Rotating”If you accidentally paste the URL somewhere it shouldn’t be:
- https://api.slack.com/apps → your app → Incoming Webhooks → trash icon on the compromised URL.
- Add a new webhook to the same channel.
- Update wherever you stored it (env var or AWS).
rm $HERMES_HOME/state/slack-webhook.cacheso the next firing re-fetches.