WhatsApp Automation
Automate WhatsApp messaging with MachinaOs. Receive messages, process them, and send responses.Prerequisites
- MachinaOs running with the WhatsApp service
- A WhatsApp account for pairing
Understanding WhatsApp Nodes
| Node | Purpose |
|---|---|
| WhatsApp Connect | Check connection status |
| WhatsApp Receive | Trigger on incoming messages |
| WhatsApp Send | Send messages to contacts/groups |
Step 1: Connect WhatsApp
- Click the WhatsApp icon in the toolbar (or add WhatsApp Connect node)
- A modal appears with a QR code
- Open WhatsApp on your phone > Settings > Linked Devices > Link a Device
- Scan the QR code
- Wait for “Connected” status
Step 2: Create a Message Responder
Let’s build a workflow that auto-replies to incoming messages.Add WhatsApp Receive Trigger
- Drag WhatsApp Receive from the WhatsApp category
- Configure the trigger:
Filter Options
| Filter | Description |
|---|---|
| All Messages | Receive everything |
| From Any Contact | Non-group messages only |
| From Specific Contact | Filter by phone number |
| From Specific Group | Filter by group |
| Contains Keywords | Match specific words |
Step 3: Add an AI Response
- Drag OpenAI Chat Model onto the canvas
- Connect WhatsApp Receive output to AI input
- Configure:
Step 4: Send the Response
- Drag WhatsApp Send onto the canvas
- Connect AI output to WhatsApp Send input
- Configure:
Complete Workflow
Step 5: Deploy
- Click Deploy
- Send a message to your linked WhatsApp number
- The workflow triggers and sends an AI response
Available Data from WhatsApp Receive
| Field | Type | Description |
|---|---|---|
message_id | string | Unique message ID |
sender | string | Sender JID |
sender_phone | string | Phone number |
chat_id | string | Chat/group ID |
message_type | string | text, image, video, etc. |
text | string | Message content |
timestamp | string | When message was sent |
is_group | boolean | True if from a group |
is_from_me | boolean | True if sent by you |
push_name | string | Sender’s display name |
is_forwarded | boolean | True if forwarded |
group_info | object | Group details (if group message) |
Group Message Handling
For group messages, use:Example: Keyword-Based Response
Set up different responses based on keywords:Configuration
AI Prompt
Example: Group Bot
Reply only in specific groups:Troubleshooting
QR code not appearing
QR code not appearing
- Ensure the WhatsApp service is running on port 5000
- Check Docker logs:
docker-compose logs whatsapp - Restart the service:
docker-compose restart whatsapp
Messages not being received
Messages not being received
- Verify the trigger is deployed (not just saved)
- Check “Ignore Own Messages” setting
- Ensure filters aren’t too restrictive
Send fails with error
Send fails with error
- Verify phone number format (include country code)
- Check WhatsApp connection status
- Ensure recipient hasn’t blocked you