Zalo Message Trigger icon

Zalo Message Trigger

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

Zalo Message Trigger

AI-generated

Overview

This node listens for incoming messages from users or groups in a messaging environment. It is designed to trigger workflows based on specific message events, such as user messages or group messages, with options to filter by mentions and user identifiers. The node supports listening to messages sent by the bot itself and can optionally fetch detailed information about the message sender.

Common scenarios where this node is beneficial include:

  • Automating responses or actions when a user sends a direct message.
  • Monitoring group chats for mentions of specific users or all members.
  • Filtering group messages based on mention conditions (e.g., messages mentioning certain user IDs).
  • Collecting user information automatically upon receiving messages.

Practical examples:

  • Trigger a workflow when a user sends a private message containing a keyword.
  • Listen for group messages that mention @all and send a summary notification.
  • React only to group messages that mention a fixed set of user IDs with AND/OR logic.
  • Automatically retrieve and log detailed user profiles when messages arrive.

Properties

Name Meaning
Event Types Types of messages to listen for. Options: User Messages (listen to messages from individual users), Group Messages (listen to messages from groups). Default listens to both.
Self Listen Whether to allow listening to messages sent by yourself (the bot). Boolean true/false.
User Identifier A unique identifier string for this user to distinguish from others (e.g., "user1", "user2").
Lấy Thông Tin User Whether to automatically fetch detailed information about the message sender. Boolean true/false.
Group Message Filter Applicable only if listening to Group Messages. Filters group messages by mention type: Any (all group messages), @All (only messages mentioning @all), Fixed ID (messages mentioning a specific user ID), Multiple IDs (mention multiple IDs with AND/OR condition).
Target User ID Required if Group Message Filter is "Fixed ID". The specific user ID to listen for mentions.
Target User IDs Required if Group Message Filter is "Multiple IDs". Comma-separated list of user IDs to listen for mentions.
Mention Condition Required if Group Message Filter is "Multiple IDs". Condition to filter mentions: AND (message must mention all IDs), OR (message must mention at least one ID).

Output

The node outputs JSON objects representing received messages that match the configured filters. Each output item includes:

  • The original message data.
  • Metadata fields such as:
    • _timestamp: The time the message was received.
    • _instanceKey: Unique key identifying the instance of the listener.
    • _credentialId: Identifier of the used API credential.
    • _userIdentifier: The configured user identifier.
    • _eventType: The type of event (user message or group message).
    • _source: Source identifier string.
    • _userInfo: Optional detailed user information if enabled.
    • _debug: Debug information including webhook data keys and message queue status.

If the node is configured to fetch user info, the output will include detailed sender information under _userInfo.

The node does not output binary data.

Dependencies

  • Requires an API key credential for authentication with the messaging service.
  • Uses a webhook to receive incoming message events.
  • Depends on internal helper classes and modules to manage connections and message filtering.
  • Requires proper configuration of webhook URL and credentials in n8n.

Troubleshooting

  • Common Issues:

    • Failure to connect or authenticate due to invalid or missing API credentials.
    • No messages received if event types or filters are misconfigured.
    • Messages ignored if "Self Listen" is false and the bot sends messages.
    • Incorrect user IDs or mention conditions leading to no triggers.
  • Error Messages:

    • Errors related to connection failures indicate issues with credentials or network.
    • Validation errors if required properties like Target User ID(s) are missing when needed.
    • Runtime errors during user info fetching may occur if the API response is invalid or rate-limited.
  • Resolutions:

    • Verify API key credentials and webhook URL configuration.
    • Ensure correct event types and filters are selected according to use case.
    • Enable "Self Listen" if you want to process messages sent by the bot.
    • Provide valid user IDs and select appropriate mention conditions.
    • Check API limits and error logs for user info retrieval problems.

Links and References

  • n8n Webhook Documentation
  • Messaging service API documentation (generic reference, as specific service is not named)
  • Best practices for webhook security and message filtering in n8n workflows

Discussion