Telegram Codex Bridge (Codex)
Route Telegram replies back into Codex sessions. Includes three options:
- Non-interactive
codex exec+codex exec resume. codex mcp-serverwith MCP stdio JSON-RPC.- tmux injection for interactive Codex sessions.
All options store a mapping from (chat_id, bot_message_id) to a route so replies can be routed correctly.
Install
- Ensure
uvis installed. - Use the scripts in this folder as-is (no extra dependencies).
- Set
TELEGRAM_BOT_TOKENand (optionally)ALLOWED_CHAT_IDS, or put them in~/.codex/telegram.toml.
Example ~/.codex/telegram.toml:
bot_token = "123:abc"
allowed_chat_ids = [123456789]
startup_chat_ids = [123456789]
startup_message = "✅ exec_bridge started (codex exec)."
Environment variables always override the TOML file.
Option 1: exec/resume
Run:
export TELEGRAM_BOT_TOKEN="123:abc"
export BRIDGE_DB="./bridge_routes.sqlite3"
export CODEX_CMD="codex"
export CODEX_WORKSPACE="/path/to/repo"
export CODEX_EXEC_ARGS="--full-auto"
export STARTUP_CHAT_IDS="123456789" # optional; defaults to ALLOWED_CHAT_IDS if set
export STARTUP_MESSAGE="✅ exec_bridge started (codex exec)." # optional; PWD is appended
uv run exec_bridge.py
Option 2: MCP server
Run:
export TELEGRAM_BOT_TOKEN="123:abc"
export BRIDGE_DB="./bridge_routes.sqlite3"
export CODEX_MCP_CMD="codex mcp-server"
export CODEX_WORKSPACE="/path/to/repo"
export CODEX_SANDBOX="workspace-write"
export CODEX_APPROVAL_POLICY="never"
uv run mcp_bridge.py
Option 3: tmux
Reply injector:
export TELEGRAM_BOT_TOKEN="123:abc"
export BRIDGE_DB="./bridge_routes.sqlite3"
export ALLOWED_CHAT_IDS="123456789"
uv run tmux_reply_bot.py
Notifier (call from your existing hook):
uv run tmux_notify.py --chat-id "$CHAT_ID" --tmux-target "codex1:0.0" --text "$TURN_TEXT"
Files
bridge_common.py: shared Telegram client, chunking, and routing storeexec_bridge.py: codex exec + resume bridgemcp_bridge.py: MCP stdio JSON-RPC bridgetmux_notify.py: tmux notifier helpertmux_reply_bot.py: tmux reply injector