Setup telegram
Set up a Telegram bot so Claude Code can send notifications and ask the owner questions during unattended runs. Walks the user through @BotFather, then has them write ~/.claude/telegram.env themselves at a silent prompt — the bot token is never pasted into the chat and Claude never sees it. Use when the user says "set up telegram", "configure telegram notifications", "connect a telegram bot", "notify me on telegram", or when telegram-ask.sh / telegram-notify.sh reports missing credentials.From its SKILL.md
npx -y skills add panitw/engineering-skills --skill setup-telegramAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
7.9 KB, as published. Nobody here has run it
Set up Telegram notifications
Wires this machine's Claude Code to a Telegram bot, so it can ping the owner when a run needs
attention and — for the run-dev-cycle pipeline — ask the owner a question they can answer from
their phone. Credentials live in ~/.claude/telegram.env, which is machine-local and never
committed.
The one rule: you never see the token
The bot token is a bearer credential — anyone holding it controls the bot. Never accept it in the chat window, and never ask for it there.
- Never say "paste your token here", "what's your bot token?", or offer to write the file for them from a value they give you.
- Never run the setup script yourself. It is interactive and refuses to run without a real terminal, precisely so an agent cannot capture the input. Hand the user the command; they run it.
- Never read the credentials back: no
cat/Read/grep/headontelegram.env, noecho $TELEGRAM_BOT_TOKEN, nocurlwith the token spliced into the URL. Usetelegram-doctor.sh, which loads the token internally and prints only non-secret results. - The chat id is not a secret in the same way — it is fine for the user to type one in the chat if the auto-detection misses, and fine for you to write it into a config file.
If the user pastes the token into the chat anyway — stop and say this, before anything else:
That token is now in this conversation's history, so treat it as compromised. Open @BotFather, send
/revoke, pick this bot, and it will issue a fresh token. Use the new one at the setup prompt below. I won't use the one you pasted.
Then continue from Step 2 with the replacement token. Do not use the pasted value for anything, including a "quick test" — a revoked-and-replaced token is the only clean recovery.
Step 0 — check what already exists
"${CLAUDE_PLUGIN_ROOT}/scripts/telegram-doctor.sh"
- Exit 0 /
healthy→ already set up. Report the bot username it printed, mention any warnings (permissions, webhook), and offer--sendfor a live test message. Skip to Step 4 only if the user also wants the notification hook wired. - Exit 2 → not configured (or malformed). Continue to Step 1.
- Exit 3 → configured but the token or chat is rejected. Continue to Step 1; the fix is a fresh run of the setup script.
Also confirm curl and jq are installed — the doctor reports both. On macOS: brew install jq.
Step 1 — the user creates the bot
Give them these steps verbatim; they happen entirely inside Telegram:
- Open Telegram and start a chat with @BotFather.
- Send
/newbot. - Give it a display name (anything, e.g. "Claude Code"), then a username ending in
bot(e.g.panit_claude_code_bot) — it must be globally unique. - BotFather replies with a token line like
123456789:AAH.... Leave it in Telegram — they will paste it at a hidden prompt in the next step, not here.
Tell them the token is copyable again later from BotFather via /mybots, so there is no rush.
Step 2 — the user runs the setup script in their own terminal
Resolve the real path first (it differs per machine, and ${CLAUDE_PLUGIN_ROOT} is not set in
their shell), then give them one copy-pasteable line:
echo "${CLAUDE_PLUGIN_ROOT}/scripts/telegram-setup.sh"
Present it as: "Open a terminal — your own, not through me — and run: <resolved path>".
What the script does, so you can answer questions about it: refuses arguments and refuses to run
without a TTY; reads the token at a silent prompt; validates it with getMe; offers to delete a
webhook if one is set (a webhook would starve telegram-ask.sh's long-poll); waits up to 2 minutes
for the user to message the bot so it can auto-detect the numeric chat id; writes
~/.claude/telegram.env at mode 600; and sends a confirmation message.
Two things they may ask:
- "It's waiting for a message" — they must open their new bot in Telegram and send it anything
(
/start). Telegram will not reveal a chat id until the user has messaged the bot first. - "Can it notify a group?" — yes: add the bot to the group and send a message that mentions it, and the script will pick up the group's (negative) chat id.
Wait for them to report back. Do not poll the file.
Step 3 — verify
"${CLAUDE_PLUGIN_ROOT}/scripts/telegram-doctor.sh" --send
That checks file permissions, credential validity, webhook state, and chat reachability, then
delivers a test message. Ask the user to confirm the message arrived — that is the only end-to-end
proof. Relay any ! warnings; a webhook warning in particular means unattended owner questions
will hang.
Step 4 — optional: fire notifications on every attention event
scripts/telegram-notify-hook.sh is a Claude Code Notification hook: it pings Telegram whenever a
session wants attention (a tool awaiting permission, or an idle prompt). Offer it; it is opt-in.
If the user wants it, add to ~/.claude/settings.json (machine-local, so an absolute path is
correct here — ${CLAUDE_PLUGIN_ROOT} is not expanded in user settings):
{
"hooks": {
"Notification": [
{
"matcher": "",
"hooks": [
{ "type": "command", "command": "/absolute/path/to/plugin/scripts/telegram-notify-hook.sh" }
]
}
]
}
}
Resolve the absolute path from echo "${CLAUDE_PLUGIN_ROOT}", merge into any existing hooks
block rather than overwriting it, and mention that the path must be updated if the plugin is ever
reinstalled elsewhere. For anything more involved in settings.json, defer to the update-config
skill. The hook swallows all errors and always exits 0, so a broken Telegram setup can never fail a
session.
Step 5 — tell them what it unlocks
run-dev-cyclenow asks the owner over Telegram instead of blocking at the terminal when a decision needs them and the run is unattended (scripts/telegram-ask.sh, background, 6h default wait). They answer by tapping a button or typing a reply.scripts/telegram-notify.sh "message"is a one-way ping usable from any script.- Tuning:
TELEGRAM_ASK_TIMEOUT_SECONDSintelegram.envchanges the owner-reply wait window.
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
doctor: token rejected: Unauthorized | wrong/revoked token | /mybots → API Token in @BotFather, re-run setup |
doctor: chat not reachable | user never messaged the bot, or wrong id | send the bot a message, re-run setup to re-detect |
| Owner questions never get an answer | a webhook is set, or two telegram-ask.sh run at once | delete the webhook (re-run setup); keep one ask in flight per bot |
setup: no terminal attached | it was launched by an agent or piped | the user must run it directly in their own terminal — this is intentional |
setup: Conflict while detecting the chat | another poller is live on this bot | stop the other process, then re-run |
| Nothing arrives, doctor healthy | the user muted or blocked the bot | unmute the bot's chat in Telegram |
Notes
- Everything here is per-machine.
telegram.envis deliberately outside this repo and matched by.gitignore; setting up a second machine means repeating Steps 1–3 (the same bot can serve both — reuse the token from/mybots, no new bot needed). - If the user wants to stop using it: delete
~/.claude/telegram.env, remove the hook entry, and optionally/deletebotin @BotFather.