# WeCom (Enterprise WeChat)

This guide covers setting up Qwen Code with a WeCom intelligent robot (企业微信智能机器人).

## Prerequisites

- A WeCom organization account
- A WeCom intelligent robot created in API mode
- The robot's Bot ID and Secret

## Creating the Robot

1. Open the WeCom admin console and create an intelligent robot.

![](https://gw.alicdn.com/imgextra/i2/O1CN017w1jWj1TTvNBcfya8_!!6000000002384-2-tps-2212-887.png)

2. Choose API mode.

![](https://gw.alicdn.com/imgextra/i3/O1CN01buuik0207paQUuLQW_!!6000000006803-1-tps-1276-720.gif)

3. Copy the Bot ID and Secret.
4. Add the robot to the direct chats or groups where it should be available.

The intelligent robot uses a WebSocket connection from Qwen Code to WeCom. You do not need a public callback URL, Token, EncodingAESKey, Corp ID, or Agent ID.

## Configuration

Add the channel to `~/.qwen/settings.json`:

```json
{
  "channels": {
    "my-wecom": {
      "type": "wecom",
      "botId": "$WECOM_BOT_ID",
      "secret": "$WECOM_SECRET",
      "senderPolicy": "allowlist",
      "allowedUsers": ["zhangsan"],
      "sessionScope": "user",
      "cwd": "/path/to/your/project",
      "instructions": "You are a concise coding assistant responding via WeCom.",
      "groupPolicy": "open"
    }
  }
}
```

Set the credentials as environment variables:

```bash
export WECOM_BOT_ID=<your-bot-id>
export WECOM_SECRET=<your-secret>
```

Or define them in the `env` section of `settings.json`:

```json
{
  "env": {
    "WECOM_BOT_ID": "your-bot-id",
    "WECOM_SECRET": "your-secret"
  }
}
```

## Running

```bash
qwen channel start my-wecom
```

Open WeCom and send a message to the intelligent robot.

## Access Control

`senderPolicy` works the same way as other IM channels:

- `allowlist`: only users in `allowedUsers` can use the bot. This is the recommended enterprise default.
- `pairing`: users must pair before using the bot.
- `open`: anyone who can message the robot can use it.

For groups, set `groupPolicy` to `"allowlist"` or `"open"`. WeCom only delivers group messages that mention the intelligent robot, so every delivered group callback is treated as mentioned. The `requireMention` setting cannot enable responses to unmentioned group messages because those messages are not delivered to the bot.

### Group Mention Compatibility

Earlier Qwen Code versions also applied the generic `requireMention` gate after WeCom delivered a group callback. Because the callback does not include separate mention metadata, `requireMention: true`—including the default value—could reject every delivered group message and make group chat appear nonfunctional.

Qwen Code now relies on WeCom's mention-scoped delivery and does not apply a second mention decision. Existing WeCom configurations containing either `requireMention: true` or `requireMention: false` remain valid and do not produce configuration errors. Both values have the same behavior for WeCom, so the field can be removed. Other settings in the same group entry, such as `dispatchMode`, continue to apply. `groupHistoryLimit` remains accepted but cannot collect new WeCom history because unmentioned group messages are not delivered.

## Images and Files

Users can send text, voice messages with transcription, images, mixed text plus images, files, and videos. Images are passed to the agent as image attachments. Files and videos are downloaded to temporary local paths so the agent can read them with file tools.

Assistant responses are sent as WeCom markdown. To send a local image generated by the agent, include one marker outside code blocks:

```text
[IMAGE: /absolute/path/to/image.png]
```

For safety, local image paths must be inside the channel file directory under the system temporary directory, such as `/tmp/channel-files/...` on Linux. Generic file, video, and voice upload markers are ignored because model-produced file paths could otherwise upload arbitrary workspace files.

## Troubleshooting

### Bot does not connect

- Verify the Bot ID and Secret.
- Make sure the robot is created in API mode.
- Check that the environment variables are available in the shell running `qwen channel start`.

### Bot does not respond in groups

- Check `groupPolicy`.
- Mention the bot in the group.
- Confirm the robot has been added to the group.

### Self-built application credentials do not work

This channel is for WeCom intelligent robots. Self-built application callback credentials such as Corp ID, Agent ID, Token, and EncodingAESKey are not used by this channel.
