| name | chat-to-codex |
| description | Deploy, configure, and validate the Gan-Xing Telegram-to-Codex bridge on macOS or Linux, locally or over SSH. Use when Codex needs to clone or update the bridge repo, collect Telegram bot and chat/topic values, write the bridge `.env`, enable the host-native user service, and guide the user through the first Telegram message test. Trigger on requests about Telegram bots controlling Codex, copying the bridge to another host, remote bridge deployment, or turning this repo into an installable Codex skill. |
Chat To Codex
Deploy the Telegram Codex bridge to a macOS or Linux host with as little manual setup as possible. The bundled scripts install user-scoped Node.js and Codex CLI when missing, clone or update the bridge repo, write .env, build the project, run doctor checks, and optionally install the host-native user service.
This skill is not finished when the repo is merely installed. Treat a bridge setup as complete only after:
- the repo exists at the target path
.env contains the correct Telegram values
- the bridge passes
doctor and can report status
- the user has been told exactly where to send the first Telegram message
- the setup has been smoke-tested or clearly blocked by missing Telegram-side values
Mandatory Workflow
Follow this order every time:
- Decide whether this is a local host install or a remote host over SSH.
- Confirm where the bridge repo should live. If the repo is not already present, clone it or let bootstrap clone it.
- Decide the Telegram mode before writing
.env:
- private chat only
- one allowed group
- one allowed topic inside one group
- Collect the Telegram values and filesystem paths listed below.
- Run the correct bootstrap script with explicit arguments.
- Run post-install validation.
- Tell the user to send a first Telegram message and explain exactly where to send it.
- If the bridge does not answer, inspect
status, logs, and Telegram configuration instead of declaring success.
Do not stop after "install completed" if the user asked for a working bot.
Required Inputs
Collect these values before running bootstrap:
TG_BOT_TOKEN
TG_ALLOWED_USER_ID
DEFAULT_CWD
Collect these values when group/topic mode is used:
TG_ALLOWED_CHAT_ID
TG_ALLOWED_TOPIC_ID
Collect these deployment values on every run:
- install directory
- SSH host when deploying remotely
Defaults:
- repo URL:
https://github.com/Gan-Xing/telegram-codex-app-bridge.git
- repo ref:
main
- install directory:
~/telegram-codex-app-bridge
DEFAULT_APPROVAL_POLICY: on-request
DEFAULT_SANDBOX_MODE: workspace-write
Telegram behavior:
- private chat with
TG_ALLOWED_USER_ID remains available even when TG_ALLOWED_CHAT_ID or TG_ALLOWED_TOPIC_ID is set
TG_ALLOWED_CHAT_ID and TG_ALLOWED_TOPIC_ID choose the default group or topic scope; they do not disable private chat
If TG_ALLOWED_CHAT_ID or TG_ALLOWED_TOPIC_ID is missing, read references/telegram-setup.md and explicitly guide the user through collecting it.
Deployment Rules
- If the user is deploying to a second host, prefer one bot per device.
- If no unique bot token has been provided for the second host, bootstrap with
--no-start.
- If group or topic mode is involved, read references/telegram-setup.md before continuing.
- Always explain to the user which values will be written into
.env before starting bootstrap.
- After bootstrap, check
codex login status. If authentication is missing, tell the user to run codex login on that host.
- If the user only says "set it up" and has not given all required values, ask for the missing values directly instead of guessing Telegram IDs.
- If the user wants a fully usable setup, continue until first-message validation is done or clearly blocked by Telegram-side prerequisites.
What To Ask The User
Use short direct questions when values are missing. The minimum useful checklist is:
- Where should the repo live on the target host?
- Which directory should be the bridge's default working directory?
- What is the Telegram bot token?
- What is the Telegram numeric user id allowed to control the bridge?
- Are we using private chat only, a group, or a specific topic?
- If group/topic mode: what are the
TG_ALLOWED_CHAT_ID and TG_ALLOWED_TOPIC_ID values?
If the user does not know the Telegram ids, point them to the exact getUpdates method in references/telegram-setup.md.
Local Bootstrap
Run:
python3 "$CODEX_HOME/skills/chat-to-codex/scripts/bootstrap_host.py" \
--tg-bot-token "<BOT_TOKEN>" \
--tg-allowed-user-id "<USER_ID>" \
--default-cwd "<ABSOLUTE_CWD>" \
--tg-allowed-chat-id "<CHAT_ID>" \
--tg-allowed-topic-id "<TOPIC_ID>" \
--default-sandbox-mode "workspace-write"
Omit --tg-allowed-chat-id and --tg-allowed-topic-id when using private chat only.
Use --no-start when you only want the host prepared but do not want the bridge service to start yet.
When the repo is not already present on disk, this bootstrap path counts as the repo download step because it clones the bridge automatically.
Remote Bootstrap Over SSH
Run:
python3 "$CODEX_HOME/skills/chat-to-codex/scripts/bootstrap_remote.py" \
--ssh-host "<USER@HOST>" \
--install-dir "<REMOTE_INSTALL_DIR>" \
--tg-bot-token "<BOT_TOKEN>" \
--tg-allowed-user-id "<USER_ID>" \
--default-cwd "<REMOTE_ABSOLUTE_CWD>" \
--tg-allowed-chat-id "<CHAT_ID>" \
--tg-allowed-topic-id "<TOPIC_ID>" \
--default-sandbox-mode "workspace-write"
Use --no-start by default when preparing a second host before a unique bot token is ready.
Validation
After either bootstrap path:
- Run
node dist/main.js doctor in the installed bridge repo.
- If the user service was installed, run
./scripts/service/status.sh.
- Check
codex login status. If authentication is missing, stop and tell the user exactly how to log in.
- If the bridge is expected to answer in a Telegram group, confirm:
privacy mode is disabled
- the bot is an admin in the group
- the configured
TG_ALLOWED_CHAT_ID and TG_ALLOWED_TOPIC_ID match the target group/topic
- If group or topic mode is enabled, also verify that private chat still responds for the configured
TG_ALLOWED_USER_ID.
First Telegram Message Check
Do this whenever the bridge has been started:
- Tell the user exactly where to send the first test message:
- private chat mode: send
/help to the bot in private chat
- group mode: send
/help@botname or /help in the configured default scope
- topic mode: send
/help inside the configured topic, then send one plain-language message
- After the user sends that message, verify the bridge is listening:
node dist/main.js status
./scripts/service/logs.sh or the host service log if there is no reply
- If the bot still does not answer, debug the Telegram side before changing the bridge:
- wrong bot token
- wrong user id
- wrong chat/topic ids
- privacy mode still on
- bot not admin in group
Do not describe the setup as "done" until this smoke test has either passed or been blocked by missing Telegram-side access.
Resources
- references/telegram-setup.md: Telegram-side checklist and ID discovery
scripts/bootstrap_host.py: install and configure the bridge on the current host
scripts/bootstrap_remote.py: run the same bootstrap on another host over SSH