Wechat Official Account Response icon

Wechat Official Account Response

Wechat Official Account Response

Overview

This node, named "Wechat Official Account Response," is designed to send a response back to a Wechat Official Account trigger within an n8n workflow. It is typically used in scenarios where you want to reply to messages or events received from a Wechat Official Account, allowing you to customize the response content and format.

Common use cases include:

  • Responding to user messages with custom XML or JSON payloads.
  • Sending encrypted responses if the Wechat account uses AES encryption.
  • Integrating Wechat Official Account interactions into automated workflows.

For example, after receiving a message via a Wechat Official Account Trigger node, this node can be used to send a formatted XML or JSON response that complies with Wechat's messaging protocol.

Properties

Name Meaning
响应数据格式 (dataFormat) The format of the response data. Options: XML or JSON.
响应数据 (content) The actual response content to send back. This is a required multiline string input. The field shown depends on the selected data format (XML or JSON).

Output

The node outputs a JSON array containing one item with the following structure:

  • If AES encryption is enabled, the output contains the encrypted response content.
  • Otherwise, it returns the raw response content as provided.

The output JSON object has a content property holding the response data string.

Additionally, the node sends an HTTP response directly with:

  • Status code 200.
  • Content-Type header set according to the chosen data format (application/xml; charset=utf-8 or application/json; charset=utf-8).
  • Body containing either the XML string or parsed JSON object.

If AES encryption is used, the XML response is wrapped in CDATA sections for text nodes.

Dependencies

  • Requires a connected Wechat Official Account Trigger node upstream in the workflow to function properly.
  • Uses an external utility module for encrypting responses when AES encryption is configured.
  • Uses an XML-to-JS conversion library to convert JS objects to XML strings when needed.

Troubleshooting

  • Error: No connected Wechat Official Account Trigger node found
    This error occurs if the node is not connected to a Wechat Official Account Trigger node. Ensure your workflow includes such a trigger node before this response node.

  • Error: No workflow data found
    Indicates missing static workflow data necessary for encryption or configuration. Verify that the workflow context is correctly set up and that required credentials or keys are available.

  • Malformed XML or JSON response
    Make sure the response content entered matches the selected data format and is well-formed. Invalid XML or JSON may cause errors downstream.

  • Encryption issues
    If AES encryption is enabled but the response is not correctly encrypted or fails, check that the token, AES key, and App ID are correctly configured in the workflow's static data.

Links and References

Discussion