| 1 | # Chat Apps |
| 2 | |
| 3 | Connect nanobot to your favorite chat platform. Want to build your own? See the [Channel Plugin Guide](./channel-plugin-guide.md). |
| 4 | |
| 5 | | Channel | What you need | |
| 6 | |---------|---------------| |
| 7 | | **Telegram** | Bot token from @BotFather | |
| 8 | | **Discord** | Bot token + Message Content intent | |
| 9 | | **WhatsApp** | QR code scan (`nanobot channels login whatsapp`) | |
| 10 | | **WeChat (Weixin)** | QR code scan (`nanobot channels login weixin`) | |
| 11 | | **Feishu** | App ID + App Secret | |
| 12 | | **DingTalk** | App Key + App Secret | |
| 13 | | **Slack** | Bot token + App-Level token | |
| 14 | | **Matrix** | Homeserver URL + Access token | |
| 15 | | **Email** | IMAP/SMTP credentials | |
| 16 | | **QQ** | App ID + App Secret | |
| 17 | | **Wecom** | Bot ID + Bot Secret | |
| 18 | | **Microsoft Teams** | App ID + App Password + public HTTPS endpoint | |
| 19 | | **Mochat** | Claw token (auto-setup available) | |
| 20 | |
| 21 | <details> |
| 22 | <summary><b>Telegram</b> (Recommended)</summary> |
| 23 | |
| 24 | **1. Create a bot** |
| 25 | - Open Telegram, search `@BotFather` |
| 26 | - Send `/newbot`, follow prompts |
| 27 | - Copy the token |
| 28 | |
| 29 | **2. Configure** |
| 30 | |
| 31 | ```json |
| 32 | { |
| 33 | "channels": { |
| 34 | "telegram": { |
| 35 | "enabled": true, |
| 36 | "token": "YOUR_BOT_TOKEN", |
| 37 | "allowFrom": ["YOUR_USER_ID"] |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 | ``` |
| 42 | |
| 43 | > You can find your **User ID** in Telegram settings. It is shown as `@yourUserId`. |
| 44 | > Copy this value **without the `@` symbol** and paste it into the config file. |
| 45 | |
| 46 | |
| 47 | **3. Run** |
| 48 | |
| 49 | ```bash |
| 50 | nanobot gateway |
| 51 | ``` |
| 52 | |
| 53 | </details> |
| 54 | |
| 55 | <details> |
| 56 | <summary><b>Mochat (Claw IM)</b></summary> |
| 57 | |
| 58 | Uses **Socket.IO WebSocket** by default, with HTTP polling fallback. |
| 59 | |
| 60 | **1. Ask nanobot to set up Mochat for you** |
| 61 | |
| 62 | Simply send this message to nanobot (replace `xxx@xxx` with your real email): |
| 63 | |
| 64 | ``` |
| 65 | Read https://raw.githubusercontent.com/HKUDS/MoChat/refs/heads/main/skills/nanobot/skill.md and register on MoChat. My Email account is xxx@xxx Bind me as your owner and DM me on MoChat. |
| 66 | ``` |
| 67 | |
| 68 | nanobot will automatically register, configure `~/.nanobot/config.json`, and connect to Mochat. |
| 69 | |
| 70 | **2. Restart gateway** |
| 71 | |
| 72 | ```bash |
| 73 | nanobot gateway |
| 74 | ``` |
| 75 | |
| 76 | That's it — nanobot handles the rest! |
| 77 | |
| 78 | <br> |
| 79 | |
| 80 | <details> |
| 81 | <summary>Manual configuration (advanced)</summary> |
| 82 | |
| 83 | If you prefer to configure manually, add the following to `~/.nanobot/config.json`: |
| 84 | |
| 85 | > Keep `claw_token` private. It should only be sent in `X-Claw-Token` header to your Mochat API endpoint. |
| 86 | |
| 87 | ```json |
| 88 | { |
| 89 | "channels": { |
| 90 | "mochat": { |
| 91 | "enabled": true, |
| 92 | "base_url": "https://mochat.io", |
| 93 | "socket_url": "https://mochat.io", |
| 94 | "socket_path": "/socket.io", |
| 95 | "claw_token": "claw_xxx", |
| 96 | "agent_user_id": "6982abcdef", |
| 97 | "sessions": ["*"], |
| 98 | "panels": ["*"], |
| 99 | "reply_delay_mode": "non-mention", |
| 100 | "reply_delay_ms": 120000 |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | ``` |
| 105 | |
| 106 | |
| 107 | |
| 108 | </details> |
| 109 | |
| 110 | </details> |
| 111 | |
| 112 | <details> |
| 113 | <summary><b>Discord</b></summary> |
| 114 | |
| 115 | **1. Create a bot** |
| 116 | - Go to https://discord.com/developers/applications |
| 117 | - Create an application → Bot → Add Bot |
| 118 | - Copy the bot token |
| 119 | |
| 120 | **2. Enable intents** |
| 121 | - In the Bot settings, enable **MESSAGE CONTENT INTENT** |
| 122 | - (Optional) Enable **SERVER MEMBERS INTENT** if you plan to use allow lists based on member data |
| 123 | |
| 124 | **3. Get your User ID** |
| 125 | - Discord Settings → Advanced → enable **Developer Mode** |
| 126 | - Right-click your avatar → **Copy User ID** |
| 127 | |
| 128 | **4. Configure** |
| 129 | |
| 130 | ```json |
| 131 | { |
| 132 | "channels": { |
| 133 | "discord": { |
| 134 | "enabled": true, |
| 135 | "token": "YOUR_BOT_TOKEN", |
| 136 | "allowFrom": ["YOUR_USER_ID"], |
| 137 | "allowChannels": [], |
| 138 | "groupPolicy": "mention", |
| 139 | "streaming": true |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | ``` |
| 144 | |
| 145 | > `groupPolicy` controls how the bot responds in group channels: |
| 146 | > - `"mention"` (default) — Only respond when @mentioned |
| 147 | > - `"open"` — Respond to all messages |
| 148 | > DMs always respond when the sender is in `allowFrom`. |
| 149 | > - If you set group policy to open create new threads as private threads and then @ the bot into it. Otherwise the thread itself and the channel in which you spawned it will spawn a bot session. |
| 150 | > `allowChannels` restricts the bot to specific Discord channel IDs. Empty (default) means respond in every channel the bot can see. Example: `["1234567890", "0987654321"]`. The filter applies after `allowFrom`, so both must pass. |
| 151 | > `streaming` defaults to `true`. Disable it only if you explicitly want non-streaming replies. |
| 152 | |
| 153 | **5. Invite the bot** |
| 154 | - OAuth2 → URL Generator |
| 155 | - Scopes: `bot` |
| 156 | - Bot Permissions: `Send Messages`, `Read Message History` |
| 157 | - Open the generated invite URL and add the bot to your server |
| 158 | |
| 159 | **6. Run** |
| 160 | |
| 161 | ```bash |
| 162 | nanobot gateway |
| 163 | ``` |
| 164 | |
| 165 | </details> |
| 166 | |
| 167 | <details> |
| 168 | <summary><b>Matrix (Element)</b></summary> |
| 169 | |
| 170 | Install Matrix dependencies first: |
| 171 | |
| 172 | ```bash |
| 173 | pip install echo-director-agent[matrix] |
| 174 | ``` |
| 175 | |
| 176 | > [!NOTE] |
| 177 | > Matrix is not supported on Windows. `matrix-nio[e2e]` depends on |
| 178 | > `python-olm`, which has no pre-built Windows wheel and is skipped by the |
| 179 | > `matrix` extra on `sys_platform == 'win32'`. The command above will still |
| 180 | > succeed on Windows but without `matrix-nio` installed, so enabling the |
| 181 | > Matrix channel will fail at startup. Use macOS, Linux, or WSL2. |
| 182 | |
| 183 | **1. Create/choose a Matrix account** |
| 184 | |
| 185 | - Create or reuse a Matrix account on your homeserver (for example `matrix.org`). |
| 186 | - Confirm you can log in with Element. |
| 187 | |
| 188 | **2. Get credentials** |
| 189 | |
| 190 | - You need: |
| 191 | - `userId` (example: `@nanobot:matrix.org`) |
| 192 | - `password` |
| 193 | |
| 194 | (Note: `accessToken` and `deviceId` are still supported for legacy reasons, but |
| 195 | for reliable encryption, password login is recommended instead. If the |
| 196 | `password` is provided, `accessToken` and `deviceId` will be ignored.) |
| 197 | |
| 198 | **3. Configure** |
| 199 | |
| 200 | ```json |
| 201 | { |
| 202 | "channels": { |
| 203 | "matrix": { |
| 204 | "enabled": true, |
| 205 | "homeserver": "https://matrix.org", |
| 206 | "userId": "@nanobot:matrix.org", |
| 207 | "password": "mypasswordhere", |
| 208 | "e2eeEnabled": true, |
| 209 | "allowFrom": ["@your_user:matrix.org"], |
| 210 | "groupPolicy": "open", |
| 211 | "groupAllowFrom": [], |
| 212 | "allowRoomMentions": false, |
| 213 | "maxMediaBytes": 20971520 |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | ``` |
| 218 | |
| 219 | > Keep a persistent `matrix-store` — encrypted session state is lost if these change across restarts. |
| 220 | |
| 221 | | Option | Description | |
| 222 | |--------|-------------| |
| 223 | | `allowFrom` | User IDs allowed to interact. Empty denies all; use `["*"]` to allow everyone. | |
| 224 | | `groupPolicy` | `open` (default), `mention`, or `allowlist`. | |
| 225 | | `groupAllowFrom` | Room allowlist (used when policy is `allowlist`). | |
| 226 | | `allowRoomMentions` | Accept `@room` mentions in mention mode. | |
| 227 | | `e2eeEnabled` | E2EE support (default `true`). Set `false` for plaintext-only. | |
| 228 | | `maxMediaBytes` | Max attachment size (default `20MB`). Set `0` to block all media. | |
| 229 | |
| 230 | |
| 231 | |
| 232 | |
| 233 | **4. Run** |
| 234 | |
| 235 | ```bash |
| 236 | nanobot gateway |
| 237 | ``` |
| 238 | |
| 239 | </details> |
| 240 | |
| 241 | <details> |
| 242 | <summary><b>WhatsApp</b></summary> |
| 243 | |
| 244 | Requires **Node.js ≥18**. |
| 245 | |
| 246 | **1. Link device** |
| 247 | |
| 248 | ```bash |
| 249 | nanobot channels login whatsapp |
| 250 | # Scan QR with WhatsApp → Settings → Linked Devices |
| 251 | ``` |
| 252 | |
| 253 | **2. Configure** |
| 254 | |
| 255 | ```json |
| 256 | { |
| 257 | "channels": { |
| 258 | "whatsapp": { |
| 259 | "enabled": true, |
| 260 | "allowFrom": ["+1234567890"] |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | ``` |
| 265 | |
| 266 | **3. Run** (two terminals) |
| 267 | |
| 268 | ```bash |
| 269 | # Terminal 1 |
| 270 | nanobot channels login whatsapp |
| 271 | |
| 272 | # Terminal 2 |
| 273 | nanobot gateway |
| 274 | ``` |
| 275 | |
| 276 | > WhatsApp bridge updates are not applied automatically for existing installations. |
| 277 | > After upgrading nanobot, rebuild the local bridge with: |
| 278 | > `rm -rf ~/.nanobot/bridge && nanobot channels login whatsapp` |
| 279 | |
| 280 | </details> |
| 281 | |
| 282 | <details> |
| 283 | <summary><b>Feishu</b></summary> |
| 284 | |
| 285 | Uses **WebSocket** long connection — no public IP required. |
| 286 | |
| 287 | **1. Create a Feishu bot** |
| 288 | - Visit [Feishu Open Platform](https://open.feishu.cn/app) |
| 289 | - Create a new app → Enable **Bot** capability |
| 290 | - **Permissions**: |
| 291 | - `im:message` (send messages) and `im:message.p2p_msg:readonly` (receive messages) |
| 292 | - **Streaming replies** (default in nanobot): add **`cardkit:card:write`** (often labeled **Create and update cards** in the Feishu developer console). Required for CardKit entities and streamed assistant text. Older apps may not have it yet — open **Permission management**, enable the scope, then **publish** a new app version if the console requires it. |
| 293 | - If you **cannot** add `cardkit:card:write`, set `"streaming": false` under `channels.feishu` (see below). The bot still works; replies use normal interactive cards without token-by-token streaming. |
| 294 | - **Events**: Add `im.message.receive_v1` (receive messages) |
| 295 | - Select **Long Connection** mode (requires running nanobot first to establish connection) |
| 296 | - Get **App ID** and **App Secret** from "Credentials & Basic Info" |
| 297 | - Publish the app |
| 298 | |
| 299 | **2. Configure** |
| 300 | |
| 301 | ```json |
| 302 | { |
| 303 | "channels": { |
| 304 | "feishu": { |
| 305 | "enabled": true, |
| 306 | "appId": "cli_xxx", |
| 307 | "appSecret": "xxx", |
| 308 | "encryptKey": "", |
| 309 | "verificationToken": "", |
| 310 | "allowFrom": ["ou_YOUR_OPEN_ID"], |
| 311 | "groupPolicy": "mention", |
| 312 | "reactEmoji": "OnIt", |
| 313 | "doneEmoji": "DONE", |
| 314 | "toolHintPrefix": "🔧", |
| 315 | "streaming": true, |
| 316 | "domain": "feishu" |
| 317 | } |
| 318 | } |
| 319 | } |
| 320 | ``` |
| 321 | |
| 322 | > `streaming` defaults to `true`. Use `false` if your app does not have **`cardkit:card:write`** (see permissions above). |
| 323 | > `encryptKey` and `verificationToken` are optional for Long Connection mode. |
| 324 | > `allowFrom`: Add your open_id (find it in nanobot logs when you message the bot). Use `["*"]` to allow all users. |
| 325 | > `groupPolicy`: `"mention"` (default — respond only when @mentioned), `"open"` (respond to all group messages). Private chats always respond. |
| 326 | > `reactEmoji`: Emoji for "processing" status (default: `OnIt`). See [available emojis](https://open.larkoffice.com/document/server-docs/im-v1/message-reaction/emojis-introduce). |
| 327 | > `doneEmoji`: Optional emoji for "completed" status (e.g., `DONE`, `OK`, `HEART`). When set, bot adds this reaction after removing `reactEmoji`. |
| 328 | > `toolHintPrefix`: Prefix for inline tool hints in streaming cards (default: `🔧`). |
| 329 | > `domain`: `"feishu"` (default) for China (open.feishu.cn), `"lark"` for international Lark (open.larksuite.com). |
| 330 | |
| 331 | **3. Run** |
| 332 | |
| 333 | ```bash |
| 334 | nanobot gateway |
| 335 | ``` |
| 336 | |
| 337 | > [!TIP] |
| 338 | > Feishu uses WebSocket to receive messages — no webhook or public IP needed! |
| 339 | |
| 340 | </details> |
| 341 | |
| 342 | <details> |
| 343 | <summary><b>QQ (QQ单聊)</b></summary> |
| 344 | |
| 345 | Uses **botpy SDK** with WebSocket — no public IP required. Currently supports **private messages only**. |
| 346 | |
| 347 | **1. Register & create bot** |
| 348 | - Visit [QQ Open Platform](https://q.qq.com) → Register as a developer (personal or enterprise) |
| 349 | - Create a new bot application |
| 350 | - Go to **开发设置 (Developer Settings)** → copy **AppID** and **AppSecret** |
| 351 | |
| 352 | **2. Set up sandbox for testing** |
| 353 | - In the bot management console, find **沙箱配置 (Sandbox Config)** |
| 354 | - Under **在消息列表配置**, click **添加成员** and add your own QQ number |
| 355 | - Once added, scan the bot's QR code with mobile QQ → open the bot profile → tap "发消息" to start chatting |
| 356 | |
| 357 | **3. Configure** |
| 358 | |
| 359 | > - `allowFrom`: Add your openid (find it in nanobot logs when you message the bot). Use `["*"]` for public access. |
| 360 | > - `msgFormat`: Optional. Use `"plain"` (default) for maximum compatibility with legacy QQ clients, or `"markdown"` for richer formatting on newer clients. |
| 361 | > - For production: submit a review in the bot console and publish. See [QQ Bot Docs](https://bot.q.qq.com/wiki/) for the full publishing flow. |
| 362 | |
| 363 | ```json |
| 364 | { |
| 365 | "channels": { |
| 366 | "qq": { |
| 367 | "enabled": true, |
| 368 | "appId": "YOUR_APP_ID", |
| 369 | "secret": "YOUR_APP_SECRET", |
| 370 | "allowFrom": ["YOUR_OPENID"], |
| 371 | "msgFormat": "plain" |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | ``` |
| 376 | |
| 377 | **4. Run** |
| 378 | |
| 379 | ```bash |
| 380 | nanobot gateway |
| 381 | ``` |
| 382 | |
| 383 | Now send a message to the bot from QQ — it should respond! |
| 384 | |
| 385 | </details> |
| 386 | |
| 387 | <details> |
| 388 | <summary><b>DingTalk (钉钉)</b></summary> |
| 389 | |
| 390 | Uses **Stream Mode** — no public IP required. |
| 391 | |
| 392 | **1. Create a DingTalk bot** |
| 393 | - Visit [DingTalk Open Platform](https://open-dev.dingtalk.com/) |
| 394 | - Create a new app -> Add **Robot** capability |
| 395 | - **Configuration**: |
| 396 | - Toggle **Stream Mode** ON |
| 397 | - **Permissions**: Add necessary permissions for sending messages |
| 398 | - Get **AppKey** (Client ID) and **AppSecret** (Client Secret) from "Credentials" |
| 399 | - Publish the app |
| 400 | |
| 401 | **2. Configure** |
| 402 | |
| 403 | ```json |
| 404 | { |
| 405 | "channels": { |
| 406 | "dingtalk": { |
| 407 | "enabled": true, |
| 408 | "clientId": "YOUR_APP_KEY", |
| 409 | "clientSecret": "YOUR_APP_SECRET", |
| 410 | "allowFrom": ["YOUR_STAFF_ID"] |
| 411 | } |
| 412 | } |
| 413 | } |
| 414 | ``` |
| 415 | |
| 416 | > `allowFrom`: Add your staff ID. Use `["*"]` to allow all users. |
| 417 | |
| 418 | **3. Run** |
| 419 | |
| 420 | ```bash |
| 421 | nanobot gateway |
| 422 | ``` |
| 423 | |
| 424 | </details> |
| 425 | |
| 426 | <details> |
| 427 | <summary><b>Slack</b></summary> |
| 428 | |
| 429 | Uses **Socket Mode** — no public URL required. |
| 430 | |
| 431 | **1. Create a Slack app** |
| 432 | - Go to [Slack API](https://api.slack.com/apps) → **Create New App** → "From scratch" |
| 433 | - Pick a name and select your workspace |
| 434 | |
| 435 | **2. Configure the app** |
| 436 | - **Socket Mode**: Toggle ON → Generate an **App-Level Token** with `connections:write` scope → copy it (`xapp-...`) |
| 437 | - **OAuth & Permissions**: Add bot scopes: `chat:write`, `reactions:write`, `app_mentions:read` |
| 438 | - **Event Subscriptions**: Toggle ON → Subscribe to bot events: `message.im`, `message.channels`, `app_mention` → Save Changes |
| 439 | - **App Home**: Scroll to **Show Tabs** → Enable **Messages Tab** → Check **"Allow users to send Slash commands and messages from the messages tab"** |
| 440 | - **Install App**: Click **Install to Workspace** → Authorize → copy the **Bot Token** (`xoxb-...`) |
| 441 | |
| 442 | **3. Configure nanobot** |
| 443 | |
| 444 | ```json |
| 445 | { |
| 446 | "channels": { |
| 447 | "slack": { |
| 448 | "enabled": true, |
| 449 | "botToken": "xoxb-...", |
| 450 | "appToken": "xapp-...", |
| 451 | "allowFrom": ["YOUR_SLACK_USER_ID"], |
| 452 | "groupPolicy": "mention" |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | ``` |
| 457 | |
| 458 | **4. Run** |
| 459 | |
| 460 | ```bash |
| 461 | nanobot gateway |
| 462 | ``` |
| 463 | |
| 464 | DM the bot directly or @mention it in a channel — it should respond! |
| 465 | |
| 466 | > [!TIP] |
| 467 | > - `groupPolicy`: `"mention"` (default — respond only when @mentioned), `"open"` (respond to all channel messages), or `"allowlist"` (restrict to specific channels). |
| 468 | > - DM policy defaults to open. Set `"dm": {"enabled": false}` to disable DMs. |
| 469 | |
| 470 | </details> |
| 471 | |
| 472 | <details> |
| 473 | <summary><b>Email</b></summary> |
| 474 | |
| 475 | Give nanobot its own email account. It polls **IMAP** for incoming mail and replies via **SMTP** — like a personal email assistant. |
| 476 | |
| 477 | **1. Get credentials (Gmail example)** |
| 478 | - Create a dedicated Gmail account for your bot (e.g. `my-nanobot@gmail.com`) |
| 479 | - Enable 2-Step Verification → Create an [App Password](https://myaccount.google.com/apppasswords) |
| 480 | - Use this app password for both IMAP and SMTP |
| 481 | |
| 482 | **2. Configure** |
| 483 | |
| 484 | > - `consentGranted` must be `true` to allow mailbox access. This is a safety gate — set `false` to fully disable. |
| 485 | > - `allowFrom`: Add your email address. Use `["*"]` to accept emails from anyone. |
| 486 | > - `smtpUseTls` and `smtpUseSsl` default to `true` / `false` respectively, which is correct for Gmail (port 587 + STARTTLS). No need to set them explicitly. |
| 487 | > - Set `"autoReplyEnabled": false` if you only want to read/analyze emails without sending automatic replies. |
| 488 | > - `allowedAttachmentTypes`: Save inbound attachments matching these MIME types — `["*"]` for all, e.g. `["application/pdf", "image/*"]` (default `[]` = disabled). |
| 489 | > - `maxAttachmentSize`: Max size per attachment in bytes (default `2000000` / 2MB). |
| 490 | > - `maxAttachmentsPerEmail`: Max attachments to save per email (default `5`). |
| 491 | |
| 492 | ```json |
| 493 | { |
| 494 | "channels": { |
| 495 | "email": { |
| 496 | "enabled": true, |
| 497 | "consentGranted": true, |
| 498 | "imapHost": "imap.gmail.com", |
| 499 | "imapPort": 993, |
| 500 | "imapUsername": "my-nanobot@gmail.com", |
| 501 | "imapPassword": "your-app-password", |
| 502 | "smtpHost": "smtp.gmail.com", |
| 503 | "smtpPort": 587, |
| 504 | "smtpUsername": "my-nanobot@gmail.com", |
| 505 | "smtpPassword": "your-app-password", |
| 506 | "fromAddress": "my-nanobot@gmail.com", |
| 507 | "allowFrom": ["your-real-email@gmail.com"], |
| 508 | "allowedAttachmentTypes": ["application/pdf", "image/*"] |
| 509 | } |
| 510 | } |
| 511 | } |
| 512 | ``` |
| 513 | |
| 514 | |
| 515 | **3. Run** |
| 516 | |
| 517 | ```bash |
| 518 | nanobot gateway |
| 519 | ``` |
| 520 | |
| 521 | </details> |
| 522 | |
| 523 | <details> |
| 524 | <summary><b>WeChat (微信 / Weixin)</b></summary> |
| 525 | |
| 526 | Uses **HTTP long-poll** with QR-code login via the ilinkai personal WeChat API. No local WeChat desktop client is required. |
| 527 | |
| 528 | **1. Install with WeChat support** |
| 529 | |
| 530 | ```bash |
| 531 | pip install "echo-director-agent[weixin]" |
| 532 | ``` |
| 533 | |
| 534 | **2. Configure** |
| 535 | |
| 536 | ```json |
| 537 | { |
| 538 | "channels": { |
| 539 | "weixin": { |
| 540 | "enabled": true, |
| 541 | "allowFrom": ["YOUR_WECHAT_USER_ID"] |
| 542 | } |
| 543 | } |
| 544 | } |
| 545 | ``` |
| 546 | |
| 547 | > - `allowFrom`: Add the sender ID you see in nanobot logs for your WeChat account. Use `["*"]` to allow all users. |
| 548 | > - `token`: Optional. If omitted, log in interactively and nanobot will save the token for you. |
| 549 | > - `routeTag`: Optional. When your upstream Weixin deployment requires request routing, nanobot will send it as the `SKRouteTag` header. |
| 550 | > - `stateDir`: Optional. Defaults to nanobot's runtime directory for Weixin state. |
| 551 | > - `pollTimeout`: Optional long-poll timeout in seconds. |
| 552 | |
| 553 | **3. Login** |
| 554 | |
| 555 | ```bash |
| 556 | nanobot channels login weixin |
| 557 | ``` |
| 558 | |
| 559 | Use `--force` to re-authenticate and ignore any saved token: |
| 560 | |
| 561 | ```bash |
| 562 | nanobot channels login weixin --force |
| 563 | ``` |
| 564 | |
| 565 | **4. Run** |
| 566 | |
| 567 | ```bash |
| 568 | nanobot gateway |
| 569 | ``` |
| 570 | |
| 571 | </details> |
| 572 | |
| 573 | <details> |
| 574 | <summary><b>Wecom (企业微信)</b></summary> |
| 575 | |
| 576 | > Here we use [wecom-aibot-sdk-python](https://github.com/chengyongru/wecom_aibot_sdk) (community Python version of the official [@wecom/aibot-node-sdk](https://www.npmjs.com/package/@wecom/aibot-node-sdk)). |
| 577 | > |
| 578 | > Uses **WebSocket** long connection — no public IP required. |
| 579 | |
| 580 | **1. Install the optional dependency** |
| 581 | |
| 582 | ```bash |
| 583 | pip install echo-director-agent[wecom] |
| 584 | ``` |
| 585 | |
| 586 | **2. Create a WeCom AI Bot** |
| 587 | |
| 588 | Go to the WeCom admin console → Intelligent Robot → Create Robot → select **API mode** with **long connection**. Copy the Bot ID and Secret. |
| 589 | |
| 590 | **3. Configure** |
| 591 | |
| 592 | ```json |
| 593 | { |
| 594 | "channels": { |
| 595 | "wecom": { |
| 596 | "enabled": true, |
| 597 | "botId": "your_bot_id", |
| 598 | "secret": "your_bot_secret", |
| 599 | "allowFrom": ["your_id"] |
| 600 | } |
| 601 | } |
| 602 | } |
| 603 | ``` |
| 604 | |
| 605 | **4. Run** |
| 606 | |
| 607 | ```bash |
| 608 | nanobot gateway |
| 609 | ``` |
| 610 | |
| 611 | </details> |
| 612 | |
| 613 | <details> |
| 614 | <summary><b>Microsoft Teams</b> (MVP — DM only)</summary> |
| 615 | |
| 616 | > Direct-message text in/out, tenant-aware OAuth, conversation reference persistence. |
| 617 | > Uses a public HTTPS webhook — no WebSocket; you need a tunnel or reverse proxy. |
| 618 | |
| 619 | **1. Install the optional dependency** |
| 620 | |
| 621 | ```bash |
| 622 | pip install echo-director-agent[msteams] |
| 623 | ``` |
| 624 | |
| 625 | **2. Create a Teams / Azure bot app registration** |
| 626 | |
| 627 | Create or reuse a Microsoft Teams / Azure bot app registration. Set the bot messaging endpoint to a public HTTPS URL ending in `/api/messages`. |
| 628 | |
| 629 | **3. Configure** |
| 630 | |
| 631 | ```json |
| 632 | { |
| 633 | "channels": { |
| 634 | "msteams": { |
| 635 | "enabled": true, |
| 636 | "appId": "YOUR_APP_ID", |
| 637 | "appPassword": "YOUR_APP_SECRET", |
| 638 | "tenantId": "YOUR_TENANT_ID", |
| 639 | "host": "0.0.0.0", |
| 640 | "port": 3978, |
| 641 | "path": "/api/messages", |
| 642 | "allowFrom": ["*"], |
| 643 | "replyInThread": true, |
| 644 | "mentionOnlyResponse": "Hi — what can I help with?", |
| 645 | "validateInboundAuth": true |
| 646 | } |
| 647 | } |
| 648 | } |
| 649 | ``` |
| 650 | |
| 651 | > - `replyInThread: true` replies to the triggering Teams activity when a stored `activity_id` is available. |
| 652 | > - `mentionOnlyResponse` controls what Nanobot receives when a user sends only a bot mention (`<at>Nanobot</at>`). Set to `""` to ignore mention-only messages. |
| 653 | > - `validateInboundAuth: true` enables inbound Bot Framework bearer-token validation (signature, issuer, audience, lifetime, `serviceUrl`). This is the safe default for public deployments. Only set it to `false` for local development or tightly controlled testing. |
| 654 | |
| 655 | **4. Run** |
| 656 | |
| 657 | ```bash |
| 658 | nanobot gateway |
| 659 | ``` |
| 660 | |
| 661 | </details> |
| 662 |