← Alle Recipes
Phase 5 · Daily Use·15 min·8 steps

Notifications — Telegram, Discord, email signals from your AI

When a long-running agent finishes you want to know. Wire up mcp-multi-channel or an email hook so signals reach you outside the terminal.

8 steps0%
Du liest ohne Account. Mit Login speichern wir Step-Fortschritt + Notes.

Notifications

Long-running agents do not require you to babysit them. A nightly research agent finishes at 03:17 — you do not want to be sitting in the terminal at 03:17 to see it. A 40-minute build finishes while you are in a meeting — you should hear about it without checking. A scheduled morning brief lands at 08:30 — you want it to land in your phone, not in a tab you forgot to open.

Wire your AI to a notification channel. Telegram, Discord, email, Slack — whichever channel you actually read. Two patterns: an MCP server that exposes a send tool to your agent, or a Stop hook that fires on session end.

Step 1: Anthropic Channels (March 2026 research preview)

Before you wire anything yourself, check whether the official Anthropic Channels feature covers what you need. Channels is bidirectional — you can both push events and chat back from your phone. Telegram, Discord, iMessage are supported on the Web/Desktop app. For pure event push from the CLI, Channels is the cleanest first choice. The MCP-multi-channel path below is the right pick when you want full control of routing rules, multiple channels at once, custom webhook destinations, or you are running Claude Code in a non-Desktop environment.

Try Channels first if you only need one or two notification destinations. Continue with this recipe if Channels is not enough.

Step 2: Pick a channel you actually check

This is the most important step and the easiest to get wrong. Pick the channel where you will see the message within an hour, on a normal day, without effort. Common honest answers:

  • Telegram — best if you live on your phone, do not check email, and want push notifications without enterprise overhead.
  • Discord — best if you are already in a server you check daily, or you want a public/team channel.
  • Slack — best if you are at a company that uses Slack and your AI work overlaps with team work.
  • Email — best for digests (morning brief, weekly review). Bad for "build finished" pings — too slow.
  • Webhook to your own server — best if you want to route to multiple channels with custom rules.

Pick exactly one for the first wire-up. Add others later if needed.

Step 3: Pick an install path

Two paths, pick one:

  • Webhook-direct (recommended starter). No MCP server at all — just curl in a Stop hook (Step 5) or a one-line bash call from Claude. Works for every channel that has a webhook (Telegram bot API, Discord channel webhook, Slack incoming webhook, ntfy, your own server). Lowest dependency, fastest to wire up.
  • Single-platform MCP. Search npm for the channel you want — mcp-telegram, mcp-discord, mcp-slack and similar packages exist with varying maintenance levels. They wrap the channel's API behind MCP send / list tools so the agent picks the right destination automatically. Worth the dependency if you want the agent to choose between channels in one call.

For the rest of the recipe we walk the webhook-direct path with Telegram. Substitute another channel's URL where Telegram appears — the rest is the same.

Step 4: Get a Telegram bot + chat ID

If Telegram is your channel:

  1. Open @BotFather on Telegram, send /newbot, follow the prompts. Save the bot token (1234567890:ABC...).
  2. Send your new bot a "hi" message so a chat exists between you.
  3. Hit https://api.telegram.org/bot<TOKEN>/getUpdates — the JSON contains chat.id. Save it.

For Discord: create a webhook on a channel via Server Settings → Integrations → Webhooks. Copy the URL. For Slack: create an incoming webhook in your workspace's app config. Copy the URL.

Stick the credentials in ~/.claude/settings.json under env so hooks can read them:

{
  "env": {
    "TG_TOKEN": "1234567890:ABC...",
    "TG_CHAT": "123456789"
  }
}
Client check · run on your machine
claude mcp list 2>&1 | grep -iE "multi-channel|telegram|discord|slack|matrix|webhook" | head -5
Expect: A messaging-bridge MCP is listed.
If stuck: Install mcp-multi-channel (`claude mcp add multi -s user -- npx -y @studiomeyer/mcp-multi-channel`) or any single-platform MCP.

