Skip to main content

Overview

The WhatsApp Bot integrates with Meta’s WhatsApp Business API to enable automated and manual customer communication. It supports template messages, conversation management, and AI-powered responses.

Template Messages

Send pre-approved templates for notifications

Conversation Inbox

Manage customer conversations in one place

AI Assistant

Automated responses for common inquiries

Request Integration

Link conversations to service requests

How It Works


Template Messages

WhatsApp templates are pre-approved message formats used for business-initiated conversations.

Available Templates

Notifies vendors of new service request assignments.Parameters:
  1. Request ID
  2. Service type
  3. Customer name
  4. Contact phone
  5. Address
  6. Requested delivery date
Button: Link to request details
Confirms receipt of customer’s service request.Parameters:
  1. Customer name
  2. Request ID
  3. Service type
  4. Requested date
  5. Contact email
Header: Brand logo image
Sends PTAR technical questionnaire link to customer.Parameters:
  1. Customer name
  2. Form URL
  3. Vendor name
  4. Vendor phone
Button: Form link with UUID
Notifies vendor that operations approved a service request.Parameters:
  1. Vendor name
  2. Request ID
  3. Approved delivery date
Button: Link to request details
Alerts vendor that a request was reassigned to someone else.Parameters:
  1. Vendor first name
  2. Request ID
  3. Service type

Sending a Template

1

Navigate to WhatsApp Section

Access WhatsApp tools from the main menu.
2

Select Template

Choose from approved templates list.
3

Add Recipients

Enter phone numbers or select from contacts.
4

Fill Parameters

Provide values for each template variable.
5

Send

Messages are dispatched via Meta API.
POST /api/whatsapp/send-template
{
  "templateName": "nueva_solicitud_de_servicio",
  "languageCode": "en_US",
  "components": [
    {
      "type": "body",
      "parameters": [
        { "type": "text", "text": "123" },
        { "type": "text", "text": "Fumigation" },
        { "type": "text", "text": "John Doe" },
        { "type": "text", "text": "+50212345678" },
        { "type": "text", "text": "123 Main St" },
        { "type": "text", "text": "2024-12-15" }
      ]
    },
    {
      "type": "button",
      "sub_type": "url",
      "index": "0",
      "parameters": [
        { "type": "text", "text": "abc-123-uuid" }
      ]
    }
  ],
  "recipients": [
    { "phoneNumber": "+50298765432", "requestId": 123 }
  ]
}

Conversation Management

Viewing Conversations

All WhatsApp conversations are centralized in the inbox:
GET /api/whatsapp/conversations?status=active&limit=50
Displays:
  • Customer name and phone
  • Last message preview
  • Unread count
  • Assigned agent
  • Linked service request (if any)
GET /api/whatsapp/conversations/:conversationId
Shows:
  • Full message history
  • Customer information
  • Conversation metadata
  • Assignment status

Conversation Statuses

Ongoing conversations requiring attention or follow-up.
Resolved but kept for reference. Can be reopened if customer replies.
Completed and no longer active. Not reopened automatically.

Sending Messages

Manual Reply

Respond to customer messages from the conversation view:
1

Open Conversation

Click on the conversation in the inbox.
2

Type Message

Enter your response in the text box.
3

Send

Message is delivered via WhatsApp Business API.
API call
POST /api/whatsapp/conversations/:conversationId/messages
{
  "content": "Hello! How can I help you today?",
  "messageType": "text"
}

Direct Message

Start a new conversation:
POST /api/whatsapp/send
{
  "phoneNumber": "+50212345678",
  "content": "Thank you for contacting us!",
  "requestId": 123
}
WhatsApp’s 24-hour window applies: You can only send free-form messages within 24 hours of the customer’s last message. After that, use templates.

Assignment and Routing

Assign Conversation

Route conversations to specific agents:
1

Open Conversation

View the conversation details.
2

Click 'Assign'

Opens agent selection dialog.
3

Select Agent

Choose the user to handle this conversation.
4

Confirm

Conversation moves to agent’s inbox.
PUT /api/whatsapp/conversations/:conversationId/assign
{
  "userId": 456
}
Connect a conversation to an existing service request:
PUT /api/whatsapp/conversations/:conversationId/link-request
{
  "requestId": 789
}
This enables:
  • Viewing conversation from request page
  • Automatic context in AI responses
  • Better tracking of customer interactions

Webhook Configuration

The WhatsApp webhook receives events from Meta:

Verification (GET)

GET /api/whatsapp/webhook?hub.mode=subscribe&hub.challenge=xyz&hub.verify_token=YOUR_TOKEN
Meta verifies the webhook URL during setup.

Incoming Events (POST)

POST /api/whatsapp/webhook
{
  "object": "whatsapp_business_account",
  "entry": [
    {
      "id": "WABA_ID",
      "changes": [
        {
          "value": {
            "messaging_product": "whatsapp",
            "metadata": { ... },
            "messages": [
              {
                "from": "50212345678",
                "id": "wamid.xyz",
                "timestamp": "1700000000",
                "text": { "body": "Hello" },
                "type": "text"
              }
            ]
          },
          "field": "messages"
        }
      ]
    }
  ]
}
The system automatically:
  1. Creates or updates conversation
  2. Saves the message
  3. Triggers AI response (if enabled)
  4. Sends notifications to assigned agents

AI-Powered Responses

The bot can use GPT-4 to generate contextual responses:
  1. Customer sends message
  2. System retrieves conversation history
  3. GPT-4 analyzes message and context
  4. Generates appropriate response
  5. Response is sent to customer
  6. Human agent can review and override
  • Previous conversation messages
  • Linked service request details
  • Customer information from database
  • Company knowledge base (if configured)
AI responses are marked with a flag. Review important conversations manually.

Message Types

WhatsApp supports various message formats:
Plain text communication. Most common type.
Send or receive photos (e.g., service site images).
Share PDFs or other files (e.g., quotations).
Template messages with clickable buttons for common actions.
Customer can share their location for service delivery.

Read Receipts

Mark conversations as read:
PUT /api/whatsapp/conversations/:conversationId/read
This:
  • Updates unread count
  • Clears notification badge
  • Tracks agent response time

Best Practices

Aim to reply within 1 hour during business hours. Customers expect fast responses on WhatsApp.
Templates are for business-initiated messages. Use plain messages for ongoing conversations within 24 hours.
Route conversations to agents familiar with the customer or service type.
Check AI-generated messages periodically to ensure quality and accuracy.

Template Approval Process

To create new templates:
1

Design Template

Create template in Meta Business Manager with:
  • Template name
  • Category (marketing, utility, authentication)
  • Message content with variables
  • Optional header, footer, buttons
2

Submit for Review

Meta reviews templates (usually 1-3 business days).
3

Sync to AmbioSys

Once approved, sync templates:
GET /api/whatsapp/templates
4

Use in System

Approved templates appear in the template selection dropdown.

Troubleshooting

Common reasons:
  • Contains variable in greeting (not allowed in opening)
  • Uses promotional language in utility template
  • Formatting issues or special characters
Review Meta’s template guidelines and resubmit.
Check:
  • Phone number format (+502xxxxxxxx)
  • WhatsApp Business Account status
  • Customer blocked the number
  • 24-hour window expired (use template)
Verify:
  • Webhook URL is accessible (HTTPS required)
  • Verify token matches Meta configuration
  • Webhook subscriptions include “messages” field

Service Requests

Link WhatsApp conversations to service requests

Customer Management

View customer’s WhatsApp contact information

Build docs developers (and LLMs) love