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 multiple users simultaneously. It acts as a webhook-based trigger that activates workflows when new messages arrive from either individual users or groups, depending on configuration.

Common scenarios include:

  • Automating responses to user or group messages on Zalo.
  • Monitoring conversations for specific message types or content.
  • Integrating Zalo messaging events into broader automation workflows.

For example, a business could use this node to listen for customer inquiries sent via Zalo and automatically route them to a CRM system or notify support staff.

Properties

Name Meaning
Event Types Types of messages to listen for. Options: User Messages (messages from individual users), Group Messages (messages from groups). Default listens to both.
Self Listen Whether to allow listening to messages sent by yourself. Boolean value: true or false.
User Identifier A unique identifier string for this user instance to distinguish it from others (e.g., "user1", "user2").

Output

The node outputs an array of JSON objects representing received messages. Each message object includes:

  • The original message data from Zalo.
  • Additional metadata fields:
    • _timestamp: ISO timestamp when the message was processed.
    • _instanceKey: Unique key combining credential ID and user identifier.
    • _credentialId: Identifier of the used API credential.
    • _userIdentifier: The configured user identifier.
    • _eventType: The type of event/message (e.g., user or group message).
    • _source: Fixed string "zalo_message_trigger" indicating the origin.

If no messages are available, the output contains a single object with _trigger set to "empty" and debug information about the current state.

The node does not output binary data.

Dependencies

  • Requires a valid Zalo API credential with authentication details such as cookie, IMEI, and user agent.
  • Uses the zca-js library to interact with the Zalo API and listen for messages.
  • Needs a webhook URL configured in n8n to receive incoming message events.
  • Stores workflow static data to manage connection instances and message queues.

Troubleshooting

  • Connection failures: Errors during login or instance creation usually indicate invalid or expired credentials. Ensure the provided API authentication token and related data are correct.
  • No messages received: Verify that the webhook URL is correctly set up and accessible by Zalo servers. Also, confirm that the selected event types match the incoming message types.
  • Duplicate or missing messages: The node maintains fallback queues for failed webhook triggers. If messages are lost or duplicated, check network reliability and webhook response handling.
  • Error messages referencing "Zalo connection failed": Typically caused by issues in authenticating with Zalo or network problems. Recheck credentials and connectivity.
  • Self Listen setting: If you expect to receive your own sent messages but do not, ensure the "Self Listen" property is enabled.

Links and References

Discussion