Step 5: Verify

The messaging_bridge_active validator runs claude mcp list and looks for multi-channel, telegram, discord, slack, or matrix in the server names — useful if you went the MCP-server path. For the webhook-direct path, just hit the API once from your shell to confirm credentials work:

TG_TOKEN=...your-token... TG_CHAT=...your-chat... \
  curl -s -X POST "https://api.telegram.org/bot$TG_TOKEN/sendMessage" \
  -d "chat_id=$TG_CHAT" -d "text=test from claude"

If a message arrives in your Telegram chat, the credentials are correct. Stop hook (Step 5) does the same call from Claude.

Step 6: Wire a Stop hook for session-end pings

Notifications only land if something triggers them. Two trigger patterns:

  • In-prompt — you ask the agent to send a notification at the end of a long task. Works for one-off "ping me when this build finishes".
  • Hook-based — fires automatically on session end. Works for "ping me whenever a long Claude Code session closes".

For the hook pattern, in ~/.claude/settings.json (merge with existing hooks):

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "curl -s -X POST \"https://api.telegram.org/bot$TG_TOKEN/sendMessage\" -d \"chat_id=$TG_CHAT\" -d \"text=Claude session ended\""
          }
        ]
      }
    ]
  }
}

That fires every time a session closes — one curl, fast, no roundtrip.

If you want the bot to also include a session summary (more useful for long sessions), wrap a one-shot headless Claude:

{
  "hooks": {
    "Stop": [
      {
        "hooks": [
          {
            "type": "command",
            "command": "bash -c 'SUMMARY=$(echo \"summarize this session in one line\" | claude --headless --no-tty); curl -s -X POST \"https://api.telegram.org/bot$TG_TOKEN/sendMessage\" -d \"chat_id=$TG_CHAT\" -d \"text=Session ended: $SUMMARY\"'"
          }
        ]
      }
    ]
  }
}

For just the "build finished" case, a simpler hook on PostToolUse for specific tools:

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Bash(npm run deploy*)",
        "hooks": [
          {
            "type": "command",
            "command": "curl -s -X POST \"https://api.telegram.org/bot$TG_TOKEN/sendMessage\" -d \"chat_id=$TG_CHAT\" -d \"text=Deploy finished\""
          }
        ]
      }
    ]
  }
}

Note the "matcher" + "hooks": [{ "type": "command", "command": "..." }] nesting — same shape as the safety-guard hook from Recipe 1.3. The flat { "command": ..., "args": [...] } form silently does nothing — Claude Code's harness ignores entries that miss the "hooks" array wrapper.

Step 7: Notification hygiene

Three rules so notifications stay useful instead of becoming noise you mute:

  • Notify on completion or failure, not progress. "Build started" is noise. "Build finished" or "Build failed: X" is signal.
  • One channel per signal class. Morning brief → email. Build/deploy → Telegram. Ad-hoc agent finish → Telegram. Not "everything everywhere".
  • Mute the bot during deep work. If you are coding 9-12, mute the Telegram bot for those three hours. Notifications you cannot respond to are stress, not information.

The right number of notifications per day for one person is 2-5. More than that, you start ignoring them. If you are getting 20 a day, the system is over-alerting and you need to tighten the triggers, not add more channels.

Step 8: Webhooks for the custom path

If you have your own server (n8n, your own Node service, anything that accepts a webhook), point the agent at that and route from there. Pattern:

Send to channel=webhook url=https://hook.mydomain.com/agent-events body={"event":"build_done","status":"ok"}

Your own server then decides what to do — fan out to Telegram + Slack + email, dedupe, batch into a daily digest, whatever you need. This is what you reach for when "always notify" is too much and "never notify" is too little, and you want a programmable middle layer.

For the average personal setup, single-channel direct (Telegram + a Stop hook + a build hook) is enough. Webhooks are for when notifications become their own product.

Debrief — clean session ends sWeekly review — synthesize a w