QQ Bot

QQ Bot adapter for Chat SDK. Connects to the QQ Bot Gateway over WebSocket or HTTP callback, supporting DM, group, and text-channel scenes with images, video, voice, and files.

Community adapter. Not maintained by Vercel or Chat SDK contributors. For feature requests, bug reports, and support, file an issue on the adapter's repo.

Install

pnpm add @agentor/chat-qq chat @chat-adapter/state-memory

Quick start

QQ bots receive events in one of two modes. WebSocket mode is the default; set mode: "callback" to use webhooks.

WebSocket mode

The adapter connects directly to the QQ Bot Gateway, so you don't need a public endpoint:

lib/bot.ts
import { createQQBotAdapter } from "@agentor/chat-qq";

const adapter = createQQBotAdapter({
  appId: process.env.QQ_BOT_APP_ID,
  clientSecret: process.env.QQ_BOT_CLIENT_SECRET,
});

await adapter.initialize({
  processMessage: async (_adapter, threadId, factory) => {
    const message = await factory();
    await adapter.postMessage(threadId, message.text);
  },
});

Webhook (callback) mode

The adapter receives events over HTTP and verifies their Ed25519 signatures. The two modes are mutually exclusive: once you configure an HTTPS callback URL on the bot, WebSocket mode is no longer available.

lib/bot.ts
import { createQQBotAdapter } from "@agentor/chat-qq";

const adapter = createQQBotAdapter({
  mode: "callback",
  appId: process.env.QQ_BOT_APP_ID,
  clientSecret: process.env.QQ_BOT_CLIENT_SECRET,
});

Configuration

PropTypeDefaultDescription
mode?"websocket" | "callback""websocket"
Connection mode. The two modes are mutually exclusive.
appId?string
QQ Bot application ID.
clientSecret?string
QQ Bot client secret.
intents?number
Event intent bitmask.
sandbox?booleanfalse
Use the sandbox environment (WebSocket mode).
userName?string"QQ Bot"
Bot display name.

Environment variables

VariableRequiredDescription
QQ_BOT_APP_IDYesQQ Bot application ID.
QQ_BOT_CLIENT_SECRETYesQQ Bot client secret.

Rich media

postMessage uploads local files (FileUpload) and URL attachments, then sends them as rich-media messages. Scenarios that don't support rich media fall back to text.

// Send a local file
await adapter.postMessage(threadId, {
  text: "Document",
  files: [
    {
      data: buffer,
      filename: "report.xlsx",
      mimeType: "application/vnd.ms-excel",
    },
  ],
});

Scenes

The adapter supports four QQ scenes: QQ DM (C2C), QQ Group, Text Channel, and Channel DM. File upload in group chats is not currently available. Text channels and channel DMs send images and videos via msg_type: 7.

Feature support

Messaging

FeatureSupported
Post message
Message replies
Edit message
Delete message
File uploads
Streaming
Scheduled messages

Rich content

FeatureSupported
Card format
Buttons
Link buttons
Select menus
Tables
Charts
Fields
Images in cards
Modals

Conversations

FeatureSupported
Slash commands
Mentions
Add reactions
Remove reactions
Typing indicator
Mark as read
Message edit events
Message delete events
DMs
Ephemeral messages
User lookup
Parent subject
Native client
Custom API endpoint

Message history

FeatureSupported
Fetch messages
Fetch single message
Fetch thread info
Fetch channel messages
List threads
Fetch channel info
Post channel message

On this page