Zalo Message Trigger icon

Zalo Message Trigger

Sự kiện lắng nghe tin nhắn trên Zalo (Hỗ trợ multiple users)

Overview

This node listens for incoming messages on the Zalo platform, supporting both individual user messages and group messages. It is designed to trigger workflows when new messages arrive, with options to filter by message type and mentions within group chats. This node is useful for automating responses, monitoring conversations, or integrating Zalo messaging into broader automation processes.

Practical examples include:

  • Triggering a workflow when a user sends a direct message.
  • Listening to group chat messages but only triggering when the bot or a specific user is mentioned.
  • Filtering out duplicate messages received within a short time window to avoid repeated triggers.

Properties

Name Meaning
Event Types Types of messages to listen for: "User Messages" (direct messages), "Group Messages" (group chats).
Self Listen Whether to allow listening to messages sent by yourself (true/false).
User Identifier A unique identifier string for this user instance to distinguish between multiple users.
De-duplicate Window (ms) Time window in milliseconds to ignore duplicate messages.
Group Message Filter Filter condition for group messages: "Any", "Mention All", "Mention Me", or "Mention ID".
Target ID (for Mention ID) The specific ID to watch for when filtering group messages by mention ID.
My Zalo ID (optional) Optional Zalo user ID used to check "Mention Me" if the SDK does not provide the user ID.

Output

The node outputs an array of JSON objects representing the received messages. Each object contains detailed information about the message event, including:

  • type: The message type (user or group).
  • data: The message content and metadata.
  • threadId or equivalent: The conversation or group ID.
  • senderId: The sender's user ID.
  • messageId: Unique message identifier.
  • Additional fields related to mentions and message text.

If binary data were involved, it would be summarized accordingly, but this node focuses on JSON message data.

Dependencies

  • Requires a valid Zalo API credential with authentication details such as cookies, IMEI, and user agent.
  • Uses the zca-js library for interacting with the Zalo API.
  • Needs webhook URL configuration in n8n to receive incoming message events.
  • Requires proper setup of credentials and permissions to connect to Zalo services.

Troubleshooting

  • No API instance found / connection failed: Ensure that the provided Zalo API credentials are valid and contain all necessary authentication data (cookie, IMEI, user agent).
  • Duplicate messages being triggered: Adjust the "De-duplicate Window (ms)" property to a suitable value to filter out repeated messages arriving within a short timeframe.
  • Group message filters not working as expected: Verify the correct filter mode is selected and that the optional IDs (e.g., "Target ID" or "My Zalo ID") are correctly set.
  • Webhook not triggering: Confirm that the webhook URL is correctly configured and accessible from Zalo's servers.
  • Messages queued in fallback: If webhook delivery fails, messages are stored temporarily; ensure network connectivity and webhook endpoint stability.

Links and References

Discussion