docs/users/features/channels/qqbot.md
This guide covers setting up a Qwen Code channel on QQ via the official QQ Bot Open Platform API.
Start the channel — the first time it will show a QR code. Scan it with your QQ app to activate. No developer account or manual registration needed. Credentials are saved and reused automatically.
{
"channels": {
"my-qq": {
"type": "qq"
}
}
}
qwen channel start my-qq
# Scan the QR code in the terminal with your QQ app
You can also use credentials from the QQ Bot Open Platform developer portal if you already have an app registered there:
{
"channels": {
"my-qq": {
"type": "qq",
"appID": "YOUR_APP_ID",
"appSecret": "$QQ_APP_SECRET"
}
}
}
Set the secret as an environment variable:
export QQ_APP_SECRET=<your-app-secret>
{
"channels": {
"my-qq": {
"type": "qq",
"appID": "YOUR_APP_ID",
"appSecret": "$QQ_APP_SECRET",
"sandbox": false,
"senderPolicy": "open",
"sessionScope": "user",
"cwd": "/path/to/your/project",
"instructions": "你是一个通过 QQ Bot 对话的 AI 助手。回复控制在 2000 字符以内。",
"blockStreaming": "on",
"groupPolicy": "disabled",
"groups": {
"*": { "requireMention": true }
}
}
}
}
| Option | Default | Description |
|---|---|---|
appID | — | QQ Bot AppID from developer portal. If omitted, QR code login is used. |
appSecret | — | QQ Bot AppSecret. Supports $ENV_VAR syntax. If omitted, QR code login is used. |
sandbox | false | Set to true to use the QQ sandbox API environment (sandbox.api.sgroup.qq.com) |
All standard channel options (see Channel Overview) are also supported:
senderPolicy, allowedUsers, sessionScope, cwd, instructions, groupPolicy, groups, dispatchMode, blockStreaming, blockStreamingChunk, blockStreamingCoalesce.
# Start only the QQ channel
qwen channel start my-qq
# Or start all configured channels together
qwen channel start
Open QQ and send a message to your bot. You should see the response arrive in your chat.
To use the bot in QQ groups:
groupPolicy to "allowlist" or "open" in your channel configQQ Bot API V2 only delivers group messages that @mention the bot — the bot does not see all group messages. By default, requireMention is true and should be left that way for QQ.
See Group Chats for full details on group policies and mention gating.
The QQ Bot channel supports Markdown formatting (msg_type=2). The agent's Markdown responses are sent as-is, and QQ renders them with rich formatting (bold, italic, code blocks, links, lists).
If the QQ server rejects a Markdown message for any reason, the channel automatically retries it as plain text — so your messages always go through even if the bot's Markdown capability is restricted server-side.
This is the opposite of the WeChat channel, which strips all Markdown. You can let the agent use full Markdown with the QQ channel.
Access tokens expire after approximately 2 hours. The channel automatically refreshes them at 80% of their TTL (typically ~1.6 hours). If a refresh fails, it retries after 60 seconds.
Token refresh continues across WebSocket reconnects — the channel never goes offline due to an expired token as long as the AppID and AppSecret remain valid.
RESUME opcode to restore the session without losing in-flight messages"sandbox": true to use the sandbox API during development. No production messages will be affected.senderPolicy: "allowlist" for a fixed set of QQ users, or "pairing" to approve new users from the CLI. See DM Pairing for details.| Area | QQ Bot | Telegram |
|---|---|---|
| Authentication | QR code login or AppID/AppSecret | Static bot token from BotFather |
| Markdown | Native QQ Markdown with plaintext fallback | HTML-formatted from agent Markdown |
| Token lifecycle | 2h TTL, auto-refresh at 80% | Permanent bot token |
| Group messages | Only @mention messages are delivered to bot | Bot sees all messages (with privacy mode off) |
| Typing indicator | Not available (QQ API limitation) | "Working..." message |
| Sandbox mode | Supported for testing | Not available |
qwen channel status)senderPolicy: "allowlist", make sure your QQ user ID is in allowedUsersgroupPolicy is set to "allowlist" or "open" (default is "disabled")"Markdown rejected" log messagesappSecret field or delete ~/.qwen/channels/<name>-credentials.json to re-trigger QR code login