WhatsApp Trigger

Listen for WhatsApp messages and events

Overview

This node listens for WhatsApp messages and connection events by polling a WhatsApp server API at a configurable interval. It triggers workflows based on specified message types or connection status changes, supporting filters for message content keywords. It is useful for automating responses or actions based on incoming WhatsApp messages or connection events, such as customer support automation, notification systems, or message monitoring.

Use Case Examples

  1. Trigger on all incoming WhatsApp messages every 5 seconds.
  2. Trigger only on media messages in group chats containing specific keywords like 'help' or 'support'.
  3. Trigger on connection status changes to monitor WhatsApp session connectivity.

Properties

Name Meaning
Trigger On Specifies the type of WhatsApp events to trigger on, such as all messages, text messages only, media messages only, group messages, direct messages, or connection events.
Polling Interval (seconds) How often the node checks for new messages or connection events, in seconds. Minimum 1 second, maximum 300 seconds.
Filter Keywords Comma-separated keywords to filter messages. Only messages containing these keywords (case-insensitive) will trigger the node. Leave empty to trigger on all messages.

Output

JSON

  • type - Type of event, e.g., 'message' or 'connection_event'.
  • messageId - Unique identifier of the WhatsApp message (for message events).
  • sessionId - Identifier of the WhatsApp session.
  • chatId - Identifier of the chat where the message was received.
  • isGroup - Boolean indicating if the message is from a group chat.
  • sender - Sender's WhatsApp ID.
  • participant - Participant ID in group messages.
  • timestamp - Timestamp of the message or event.
  • message - Raw message object from WhatsApp.
  • messageText - Text content of the message (if applicable).
  • hasMedia - Boolean indicating if the message contains media.
  • chat
    • id - Chat ID.
    • name - Chat name (empty string if not available).
    • isGroup - Boolean indicating if the chat is a group.
  • event - Connection event status, e.g., 'connected' or 'disconnected' (for connection events).
  • status - Current status of the WhatsApp session (for connection events).
  • userInfo - User information related to the WhatsApp session (for connection events).
  • error - Error message if an error occurs during polling.

Dependencies

  • Requires a WhatsApp server API with credentials including server URL, session ID, and optionally an API key for authorization.

Troubleshooting

  • If the node does not trigger, verify the WhatsApp server API credentials and ensure the session is authenticated.
  • Check the polling interval is set within the allowed range (1 to 300 seconds).
  • If filtering by keywords, ensure keywords are correctly comma-separated and match message content case-insensitively.
  • Connection events trigger only when the session status changes; if no events appear, verify the session status changes on the server.
  • Errors during polling emit error events with messages; check these messages for troubleshooting API connectivity or authentication issues.

Discussion