> For the complete documentation index, see [llms.txt](https://doc.duaer.com/zh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.duaer.com/zh/advanced-ai/recipes/wecom-ai-auto-reply.md).

# 在 Duaer 里让 AI 自动回复企业微信应用消息

在 Duaer 里，成员给企业微信自建应用发消息，模型生成回复，再用应用消息发回给这个人。可以带上下文记忆。
## 在 Duaer 里搭自动回复

1. 按 [企业微信凭证](/zh/integrations/builtin/credentials/wecom.md) 建两条：消息接收凭证（Token、EncodingAESKey）和应用 API 凭证（Corp ID、AgentId、Secret）。
2. 加 [企业微信(WeCom)-消息接收触发器](/zh/integrations/builtin/trigger-nodes/duaer-nodes-wecom.wecomtrigger.md)，改名为 WeCom in，事件类型选「消息接收与发送-普通消息-文本消息」，设好 Path。
3. 发布后复制生产 Webhook URL，填到企业微信应用的接收消息 API 地址，按后台提示通过校验。
4. 接 [AI Agent](/zh/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent.md)，Chat Model 挂 [Duaer Chat Model](/zh/build/duaer-chat-model.md)，提示词用 {{ $json.Content }}，并写清身份和不能回答的范围。
5. 要记住上下文时，Memory 挂 [Simple Memory](/zh/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memorybufferwindow.md)，Session ID 选 Define below，Key 填 {{ $('WeCom in').item.json.FromUserName }}，每个人一段对话。
6. 接企业微信基础节点：资源选「应用消息」，操作选「[基础消息] 发送文本消息」，发送给谁选「手动输入」，成员 ID 填 {{ $('WeCom in').item.json.FromUserName }}，消息内容填 {{ $json.output }}。

## 为什么不用被动回复

被动回复要在 5 秒内答复，模型常常来不及。先收下消息，再用应用消息主动发回，不受这个限制。发送报 60020 时，见 [企业微信 60020 排查](/zh/troubleshooting/wecom-60020-ip-not-allowed.md)。

这页处理的是成员发给自建应用的消息。外部客户通过微信客服进来的会话，要用企业微信的客服接口。
## Questions

### Duaer 自动回复企业微信为什么不用被动回复？

企业微信被动回复限 5 秒内，模型常超时。Duaer 先接收，再用应用消息把回复主动发给发消息的人。

### Duaer 怎么让 AI 记住同一个人之前说的话？

在 Duaer AI Agent 上挂 Simple Memory，Key 用触发器里的 FromUserName，每个成员一段独立对话。

## 相关

- [在 Duaer 里用企业微信发消息](https://doc.duaer.com/zh/build/wecom.md)
- [在 Duaer 里解决企业微信 60020：IP 不在可信列表](https://doc.duaer.com/zh/troubleshooting/wecom-60020-ip-not-allowed.md)
- [在 Duaer Chat Model 里选模型](https://doc.duaer.com/zh/build/duaer-chat-model.md)

