Overview
This node is a webhook trigger designed to handle events from Zalo Official Account (OA). It listens for various user interactions and system events sent by Zalo OA via HTTP POST requests. The node verifies the authenticity of incoming requests using a MAC signature and filters events based on user selection.
Common scenarios where this node is beneficial include:
- Automating responses or workflows when users follow or unfollow a Zalo OA.
- Processing different types of messages sent by users, such as text, images, files, locations, stickers, GIFs.
- Tracking user interactions with message buttons or links.
- Receiving all event types for comprehensive monitoring or analytics.
Practical examples:
- Automatically sending a welcome message when a user follows the OA.
- Logging or analyzing user-sent media like images or files.
- Triggering specific workflows when users click buttons in messages.
- Filtering only certain event types to reduce workflow executions.
Properties
| Name | Meaning |
|---|---|
| OA Secret Key | The secret key obtained from the Zalo OA management page, used to verify request authenticity. |
| Các Loại Sự Kiện (Events) | The types of events to receive from Zalo OA. Options include: - Người Dùng Follow OA (follow) - Người Dùng Unfollow OA (unfollow) - Người Dùng Gửi Tin Nhắn Văn Bản (user_send_text) - Người Dùng Gửi Hình Ảnh (user_send_image) - Người Dùng Gửi File (user_send_file) - Người Dùng Gửi Vị Trí (user_send_location) - Người Dùng Gửi Sticker (user_send_sticker) - Người Dùng Gửi GIF (user_send_gif) - Người Dùng Nhấp Vào Nút (user_click_button) - Người Dùng Nhấp Vào Liên Kết (user_click_link) - Tất Cả Sự Kiện (all) |
| Xác Thực Mac (Validate MAC) | Boolean option to enable or disable verification of the MAC signature from Zalo OA to ensure security. |
Output
The node outputs JSON data representing the received event with additional metadata:
event_type: The type of event received (e.g., "follow", "user_send_text").- All original event data fields sent by Zalo OA are included.
timestamp: The time when the event was processed by the node.
In case of errors or ignored events, the output JSON contains:
event_type: "error" or "ignored".errorormessage: Description of the issue.timestamp: Processing time.
No binary data output is produced by this node.
Dependencies
- Requires an API key credential (OA Secret Key) from Zalo Official Account for MAC signature verification.
- Uses Node.js built-in
cryptomodule for HMAC SHA256 hashing. - Configured as an HTTP webhook endpoint within n8n to receive POST requests from Zalo OA.
Troubleshooting
- Missing MAC header error: Occurs if the incoming request lacks the required MAC signature header while MAC validation is enabled. Ensure Zalo OA sends the MAC header correctly.
- Invalid MAC error: Happens when the computed MAC does not match the provided one, indicating possible tampering or incorrect secret key. Verify the OA Secret Key is correct and matches the one configured in Zalo OA.
- Method not allowed error: If the webhook receives any HTTP method other than GET or POST, it responds with this error. Only POST requests with event data and GET requests for verification are supported.
- Event ignored message: Indicates that the event type received is not among the selected event types to process. Adjust the "Các Loại Sự Kiện" property to include desired events.