Skip to main content

Receive Message

Receives incoming WhatsApp messages via a webhook server. This node sets up a local HTTP server to listen for incoming messages from Twilio and triggers your automation flow when messages are received.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Prerequisites

To receive WhatsApp messages, you need to:

  1. Configure WhatsApp Sandbox or Production WhatsApp Number in Twilio Console
  2. Set up Webhook URL - Configure Twilio to send incoming messages to your webhook endpoint
  3. Expose Local Server - Make your local server accessible to Twilio (using ngrok, tunneling, or public IP)
  4. Configure Firewall - Ensure the webhook port is accessible from external networks
warning

This node creates a local HTTP server. For production use, ensure your server is properly secured and accessible from Twilio's servers.

Input

  • Port - The webhook server port for receiving messages. This input exists for compatibility but the actual port is configured via properties. Default: 9001
info

The actual port and IP are configured through application properties:

  • robomotion.twilio.receivemessage.port (default: 9001)
  • robomotion.twilio.receivemessage.ip (default: 127.0.0.1)

Output

The node outputs a message object for each incoming WhatsApp message received:

  • id - Unique identifier for the received message
  • body - Object containing the message details from Twilio:
    • From - Sender's WhatsApp number (format: whatsapp:+14155552671)
    • To - Your WhatsApp number (format: whatsapp:+14155552672)
    • Body - The message text content
    • MessageSid - Twilio's unique message identifier
    • AccountSid - Your Twilio Account SID
    • NumMedia - Number of media attachments
    • MediaUrl0, MediaContentType0 - Media attachment details (if present)
    • Additional Twilio webhook parameters

Options

  • n/a - This node has no configurable options.

Configuration

1. Configure Application Properties

Set the webhook server configuration in your Robomotion properties:

robomotion.twilio.receivemessage.port=9001
robomotion.twilio.receivemessage.ip=127.0.0.1

2. Expose Local Server

For development/testing, use ngrok to expose your local server:

ngrok http 9001

This provides a public URL like: https://abc123.ngrok.io

3. Configure Twilio Webhook

In Twilio Console:

  1. Go to your WhatsApp Sender settings
  2. Find "Webhook URL for Incoming Messages"
  3. Set to: https://abc123.ngrok.io/ (or your public URL)
  4. Save configuration

Examples

Example 1: Auto-Reply System

Create an auto-reply system for incoming WhatsApp messages:

Flow Structure:

Receive Message
├── Output: message data
└── Send WhatsApp Message
├── To Number: {{item.body.From}} (remove "whatsapp:" prefix)
└── Message: "Thank you for contacting us! We'll respond shortly."

Implementation:

  1. Add Receive Message node (starts the flow)
  2. Extract sender from {{item.body.From}}
  3. Remove whatsapp: prefix: Use string manipulation or JavaScript
  4. Send WhatsApp Message with auto-reply

Example 2: Keyword-Based Responses

Respond to messages based on keywords:

Flow Structure:

Receive Message
├── Get message body
├── Convert to lowercase
└── Switch (based on keywords)
├── Case "hours" → Send business hours
├── Case "support" → Create support ticket
├── Case "order" → Send order status
└── Default → Send help menu

Message Processing:

// Extract and clean message
var fromNumber = item.body.From.replace('whatsapp:', '');
var messageText = item.body.Body.toLowerCase();

// Set variables for routing
msg.from = fromNumber;
msg.text = messageText;

Example 3: Customer Support Ticketing

Create support tickets from WhatsApp messages:

Flow Structure:

Receive Message
├── Parse message details
├── Database - Insert (create ticket)
│ └── ticket_id, customer_phone, message, status: "new"
├── Send WhatsApp Message (confirmation)
│ └── "Ticket #{{ticket_id}} created. Support will contact you soon."
└── Send Email (notify support team)

Example 4: Order Status Inquiry

Allow customers to check order status via WhatsApp:

Flow Structure:

Receive Message
├── Extract order number from message
│ └── RegEx: #(\d+)
├── Database Query
│ └── SELECT * FROM orders WHERE order_id = {{order_number}}
├── If order found
│ └── Send WhatsApp Message
│ └── "Order #{{order_id}}: {{status}}\nETA: {{delivery_date}}"
└── Else
└── Send WhatsApp Message
└── "Order not found. Please check the order number."

