docs/users/features/channels/telegram.md
This guide covers setting up a Qwen Code channel on Telegram.
/newbot and follow the prompts to choose a name and usernameTo use senderPolicy: "allowlist" or "pairing", you need your Telegram user ID (a numeric ID, not your username).
The easiest way to find it:
Add the channel to ~/.qwen/settings.json:
{
"channels": {
"my-telegram": {
"type": "telegram",
"token": "$TELEGRAM_BOT_TOKEN",
"senderPolicy": "allowlist",
"allowedUsers": ["YOUR_USER_ID"],
"sessionScope": "user",
"cwd": "/path/to/your/project",
"instructions": "You are a concise coding assistant responding via Telegram. Keep responses short.",
"groupPolicy": "disabled",
"groups": {
"*": { "requireMention": true }
}
}
}
}
Set the bot token as an environment variable:
export TELEGRAM_BOT_TOKEN=<your-token-from-botfather>
Or add it to a .env file that gets sourced before running.
# Start only the Telegram channel
qwen channel start my-telegram
# Or start all configured channels together
qwen channel start
Then open your bot in Telegram and send a message. You should see "Working..." appear immediately, followed by the agent's response.
To use the bot in Telegram groups:
groupPolicy to "allowlist" or "open" in your channel config/mybots → select your bot → Bot Settings → Group Privacy → Turn OffgroupPolicy: "allowlist", add the group's chat ID to groups in your configBy default, the bot requires an @mention or a reply to respond in groups. Set "requireMention": false for a specific group to make it respond to all messages (useful for dedicated task groups). See Group Chats for full details.
You can send photos and documents to the bot, not just text.
Photos: Send a photo and the agent will analyze it using its vision capabilities. This requires a multimodal model — add "model": "qwen3.5-plus" (or another vision-capable model) to your channel config. Photo captions are passed as the message text.
Documents: Send a PDF, code file, or any document. The bot downloads it and saves it locally so the agent can read it with its file tools. This works with any model. Telegram's file size limit is 20MB.
sessionScope: "user" — This gives each user their own conversation. Use /clear to start fresh.senderPolicy: "allowlist" for a fixed set of users, or "pairing" to let new users request access with a code you approve via CLI. See DM Pairing for details.The agent's markdown responses are automatically converted to Telegram-compatible HTML. Code blocks, bold, italic, links, and lists are all supported.
allowedUsers if using senderPolicy: "allowlist", or that you've been approved if using "pairing"groupPolicy is set to "allowlist" or "open" (default is "disabled")"allowlist", verify the group's chat ID is in the groups config@yourbotname hello to testThis usually means the agent encountered an error. Check the terminal output for details.
The agent may be running multiple tool calls (reading files, searching, etc.). The "Working..." indicator shows while the agent is processing. Complex tasks can take a minute or more.