First time here? Complete the Setup guide first to install GAIA and its dependencies.
Prerequisites
1
Install the Telegram extra
The adapter talks to the Telegram Bot API directly over HTTPS, using
httpx from GAIA’s core install. The telegram extra adds psutil, which gaia telegram stop and status use to check the background process:2
Create a bot and get its token
In Telegram, open a chat with @BotFather, send
/newbot, and follow the prompts. BotFather returns a bot token that looks like 123456789:ABCdef.... Keep it secret — anyone with the token can control your bot.3
Make sure a local model is available
The adapter runs inference through your local Lemonade backend, the same as
gaia chat. If you haven’t set up a model yet, run gaia init first.Quick Start
Start the adapter in the foreground, passing the token from BotFather and the Telegram user IDs allowed to talk to it:Ctrl+C to stop.
To find your own numeric user ID, message @userinfobot. Omitting --allowed-users is refused at startup:
The token is supplied only via
--token — there is no environment variable for it. Wrap the command in a script or shell history that keeps the token out of shared logs.Core Usage
Run in the background
Use--background to run the adapter as a long-lived service. It writes a PID file to ~/.gaia/telegram.pid, a start marker to ~/.gaia/telegram.log, and exposes a health endpoint on 127.0.0.1:8768. Runtime logs — including refusals — go to ~/.gaia/gaia.log:
The command does not detach on its own — it holds the terminal for as long as the adapter polls, so that
gaia telegram stop has a live process to signal. Add & or run it under nohup/systemd to get your prompt back.Restrict who can use the bot
--allowed-users takes a comma-separated list of numeric Telegram user IDs, and it is required — there is no way to run the bot open to everyone:
~/.gaia/gaia.log and add it to the list.
Check status and stop
~/.gaia/telegram.pid when it exits. stop signals the recorded PID only after confirming it is still a gaia telegram start process; a leftover PID file that names any other process is removed without signalling it.
gaia telegram status checks 127.0.0.1:8768 by default. If you changed the health binding, point it at the right host and port with --health-host and --health-port. When running the adapter in the background, gaia telegram start also accepts --health-port to move the health server (e.g. when the default collides with another local service).
Command reference
How It Works
- Long polling — the adapter asks Telegram for new messages over HTTPS, so it needs no public URL or open port. Only new messages are fetched: edits to a message already sent are not answered, and commands other than
/startare ignored. Only one process can poll a bot at a time; a second one stops with an error naming the conflict. - Token stays out of logs — the bot token is replaced with
REDACTEDin every logged URL and error message. - Allowlist first — every update, including
/start, is checked against--allowed-usersbefore a session is created or any model is called. - No tool loop — a Telegram session is a chat session, not an agent. There are no shell, file-write, or other action tools for a message to reach.
- Per-user sessions — the adapter keeps one Agent SDK session per Telegram user ID, so conversation history stays separated between users. Sessions live in memory and are lost when the adapter restarts.
- Streaming replies — responses stream back into the Telegram chat as the model generates them.
- Stuck replies are stopped — the bot answers one message at a time, so a reply that stops streaming for 75 minutes (
GAIA_STREAM_TIMEOUTseconds, if set) is stopped and the text so far is kept. If it stopped mid-answer, your next message starts a new conversation. - Attachments — photos and files sent to the bot are saved to a temporary path so their contents can be read into the conversation.
- Local inference — all model calls go through your local Lemonade backend; message content is processed on your machine.
src/gaia/messaging/telegram.py.
Next Steps
Document Q&A
The full chat agent — RAG, memory, and tools — on your desktop.
Agent Memory
Persistent memory for the desktop agents.
Agent UI
The desktop front-end for the same agents.
All Guides
Browse every GAIA agent and adapter.