Example 5: Multi-Agent Routing

Route messages to different agents based on content:

Flow Structure:

Receive Message
├── Analyze message content
├── Switch (routing logic)
│ ├── Sales keywords → Notify sales team
│ ├── Support keywords → Create support ticket
│ ├── Billing keywords → Notify billing department
│ └── Default → General inquiry queue
└── Send acknowledgment to customer

Tips

  • Server Accessibility - For production, host on a server with a public IP or domain, not just localhost.
  • HTTPS Required - Twilio requires HTTPS for webhooks in production. Use a valid SSL certificate.
  • Port Configuration - If port 9001 is in use, change it via application properties.
  • URL Path - The webhook endpoint is always the root path /. Configure Twilio to post to https://yourdomain.com/.
  • Testing with ngrok - ngrok is perfect for development. Remember to update the Twilio webhook URL when ngrok restarts (URL changes).
  • Message Parsing - The body contains URL-encoded form data. The node automatically parses it into an object.
  • Number Format - Incoming numbers include the whatsapp: prefix. Remove it when replying: from.replace('whatsapp:', '').
  • Flow Trigger - This node has 0 inputs (configured in the source code). It acts as a trigger node that starts the flow when messages arrive.
  • Concurrent Messages - The server handles concurrent incoming messages automatically.
  • Error Handling - Wrap subsequent nodes in Try-Catch to handle processing errors gracefully.

Common Errors

Port Already in Use

Error: Server fails to start, port 9001 already in use

Solution:

  • Check if another Receive Message flow is already running
  • Change the port via application properties:
    robomotion.twilio.receivemessage.port=9002
  • Kill the process using the port (check with netstat or lsof)

Webhook Not Receiving Messages

Error: Messages sent to WhatsApp number but no flow triggers

Solution:

  • Verify ngrok or your tunnel is running and accessible
  • Check Twilio webhook URL is correctly configured
  • Test webhook URL in browser or with curl
  • Ensure firewall allows incoming connections on the webhook port
  • Check Twilio webhook logs in Console for error messages
  • Verify the webhook URL path is / (root)

Invalid URL in Twilio

Error: "Invalid webhook URL" in Twilio Console

Solution:

  • Ensure URL uses HTTPS (required for production)
  • Verify URL is publicly accessible
  • Check URL format: https://yourdomain.com/ (must end with /)
  • Test URL accessibility from external network
  • For development, use ngrok HTTPS URL

Messages Not Parsing Correctly

Error: Message body is empty or malformed

Solution:

  • Check Twilio is sending POST requests with form data
  • Verify the node is receiving the webhook properly
  • Log the raw item.body object to inspect contents
  • Ensure no middleware is interfering with request body

Server Stops Responding

Error: Webhook stops receiving messages after running for a while

Solution:

  • Check application logs for errors
  • Ensure no memory leaks in message processing logic
  • Restart the flow
  • Monitor server resources (CPU, memory)
  • Implement proper error handling in downstream nodes

HTTPS Certificate Errors

Error: Twilio rejects webhook due to SSL certificate issues

Solution:

  • Use a valid SSL certificate (not self-signed)
  • Ensure certificate is not expired
  • Verify certificate matches your domain
  • For development, ngrok provides valid HTTPS automatically
  • Consider using Let's Encrypt for free SSL certificates

Configuration Examples

Development Setup (ngrok)

  1. Start ngrok:
ngrok http 9001
  1. Copy the HTTPS URL (e.g., https://abc123.ngrok.io)

  2. Configure Twilio webhook:

    • URL: https://abc123.ngrok.io/
    • Method: POST
  3. Run your flow with Receive Message node

Production Setup

  1. Configure application properties:
robomotion.twilio.receivemessage.port=443
robomotion.twilio.receivemessage.ip=0.0.0.0
  1. Set up reverse proxy (nginx) with SSL:
server {
listen 443 ssl;
server_name yourdomain.com;

ssl_certificate /path/to/cert.pem;
ssl_certificate_key /path/to/key.pem;

location / {
proxy_pass http://127.0.0.1:9001/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
  1. Configure Twilio webhook:
    • URL: https://yourdomain.com/
    • Method: POST