Telegram Execution Notifier
Run command-line AI agents from Telegram and get their results back on your phone. Telegram Execution Notifier connects a Telegram bot to Claude Code, Codex CLI, and Kiro CLI running on your computer, so you can delegate coding, troubleshooting, documentation, and other tasks without staying at your terminal.
Send a prompt to your bot and choose which agent should handle it. The request is forwarded to the selected CLI on your computer, and the bot sends the final output to your authorized Telegram chat. This is especially useful when your agents can access local project files and skills: you can trigger workflows remotely and let an agent use the context and capabilities already configured in your CLI environment.
The project also provides a notify-telegram command for shell scripts, pipelines, and other tools to report when work finishes or fails. A small systemd --user service keeps the Telegram integration running in the background. Built-in prompt routing supports Claude Code, Codex CLI, and Kiro CLI; the notification command can also be used by other command-line tools, including AI CLIs that support skills.
Features
- Send prompts from Telegram to Claude Code, Codex CLI, or Kiro CLI on your computer.
- Receive an acknowledgment when a task starts and the agent's final output when it finishes.
- Run agents with access to local files and configured skills, making remote task delegation practical.
- Send success or failure notifications from the shell, scripts, pipelines, or Python code.
- Process messages only from the configured Telegram chat.
- Keep the integration running as a
systemd --userservice, with its local endpoint bound to127.0.0.1.
1. Create and configure the Telegram bot
- In Telegram, message @BotFather, run
/newbot, and save the token it gives you. - Open your new bot and send it
/start. - Find your numeric chat ID and configure it as the authorized recipient. Only messages from this chat are processed.
- Create the plain file
~/.config/telegram-exec-notifier/environmentwith the variables below (.env.examplelists every supported one). You encrypt it in step 3, so it does not stay on disk in plain text:
TELEGRAM_BOT_TOKEN=your-bot-token
TELEGRAM_CHAT_ID=your-chat-id
2. Install
From this project directory:
python -m venv .venv
. .venv/bin/activate
pip install -e .
Install from PyPI
pip install telegram-exec-notifier
This provides the notify-telegram command and telegram-exec-notifier (the bot service). The systemd unit and the scripts below are in this repository.
3. Start the user service
Encrypt the environment file, then start the service. Both commands run from the project directory:
./encrypt-credentials.sh
./start-service.sh
encrypt-credentials.sh uses systemd-creds (user scope, host key plus TPM2) to write environment.cred, checks that it decrypts to the same content, and then securely deletes the plain file. The service loads the credential with LoadCredentialEncrypted=, so the token is no longer stored in plain text on disk and is decrypted only on this computer. It needs a TPM2 (systemd-analyze has-tpm2) and systemd 256 or newer. To change a value, recreate the plain file and run ./encrypt-credentials.sh again, then restart the service.
The script installs the user service unit (filling in this project's path), sets the environment file permissions to 600, enables the service at startup, and restarts it.
The service expects to find claude, codex, and kiro-cli in $HOME/.local/bin or /usr/local/bin. Adjust PATH in the service unit if your CLI binaries are elsewhere. Claude and Codex receive the home directory as an additional working directory; Kiro runs with the home directory as its workspace and has read and write tools enabled. This lets the agents work with files across your home directory while the service unit keeps the rest of the system protected from writes. On startup, the service also copies personal skills from ~/.codex/skills and ~/.claude/skills to ~/.kiro/skills, preserving any skills already present in Kiro.
Send prompts from Telegram
Send a direct message to the bot from the authorized chat. Messages without a leading / go to Claude Code. Prefix with /codex or /kiro to use another agent:
explique o estado deste projeto
/codex encontre e corrija o bug no parser
/kiro revise a documentação
Continue an existing Claude session
By default each message starts a new Claude conversation that knows where other session transcripts live (~/.claude/projects). To continue a real session, for example the one running your experiment:
/sessions list the 10 most recent interactive sessions
/use 2 make session 2 active; later messages resume it with full context
/use new go back to a fresh conversation (also: /new)
The active session is saved in ~/.config/telegram-exec-notifier/state.json and survives service restarts. Sessions started by the bot itself are not listed. If the same session is open in a terminal, the bot's replies continue it separately from what you type there.
Claude replies are streamed: each message arrives as soon as it is written, a "still working" note appears every TELEGRAM_HEARTBEAT seconds while it runs, and a final message reports completion and elapsed time. Your next message is accepted as soon as the final answer is out, even if background tasks are still running.
The bot confirms when the task starts and sends the final output when it finishes. Each run has a time limit (30 minutes by default), and long responses are truncated to fit Telegram. Send /help to see the available commands. Messages from other chats are ignored.
Approve Claude permissions from Telegram
When Claude wants to run a command or edit a file that needs permission, the bot sends a message with the tool and its command or path, plus Permitir / Negar buttons. Claude continues or adapts according to your answer. If you do not answer within TELEGRAM_PERMISSION_TIMEOUT seconds (default 300), the request is denied. Only the authorized chat can answer. /codex and /kiro do not use this flow.
Optional settings in ~/.config/telegram-exec-notifier/environment:
# Claude runs without asking when its working directory is inside this folder.
# New conversations also start in this folder. Everything else still asks.
TELEGRAM_CLAUDE_AUTO_DIR=/home/you/sandbox
TELEGRAM_PERMISSION_TIMEOUT=300 # seconds to wait for a Telegram answer
TELEGRAM_COMMAND_TIMEOUT=1800 # seconds before a run is stopped
TELEGRAM_HEARTBEAT=120 # seconds between "still working" messages
TELEGRAM_BACKGROUND_TIMEOUT=86400 # seconds a run may continue after its final answer
The folder check uses the session's working directory, so a shell command inside that folder can still reach outside it (for example cd ..). Use a dedicated folder.
Run with Docker
As an alternative to systemd, run the bot as a container. The image only contains the service; the agent CLIs (claude, codex, kiro-cli) stay on your computer, so the compose file mounts your home directory at the same path and runs as your user.
cp .env.example .env # set TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID
HOST_UID=$(id -u) HOST_GID=$(id -g) docker compose up -d
The image is published at ghcr.io/sette/telegram-exec-notifier. The port is published on 127.0.0.1 only; do not expose it to the network. Credentials come from .env through the environment, so the systemd encrypted-credential flow does not apply; the bot token is still hidden from the agents it starts. The CLI binaries must run inside the image (a glibc Linux image); if yours do not, build a custom image from this one.
4. Send a notification
notify-telegram "Codex finished running."
notify-telegram --tool Codex "Training completed successfully."
notify-telegram --tool Claude --failed "The run failed."
some-command 2>&1 | notify-telegram --tool Codex
Call from Python
import asyncio
from telegram_exec_notifier import TelegramNotifier
asyncio.run(
TelegramNotifier().execution_finished("Codex", "Training completed")
)
The same call works in an existing async function with await.
Development and releases
uv run --group dev ruff check .
uv run --group dev pytest
CI runs lint, tests on Python 3.10 to 3.13, a package build check and a Docker build on every pull request. Commits follow type(scope): emoji description. release-please reads them on main and keeps a release pull request up to date; merging it creates the tag and the GitHub release, which publishes the package to PyPI and the image to GHCR.
One-time repository setup:
- Add the
RELEASE_PLEASE_TOKENsecret (a personal access token with contents and pull request write access) so the release it creates can trigger the publish workflows. - On PyPI, add a trusted publisher for
telegram-exec-notifier: ownerSette, repositorytelegram-exec-notifier, workflowpython-publish.yml, environmentpypi. Create thepypienvironment in the repository settings. - Do not edit
.release-please-manifest.json, the version inpyproject.tomlor the changelog by hand; the release PR does it.
Security notes
- The service processes commands only from the configured Telegram chat ID.
- Its local endpoint listens on
127.0.0.1; do not expose the port to the network. - The bot token is stored encrypted (
environment.cred), and the agent CLIs started by the bot do not inherit it in their environment. - While the service runs, systemd keeps the decrypted credential in
/run/user/<uid>/credentials/, readable by your user. An agent running as your user that knows this path could still read it, so encryption protects the token at rest (disk theft, backups, other users), not from a process running as you. Revoke the token with BotFather/revokeif you suspect a leak. - Never commit your bot token.
Metadata
Release files for telegram-exec-notifier 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| telegram_exec_notifier-0.2.0.tar.gz | 23.0 kB | With provenance | Details for telegram_exec_notifier-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| telegram_exec_notifier-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for telegram_exec_notifier-0.2.0-py3-none-any.whl |
Total release size: 42.2 kB
Release files / telegram_exec_notifier-0.2.0.tar.gz
| Download URL | telegram_exec_notifier-0.2.0.tar.gz |
|---|---|
| Size | 23.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5db325cfde2061ad36c3cdbaa2add05edf6d2504a984a69a7c63f7a04f6c8c7d
|
|
BLAKE2b-256 checksum How to use checksums |
7ca3ecd5244392eb937bf5f44020a6e8342dea5a5940eeef4b7f2b29900d8bdb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / telegram_exec_notifier-0.2.0-py3-none-any.whl
| Download URL | telegram_exec_notifier-0.2.0-py3-none-any.whl |
|---|---|
| Size | 19.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e7affa738eb7b682705402a97919e081745db29cf8eebc7081dc9c2d7617e4a6
|
|
BLAKE2b-256 checksum How to use checksums |
5b654109623668ed56b5611ad639567ccf2a86282e13dd1230c75e20d2da696a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for telegram-exec-notifier 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for telegram_exec_notifier-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.