> For the complete documentation index, see [llms.txt](https://doc.duaer.com/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/advanced-ai/recipes/wecom-ai-auto-reply.md).

# Auto-reply to WeCom app messages with AI in Duaer

In Duaer, when a member messages a WeCom self-built app, a model writes the reply and Duaer sends it back as an app message, optionally with memory.
## Build the auto-reply in Duaer

1. Create two credentials per [WeCom credentials in Duaer](/integrations/builtin/credentials/wecom.md): message receive (Token, EncodingAESKey) and app API (Corp ID, AgentId, Secret).
2. Add the [WeCom message receive trigger](/integrations/builtin/trigger-nodes/duaer-nodes-wecom.wecomtrigger.md), rename it WeCom in, select the text message event type, and set Path.
3. Publish, copy the production webhook URL into the WeCom app message receive API URL, and pass the console check.
4. Add an [AI Agent](/integrations/builtin/cluster-nodes/root-nodes/n8n-nodes-langchain.agent.md) with [Duaer Chat Model](/build/duaer-chat-model.md), a prompt using {{ $json.Content }}, and a clear role and scope.
5. For memory, attach [Simple Memory](/integrations/builtin/cluster-nodes/sub-nodes/n8n-nodes-langchain.memorybufferwindow.md) with Session ID Define below and Key {{ $('WeCom in').item.json.FromUserName }}, one conversation per person.
6. Add the WeCom base node: app message resource, send text operation, manual recipient, member ID {{ $('WeCom in').item.json.FromUserName }}, content {{ $json.output }}.

## Why not a passive reply

A passive reply must answer within 5 seconds, which a model often misses. Receiving first and sending an app message afterwards avoids that limit. If sending returns 60020, refer to [Fix WeCom 60020 in Duaer](/troubleshooting/wecom-60020-ip-not-allowed.md).

This page covers members messaging a self-built app. Outside customers arriving through WeChat customer service use the WeCom customer service APIs.
## Questions

### Why does the Duaer WeCom auto-reply skip passive replies?

WeCom passive replies must arrive within 5 seconds and models often miss it. Duaer receives first, then sends the reply as an app message.

### How does Duaer remember what the same person said before?

Attach Simple Memory to the Duaer AI Agent with Key set to FromUserName from the trigger, one conversation per member.

## Related

- [Send a WeCom message in Duaer](https://doc.duaer.com/build/wecom.md)
- [Fix WeCom error 60020 (IP not allowed) in Duaer](https://doc.duaer.com/troubleshooting/wecom-60020-ip-not-allowed.md)
- [Pick a model in Duaer Chat Model](https://doc.duaer.com/build/duaer-chat-model.md)

