AI Skill Report Card

Sending Telegram Task Notifications

A-82ยทSep 2, 2026ยทSource: Web
14 / 15

When the user says exactly tg notif enable:

  1. Persist the flag to a state file (since sessions/turns are otherwise stateless): write .claude/tg_notif.json with {"enabled": true, "bot_token": "...", "chat_id": "..."}.
  2. If bot token / chat ID aren't known yet, ask once for them (or check environment variables TG_BOT_TOKEN / TG_CHAT_ID), then save to the state file.
  3. Confirm: "Telegram notifications enabled. I'll notify you at the start and finish of every task."
  4. For every task from here on (this session and future ones, as long as the state file says enabled), send a Telegram message via the Bot API at start and at finish.

Concrete send mechanism (use whichever matches the environment):

  • Shell/curl (default, works anywhere with network access):
    Bash
    curl -s -X POST "https://api.telegram.org/bot${TG_BOT_TOKEN}/sendMessage" \ -d chat_id="${TG_CHAT_ID}" \ -d text="๐ŸŸข Task started: Refactor auth module to use JWT"
  • MCP tool, if a Telegram MCP server is connected (e.g., tool name telegram_send_message): call it with {chat_id, text}.
  • Python (if a script context is more natural):
    Python
    import requests, os requests.post( f"https://api.telegram.org/bot{os.environ['TG_BOT_TOKEN']}/sendMessage", data={"chat_id": os.environ["TG_CHAT_ID"], "text": "๐ŸŸข Task started: ..."} )

Prefer curl for simplicity unless an MCP Telegram tool is already available in the environment โ€” check available tools first before falling back to curl.

Recommendationโ–พ
Description could be tightened slightly to avoid redundancy between 'when the user has enabled it' and the trigger explanation
14 / 15

Progress:

  • Detect tg notif enable / tg notif disable
  • Read/write persistent state file for the flag + credentials
  • Verify a send mechanism exists (MCP tool, curl+credentials, or script)
  • Send "start" notification before beginning each task (if enabled)
  • Do the actual task work
  • Send "finish" notification after task completes, success or failure (if enabled)

Step-by-step:

  1. Detect command. Watch for tg notif enable / tg notif disable (case-insensitive), as a standalone message.

  2. Persist state. On enable, write to .claude/tg_notif.json:

    JSON
    {"enabled": true, "bot_token": "123456:ABC-DEF...", "chat_id": "987654321"}

    On disable, set "enabled": false (keep credentials so re-enabling doesn't require re-asking). At the start of any new task, read this file first to decide whether to notify โ€” this is how the flag survives across turns/sessions without relying on conversation memory.

  3. Verify send mechanism before first use:

    • Check for an available MCP tool with "telegram" in its name/description.
    • Else check TG_BOT_TOKEN / TG_CHAT_ID are present (env vars or state file).
    • If neither exists, notifications cannot be sent โ€” see fallback example below. Do not silently skip.
  4. On each new task/prompt while enabled:

    • Before starting work, send: ๐ŸŸข Task started: <short task summary>
  5. After the task ends (success or failure):

    • Success: โœ… Task finished: <short task summary> โ€” <one-line result>
    • Failure: โŒ Task failed: <short task summary> โ€” <one-line error/reason>
  6. If disabled or state file missing/unreadable, do nothing extra โ€” proceed with the task silently.

Recommendationโ–พ
Add an example of the disable-then-still-getting-asked edge case, or what happens if credentials are invalid (API error handling)
18 / 20

Example 1: Enabling Input:

tg notif enable

Output:

Telegram notifications enabled. I'll notify you at the start and finish of each task.
(Saved config to .claude/tg_notif.json)

Example 2: Successful task with notifications Input (after enabling):

Refactor the auth module to use JWT

Output:

[curl โ†’ Telegram] ๐ŸŸข Task started: Refactor auth module to use JWT

... performs the refactor ...

[curl โ†’ Telegram] โœ… Task finished: Refactor auth module to use JWT โ€” all tests passing, 3 files changed

Example 3: Failed task with notifications Input (after enabling):

Deploy the app to production

Output:

[curl โ†’ Telegram] ๐ŸŸข Task started: Deploy app to production

... deployment fails due to missing env var ...

[curl โ†’ Telegram] โŒ Task failed: Deploy app to production โ€” missing PROD_DB_URL environment variable

Example 4: No integration configured (fallback path) Input (after enabling, but no bot token found):

Write unit tests for the payment module

Output:

โš ๏ธ Telegram notifications are enabled, but no send method is configured โ€” no MCP Telegram tool found and TG_BOT_TOKEN/TG_CHAT_ID are not set.
Please provide a bot token and chat ID (or set TG_BOT_TOKEN / TG_CHAT_ID env vars) so I can send notifications.

Proceeding with the task now without notifications:
... writes unit tests ...
Task complete: added 12 unit tests for payment module.

Example 5: Disabling Input:

tg notif disable

Output:

Telegram notifications disabled. (Config updated: enabled=false)
Recommendationโ–พ
Consider clarifying how per-step vs per-task notification granularity is decided for very long-running tasks
  • Check available tools for an existing Telegram MCP integration before defaulting to raw curl.
  • Keep messages short: one line for start, one line for finish with outcome.
  • Send the start notification before doing any work, not after.
  • Always send a finish notification, even on failure โ€” use โŒ instead of โœ… and state the reason.
  • Store credentials once in the state file so the user isn't asked repeatedly across sessions.
  • For long multi-step tasks, one start/finish pair is enough unless the user asks for per-step updates.
  • Don't hand-wave the send mechanism โ€” always use a concrete method (curl to Bot API, MCP tool call, or script) shown above.
  • Don't rely on in-memory-only state โ€” conversation context resets; use the state file to persist the enabled flag and credentials.
  • Don't skip the finish notification on failure; silence on error is worse than silence on success.
  • Don't keep notifying after tg notif disable โ€” always re-check the state file before sending.
  • Don't assume credentials exist โ€” verify and fall back to asking the user explicitly, then continue the task anyway.
0
Grade A-AI Skill Framework
Scorecard
Criteria Breakdown
Quick Start
14/15
Workflow
14/15
Examples
18/20
Completeness
17/20
Format
14/15
Conciseness
13/15