> ## Documentation Index
> Fetch the complete documentation index at: https://kiro.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# WeCom

> Chat with Crew from WeCom (企业微信) through an AI bot. Outbound WebSocket, two credentials, configured user access.

Crew connects to WeCom (企业微信) through its AI-bot API over an outbound WebSocket. Create the bot in your WeCom admin console, drop in two values, and you're chatting. Replies stream back live.

**ℹ️ Info:** This is **WeCom (企业微信)**, the work edition. For personal WeChat (微信), see [WeChat (Weixin)](https://kiro.dev/docs/crew/interfaces/wechat.md).

## Setup

### From the dashboard (recommended)

1. In the WeCom admin console, open 应用管理 → AI 智能体 and create a bot. Note the **Bot ID** and **Secret** from its settings page.
2. Open **Settings → Messaging Channels → WeCom** in the dashboard
3. Paste the Bot ID and Secret
4. Add the userids you want to allow (every WeCom member has a `userid` / 账号)
5. Click **Save** — the gateway restarts and connects

Look for `WeCom WS connected and subscribed` in the status badge. Message the bot in WeCom.

### From the CLI

```bash
# Save credentials to ~/.kiro/crew/.env
echo "WECOM_BOT_ID=your-bot-id" >> ~/.kiro/crew/.env
echo "WECOM_SECRET=your-bot-secret" >> ~/.kiro/crew/.env
```

In `~/.kiro/crew/config.json`:

```json
{
  "wecom": {
    "enabled": true,
    "allowed_users": [{ "userid": "zhangsan", "name": "Zhang San" }]
  }
}
```

Then: `kirocrew restart`

Message the bot in WeCom. If it stays quiet, confirm your userid is allowed.

## Who can reach it

- **Owner** (`KIROCREW_OWNER_ID`) plus anyone in `allowed_users`
- **Whole-company access**: set `"allow_all_users": true` to skip individual listing — this is an explicit opt-in (an empty list never means "everyone")
- The WeCom AI bot carries direct messages only — one conversation per userid
- Anyone else is silently dropped and recorded in the audit log

## Send and receive files

Images, regular files, and voice notes sent to the bot reach the agent. WeCom supplies voice-note transcripts, while attached audio files are downloaded and transcribed locally. Inbound limits are 10 MB per image, 20 MB per file, and 10 items per message.

Files the agent sends through `file_send` or a dashboard upload arrive as native WeCom media. PNG and JPEG files arrive as pictures, MP4 and WebM files as videos, and other formats as downloads. Outbound pictures and voice notes are limited to 2 MB; files and videos are limited to 20 MB. A larger picture is delivered as a file instead of being dropped.

An image merely mentioned inline in a reply is not uploaded. Use `file_send` when the image itself should arrive.

## Commands

| Command | Effect |
|---|---|
| `/new` (or `新对话`, `清空`) | Start a fresh conversation |
| `/compact` | Compress context |

## Behavior notes

- The bot replies to messages — it can't start a conversation on its own
- No buttons — `OPTIONS` prompts arrive as plain text; just reply normally
- Only two values needed: Bot ID and Secret. No corp ID, agent ID, callback URL, or AES key

## Configuration

| Key | Default | Purpose |
|---|---|---|
| `wecom.enabled` | `false` | Turns the channel on |
| `wecom.allowed_users` | `[]` | `` entries (empty = owner only) |
| `wecom.allow_all_users` | `false` | Allow all organization members |
| `wecom.soft_threshold_pct` | `80` | Suggest `/compact` past this |
| `wecom.hard_threshold_pct` | `95` | Hard cutoff |
| `wecom.ws_url` | `wss://openws.work.weixin.qq.com` | WeCom AI-bot endpoint |

Credentials in `~/.kiro/crew/.env`: `WECOM_BOT_ID` and `WECOM_SECRET`.

## Troubleshooting

| Problem | Fix |
|---|---|
| No reply | Sender's userid isn't allowed or `enabled` is `false` |
| No `channel started` in logs | A credential is unset |
| Connects then goes quiet | Bot may have been removed from the WeCom console — re-add and restart |

## Next

- [WeChat (Weixin)](https://kiro.dev/docs/crew/interfaces/wechat.md) — personal WeChat via iLink
- [Telegram](https://kiro.dev/docs/crew/interfaces/telegram.md) — similar outbound model
- [Interfaces overview](https://kiro.dev/docs/crew/interfaces.md) — all surfaces at a glance
