~5 min read · 5 sections

Connect Telegram & QQ

Connect to your local companion via a Telegram bot or an official QQ bot; pay close attention to session allowlist authorization so replies don't silently fail after entering credentials.

On this page (5)▾

Telegram · Create a Bot and Enter Token

Make sure you can already receive normal model replies in the local terminal or desktop client before configuring external chat apps.

  1. Search for the official @BotFather in Telegram, send /newbot, follow the prompts to create a bot, and copy the HTTP API Token it gives you (this token acts as your bot's master key—never post it in public groups or screenshots);
  2. Run the gateway setup wizard in your terminal (Windows desktop users can also fill this in directly on the "Settings → Model & Channels" page):
bash
nyairo gateway setup

Choose Telegram and paste the token you just received. Under "Allowed Users," enter only your own numeric Telegram User ID (note: not your @username or display name). If the wizard automatically displays Detected your Telegram user ID, verify it is accurate and confirm.

Telegram · Bind DM Memory Permissions

To prevent strangers who stumble upon your bot from accessing your private memories, nyairo requires you to explicitly specify which direct-message session has permission to read and write long-term memory.

If you installed using the default one-line script (data stored in ~/.nyairo), run the snippet below and enter your numeric DM User ID when prompted to compute the corresponding session key:

bash
REL="$HOME/.local/share/nyairo/releases/v0.8.0"
PYTHONPATH="$REL:$REL/vendor/hermes" "$REL/vendor/hermes/.venv/bin/python" -c '
from gateway.config import Platform
from gateway.session import SessionSource, build_session_key
uid = input("Enter your numeric Telegram User ID: ").strip()
source = SessionSource(platform=Platform.TELEGRAM, chat_type="dm", chat_id=uid, user_id=uid)
print("Copy the session binding key below:")
print(build_session_key(source))
'

Copy the printed key, then open ~/.nyairo/chiyo/config.json:

bash
nano "$HOME/.nyairo/chiyo/config.json"

Keep all other fields in the file unchanged, and set the telegram array under gateway_bindings to the key you just generated (Windows desktop users can simply check the session allowlist at the bottom of "Settings → Model & Channels"):

json
{
  "gateway_bindings": {
    "telegram": ["PASTE_THE_SESSION_KEY_PRINTED_ABOVE"]
  }
}

Telegram · Start the Gateway and Verify

Save and exit, then run the gateway to keep it online:

bash
nyairo gateway run

Note that only one gateway process can poll a given bot token at a time; if you see a 409 Conflict error, it means two gateway instances are running simultaneously (for example, the desktop app's background gateway plus a manual terminal window)—just stop one of them.

Open Telegram on your phone and send a few messages to your bot to verify everything works:

  1. Send a casual greeting and confirm you receive a reply;
  2. Send /chiyo_status and confirm it returns module status (Memory: READY);
  3. Send /chiyo_memory list to confirm DM memory permissions are properly bound (an empty list on a fresh install is normal).

Official QQ Bot Setup & Two Essential Gotchas

The underlying gateway includes a built-in official QQ Bot (API v2) adapter. If you want to chat with your companion in a QQ DM, visit the QQ Open Platform (q.qq.com) to create a bot and obtain its AppID and AppSecret. Enter and save them under "Connect QQ" in the Windows desktop client's "Settings → Model & Channels" page—the gateway will restart and connect automatically, displaying the actual connection result from the gateway logs directly in the UI.

If you edit configuration files manually, or run into "it says connected, but never replies," double-check these two verified gotchas:

  1. The config key must be qqbot, not qq: Under gateway.platforms in config.yaml, the platform name is strictly qqbot. If you mistakenly type qq, the gateway silently ignores the entire section without printing even a single error line in the logs.
  2. AppID and AppSecret alone are not enough—you must allowlist the specific DM session: nyairo's privacy gate only admits DM keys explicitly authorized in gateway_bindings.qqbot (formatted as agent:main:qqbot:dm:YOUR_USER_ID). Before allowlisting, QQ messages reaching the gateway are quietly dropped—send one message to the bot first, then check off the newly appeared session in the desktop client's "Who Can Talk to Them" panel (or copy that key from the logs into chiyo/config.json) to start chatting normally.

Other Chat Platforms

  • Personal WeChat (Easiest): Requires no developer portal registration or complicated IDs—just scan a QR code with mobile WeChat. See the previous chapter, Connect WeChat.
  • Feishu (Lark) / WeCom / Discord, etc.: Although some third-party platform files exist in the underlying host codebase, we have not finished end-to-end testing of memory permission bindings and reconnect behavior for them, so they are not officially supported at this time.
Hit a setup snag or spot a doc issue?