WATI WhatsApp API¶
Overview¶
The WATI task integrates BaseCloud CRM with WATI's WhatsApp Business API platform, enabling automated WhatsApp messaging including templates, session messages, file sharing, and contact management.
Key Features:
- 5 Actions: Send messages, files, templates, update contacts, retrieve media
- Bearer Token Auth: Simple API key authentication
- Template Messaging: Pre-approved marketing templates with dynamic parameters
- Session Messaging: 24-hour conversational window
- Media Handling: Send files and retrieve media from WATI
- Contact Sync: Update contact attributes in WATI system
Use Cases:
- Automated lead follow-up with template messages
- Invoice delivery via WhatsApp with PDF attachments
- Customer support automation with session messaging
- Contact data synchronization between CRM and WATI
- Marketing campaigns with approved templates
Prerequisites¶
1. WATI Account¶
WATI Setup:
- Active WATI subscription: https://www.wati.io
- WhatsApp Business number configured in WATI
- Access to WATI Dashboard
- Message templates approved by WhatsApp
2. API Credentials¶
Obtain from WATI Dashboard:
- Log into WATI Dashboard
- Navigate to Settings → API or Integrations → API
- Copy API Endpoint URL (format:
https://live-server-XXXXX.wati.io) - Copy Access Token (Bearer token)
- Note: Each WATI account has unique endpoint and token
API Endpoint Format:
Access Token Format:
3. WhatsApp Number¶
- WhatsApp Business number must be active in WATI
- Number cannot be used simultaneously on other platforms
- Verify number is connected and operational in WATI Dashboard
4. Message Templates (Optional)¶
For Template Messaging:
- Create templates in WATI Dashboard
- Submit for WhatsApp approval
- Wait for approval (usually 24-48 hours)
- Note template names for use in tasks
Outputs¶
Reference fields as {{task_<ID>_<field>}}.
| Field | Type | Notes |
|---|---|---|
response |
string | WATI's response to the call. Present only on some actions. |
Always emitted¶
| Field | Type | Notes |
|---|---|---|
run |
boolean | Whether the task succeeded. |
run_text |
string | What happened, including the reason on failure. |
Fields marked as action-dependent may be absent
This task does several different things depending on its action setting, and only the fields relevant to that action are emitted. Check a real run in the OUTPUT panel before referencing one downstream.
Configuration¶
Builder fields¶
The Field column is the label as it appears in the task builder; Key is the name the value is stored under and referenced by.
| Field | Key | Type | Default | Notes |
|---|---|---|---|---|
| Action | wati_action |
select | send_session_message |
Options: Send Session Message · Send Template Message · Send Session File · Update Contact · Get Media |
| API Endpoint | API Endpoint |
text | – | |
| Access Token | Access Token |
text | – | |
| WhatsApp Number | whatsappNumber |
text | – | |
| Message Text | messageText |
textarea | – | Only shown when wati_action is send_session_message |
| Template Name | template_name |
select | – | Only shown when wati_action is send_template_message |
| Caption | caption |
text | – | Only shown when wati_action is send_session_file |
| File URL | file_url |
text | – | Only shown when wati_action is send_session_file, get_media |
| Template Parameters | _template_params |
dyn-rows | – | Only shown when wati_action is send_template_message |
| Contact Attributes | _contact_params |
dyn-rows | – | Only shown when wati_action is update_contact |
Action 1: send_session_message¶
Send text message within 24-hour conversational window.
| Field | Required | Description | Example |
|---|---|---|---|
| wati_action | Yes | Must be "send_session_message" | send_session_message |
| API Endpoint | Yes | WATI server URL | https://live-server-12345.wati.io |
| Access Token | Yes | Bearer token | Bearer eyJhbGci... |
| whatsappNumber | Yes | Recipient number (no + symbol) | 27821234567 |
| messageText | Yes | Message content | Hello {{client_name}}, your order is ready! |
Output Variables:
task_23001_run; // true/false
task_23001_run_text; // "Successfully sent message."
task_23001_response; // Full WATI API response
How It Works:
- Validates required fields (endpoint, token, number, text)
- Constructs URL:
POST {endpoint}/api/v1/sendSessionMessage/{number}?messageText={text} - Adds Authorization header with Bearer token
- Sends message via WATI API
- Returns success status and API response
24-Hour Window:
- Session messages only work within 24 hours of last customer message
- Outside window, use
send_template_messageinstead - WATI returns error if session expired
Action 2: send_template_message¶
Send pre-approved WhatsApp template message (works anytime).
| Field | Required | Description | Example |
|---|---|---|---|
| wati_action | Yes | Must be "send_template_message" | send_template_message |
| API Endpoint | Yes | WATI server URL | https://live-server-12345.wati.io |
| Access Token | Yes | Bearer token | Bearer eyJhbGci... |
| whatsappNumber | Yes | Recipient number | 27821234567 |
| template_name | Yes | Approved template name | welcome_new_customer |
| parameter_name_1 | No | First parameter name | customer_name |
| parameter_value_1 | No | First parameter value | {{client_first_name}} |
| parameter_name_2 | No | Second parameter name | order_number |
| parameter_value_2 | No | Second parameter value | {{order_id}} |
Add as many parameter pairs as needed
Output Variables:
task_23001_run; // true/false
task_23001_run_text; // "Successfully sent message."
task_23001_response; // Full WATI API response with message ID
How It Works:
- Validates required fields
- Collects all
parameter_name_Xandparameter_value_Xpairs - Builds parameter array matching template placeholders
- Constructs URL:
POST {endpoint}/api/v1/sendTemplateMessage?whatsappNumber={number} - POST body:
- Returns WATI's answer in
response
The template name is also sent as the broadcast name, so the send shows under that name in WATI.
A parameter must have its value. A parameter name saved without its value row fails the task straight away —
WhatsApp parameter "customer_name" (1) has no value row — instead of sending a template with a gap in it. Remove
the parameter and add it again.
Template Parameters:
Templates defined in WATI use placeholders like {{customer_name}}. Parameter names must match exactly.
Example template:
Requires 3 parameters: customer_name, order_number, delivery_date
Action 3: send_session_file¶
Send file/media within 24-hour conversational window.
| Field | Required | Description | Example |
|---|---|---|---|
| wati_action | Yes | Must be "send_session_file" | send_session_file |
| API Endpoint | Yes | WATI server URL | https://live-server-12345.wati.io |
| Access Token | Yes | Bearer token | Bearer eyJhbGci... |
| whatsappNumber | Yes | Recipient number | 27821234567 |
| file_url | Yes | Public URL to file | {{task_36001_document_url}} |
| caption | No | File caption/description | Your invoice for {{month}} |
Output Variables:
task_23001_run; // true/false
task_23001_run_text; // "Successfully sent file."
task_23001_response; // Full WATI API response
How It Works:
- Validates required fields
- Downloads file from
file_url - Creates FormData with file and caption
- Uploads via:
POST {endpoint}/api/v1/sendSessionFile/{number} - WATI processes and sends to recipient
File URL Requirements:
- BaseCloud downloads the file from the URL itself, so it must be reachable without signing in
- The file type and size must be ones WhatsApp accepts — WATI refuses the rest, and the task fails with its answer
Action 4: update_contact¶
Update contact attributes in WATI system.
| Field | Required | Description | Example |
|---|---|---|---|
| wati_action | Yes | Must be "update_contact" | update_contact |
| API Endpoint | Yes | WATI server URL | https://live-server-12345.wati.io |
| Access Token | Yes | Bearer token | Bearer eyJhbGci... |
| whatsappNumber | Yes | Contact number | 27821234567 |
| parameter_name_1 | No | Attribute name | first_name |
| parameter_value_1 | No | Attribute value | {{client_first_name}} |
| parameter_name_2 | No | Second attribute | email |
| parameter_value_2 | No | Second value | {{client_email}} |
Add as many parameter pairs as needed
Output Variables:
task_23001_run; // true/false
task_23001_run_text; // "Successfully updated contact."
task_23001_response; // Updated contact object
How It Works:
- Collects all
parameter_name_Xandparameter_value_Xpairs - Builds custom attributes array
- Sends to:
POST {endpoint}/api/v1/updateContactAttributes/{number} - POST body:
- Returns WATI's answer in
response
The attribute names are the ones your WATI account defines — check them in WATI before mapping values to them.
Action 5: get_media¶
Retrieve media file from WATI and upload to Azure storage.
| Field | Required | Description | Example |
|---|---|---|---|
| wati_action | Yes | Must be "get_media" | get_media |
| API Endpoint | Yes | WATI server URL | https://live-server-12345.wati.io |
| Access Token | Yes | Bearer token | Bearer eyJhbGci... |
| file_url | Yes | WATI media URL with fileName param | https://live-server-12345.wati.io/media/123?fileName=image.jpg |
Output Variables:
task_23001_run; // true/false
task_23001_run_text; // "Successfully fetched media."
task_23001_response; // Full file object
task_23001_response.id; // File database ID
task_23001_response.owner_id; // BaseCloud owner ID
task_23001_response.file_url; // Azure Blob Storage URL
task_23001_response.file_name; // Sanitized filename (basecloud_wa_*)
task_23001_response.size; // File size in bytes
task_23001_response.contentType; // MIME type
How It Works:
- Validates file URL has
fileNamequery parameter - Extracts filename from URL
- Downloads file from WATI:
GET {file_url}with Authorization header - Sanitizes filename:
basecloud_wa_{original_filename} - Uploads to Azure Blob Storage (owner-specific container)
- Records the file in BaseCloud (not attached to a client)
- Returns Azure URL and file metadata
Use Case:
When customer sends image/document via WhatsApp:
- A Webhook In trigger receives the media URL WATI posts
- Use
get_mediaaction to download and store - Azure URL can be used in other tasks (attach to email, save to client record, etc.)
Real-World Examples¶
Send a WhatsApp template when a lead arrives¶
WATI needs the number in international format, so normalise it first.
Send an appointment reminder¶
Share a document over WhatsApp¶
Webhook In
└─ PDF generate the document
└─ WATI send it as a file, using {{task_36001_document_url}}
Troubleshooting¶
Error: "No API endpoint provided"¶
Cause: API Endpoint field is empty
Solutions:
- Obtain endpoint from WATI Dashboard → Settings → API
- Format:
https://live-server-XXXXX.wati.io(no trailing slash) - Verify URL is accessible (test in browser)
Error: "No Access Token provided"¶
Cause: Access Token field is empty
Solutions:
- Copy full token from WATI Dashboard
- Include "Bearer " prefix:
Bearer eyJhbGci... - Check token hasn't expired (regenerate if needed)
Error: "No WhatsApp number is configured"¶
Cause: Recipient number field is empty
Solutions:
- Provide number with country code, no + symbol:
27821234567 - Verify number exists in client record
- If it comes from an earlier task, check that task ran and has the number — a Phone Formatter normalises it
Session Message Failed (Outside 24-Hour Window)¶
Cause: Attempting session message without active conversation
Solutions:
- Use
send_template_messageinstead (works anytime) - Check last customer message timestamp in WATI
- Customer must message first to open 24-hour window
- Use template for initial outreach
Template Not Found¶
Cause: Template name doesn't exist or not approved
Solutions:
- Verify template exists in WATI Dashboard → Templates
- Check template status is "Approved" (not Pending/Rejected)
- Match exact template name (case-sensitive)
- Wait for WhatsApp approval if recently submitted
Template Parameters Mismatch¶
Cause: Parameter names don't match template placeholders
Solutions:
- Check template definition in WATI Dashboard
- Match parameter names exactly:
{{customer_name}}requiresparameter_name_1: customer_name - Provide all required parameters
- Order doesn't matter, names must match
File Upload Failed¶
Cause: File URL inaccessible or invalid format
Solutions:
- Verify URL is publicly accessible (no authentication)
- Use HTTPS URLs when possible
- Check WhatsApp accepts the file's type and size
- Test the URL in a browser first
Media Retrieval Error: "Invalid filepath within URL"¶
Cause: get_media file_url missing fileName query parameter
Solutions:
- WATI media URLs include
fileName:https://...?fileName=image.jpg - Don't construct URLs manually - use from webhook
- Verify
{{task_46001_media_url}}contains full URL with params
Contact Update Not Reflecting¶
Cause: Attribute names don't match WATI custom fields
Solutions:
- Check custom attribute names in WATI Dashboard → Settings → Custom Attributes
- Use exact spelling and casing
- Create custom attributes in WATI first
Rate Limiting / 429 Errors¶
Cause: Sending messages too quickly
Solutions:
- BaseCloud already backs off and retries a rate-limited call — the run shows "Rate limited — rescheduled for retry."
- In a Loop sending many messages, add a Delay between them
- WATI's limits vary by plan — contact WATI to raise them
Best Practices¶
- Keep the Access Token out of sight. It is withheld when the workflow is read; rotate it in WATI if it may have leaked.
- Use templates for the first message. Session messages and files only reach someone who messaged in the last 24 hours.
- Name template parameters clearly (
customer_name, notparam1) — they must match the template's placeholders exactly. - Generate files with a PDF task and send its
document_url. - Archive what customers send with
get_media, so the file stays in BaseCloud after WATI's link expires.
FAQ¶
Q: Can I use WATI and WhatsApp Business simultaneously?
A: No, WhatsApp number can only be connected to one platform at a time. Choose WATI or Meta WhatsApp Business Cloud API.
Q: What's the difference between session and template messages?
A:
- Session Messages: Free text, requires active conversation (24-hour window)
- Template Messages: Pre-approved, can send anytime, costs per message
Q: How do I get templates approved?
A: Create template in WATI Dashboard → Submit for WhatsApp review → Wait 24-48 hours for approval.
Q: Can I send messages without templates outside 24-hour window?
A: No, WhatsApp requires approved templates for initial outreach and messaging outside conversation windows.
Q: What file types can I send?
A: Images (JPG, PNG, GIF), videos (MP4), documents (PDF, DOC, XLS, PPT), audio (MP3, OGG).
Q: How do I handle opt-outs?
A: Keep the opt-out on the client — for example a custom field — and check it with an If before the WATI task.
Q: Can I schedule messages for later?
A: Start the workflow from a Timer Trigger, or put a Delay before the WATI task.
Q: What happens if recipient number is invalid?
A: WATI returns error in response. Check {{task_23001_response}} for error details.
Q: Can I send bulk messages?
A: Yes, use Loop task with delays. Ensure compliance with WhatsApp policies and opt-ins.
Q: How do I track message delivery?
A: WATI can post delivery events to a webhook — catch them with a Webhook In trigger.
Q: Can I receive messages from customers?
A: Yes — point WATI's webhook at a Webhook In trigger.
Q: What's the cost per message?
A: Varies by WATI plan. Session messages usually free, template messages charged per send.
Related Tasks¶
- WhatsApp Business - Alternative using Meta's official API
- Email - Fallback communication channel
- SMS - Alternative text messaging
- PDF - Generate documents to send
- Loop - Bulk message sending
- If Statement - Message routing logic
- Delay - Rate limiting in loops
- Webhook In - Receive WATI webhooks
Technical Details¶
- Type ID: 23
- Function:
taskWATI()in automationService.js - API Version: WATI API v1
- Authentication: Bearer Token
- Output Prefix:
task_23001_* - Rate Limits: Varies by WATI plan
- Session Window: 24 hours from last customer message