# Connect the official QQ bot

Connect an official bot from the QQ Open Platform through webhooks and reply in private and group chats.

Besides signing in to a personal QQ account through [OneBot](https://shiritaibot.dev/en/docs/onebot), ShiritaiBot can connect to an official bot on the QQ Open Platform. An official bot doesn't need a QQ account of its own, but it does need an HTTPS domain reachable from the internet to receive callbacks.

## Create the bot

1. Create a bot on the [QQ Open Platform](https://q.qq.com/) and note its App ID and App Secret.
2. In the ShiritaiBot WebUI, open **Settings → Channels**, click **Add a bot**, choose **Official QQ bot**, enter the App ID and App Secret, then enable and save.

## Set the callback address

In the platform's event subscription and callback settings, enter the callback path shown on the channel's page, with your public HTTPS domain in front. For an instance with the ID `qq-official`:

```text Callback address
https://bot.example.com/api/adapters/qq-official/qq-official/callback
```

Then:

1. Forward that path to ShiritaiBot with a reverse proxy.
2. Add the domain to the allowed hosts when starting ShiritaiBot, for example `shiritaibot run --allowed-host bot.example.com`.
3. Subscribe to `C2C_MESSAGE_CREATE` (private chats) and `GROUP_AT_MESSAGE_CREATE` (group messages that @ the bot). If the platform has opened regular group messages for your app, you can also subscribe to `GROUP_MESSAGE_CREATE`.
4. If the platform asks for an IP allowlist, enter the outbound IP of the server running ShiritaiBot.

## Allowlist and owner

The official QQ API identifies private chat users, groups and group members by OpenID. Add the groups and users you allow to the channel's allowlist.

To find an OpenID, send a test message from that account or group, then switch to the Debug level in **Monitor → Logs** to see the OpenID of the chat that isn't set up yet.

Only the owner's private chat gets owner permissions; group chats follow the group's chat permissions. See [Permissions](https://shiritaibot.dev/en/docs/auth).

## Current limits

* Text messages in private and group chats, with passive replies. A reply is tied to the message it answers, within the platform's time and count limits.
* Incoming attachments show as placeholders in the text.
* Channels, media upload and proactive pushes aren't supported yet.

References: [Event subscription](https://bot.q.qq.com/wiki/develop/api-v2/dev-prepare/interface-framework/event-emit.html), [signature verification](https://bot.q.qq.com/wiki/develop/api-v2/dev-prepare/interface-framework/sign.html), [messaging overview](https://bot.q.qq.com/wiki/develop/api-v2/server-inter/message/overview.html).
