Chatilo
USDPrices shown in US dollars Sign in Start free trial
Guide

Send your first template message

WhatsApp lets a business start a conversation only with a message it has approved in advance, called a template. This guide sends one, then checks that it arrived. You need an API key (make one) and one approved template.

First, why a template? #

WhatsApp has one rule that shapes everything: you may write freely to a customer for 24 hours after their last message to you. Outside that window, only an approved template gets through. So an order update, a reminder or a first hello is a template; a reply to a question is ordinary text.

Templates are written in Chatilo under Templates and sent to WhatsApp for approval, which usually takes minutes. A template has a name, a language and numbered placeholders such as {{1}} that you fill in when sending.

Just trying things out? If the workspace has a sandbox number ("sandbox": true in the list of numbers), messages sent from it are only pretended: nothing reaches a real phone, and each one is marked delivered a moment later. It is a safe place to follow this guide.
  1. Check which number you are sending from #

    List the workspace’s WhatsApp numbers. With one number you can skip this; with several, note the id of the one to send from.

    List numbers
    curl "https://chatilo.me/api/v1/numbers" \
      -H "Authorization: Bearer YOUR_API_KEY"
  2. Find an approved template #

    List the templates that can be sent, and look at what each needs filled in:

    List approved templates
    curl "https://chatilo.me/api/v1/templates?status=APPROVED" \
      -H "Authorization: Bearer YOUR_API_KEY"
    Response
    {
        "ok": true,
        "templates": [
            {
                "name": "order_update",
                "language": "en",
                "category": "UTILITY",
                "status": "APPROVED",
                "variables": {
                    "header": "none",
                    "header_vars": 0,
                    "body_vars": 2
                },
                "id": 12,
                "number_id": 1
            }
        ]
    }

    body_vars: 2 means the body has {{1}} and {{2}}, so you will send two values. To read the template’s text, ask for the template by id.

  3. Send it #

    Give the phone number with its country code, the template’s name and language, and the values for the body in order. The Idempotency-Key makes it safe to retry if the connection drops: the same key never sends twice.

    Send a template
    curl -X POST "https://chatilo.me/api/v1/messages" \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Idempotency-Key: order-1042-shipped" \
      -H "Content-Type: application/json" \
      -d '{
        "to": "+919876543210",
        "type": "template",
        "template": {
            "name": "order_update",
            "language": "en",
            "body": [
                "Grace",
                "#1042"
            ]
        }
    }'
    Response · HTTP 201
    {
        "ok": true,
        "message": {
            "id": 3001,
            "status": "sent",
            "conversation_id": 2001,
            "contact_id": 1001
        }
    }

    If that number wasn’t a contact yet, it is now. sent means WhatsApp accepted the message, not that it has reached the phone.

  4. See whether it arrived #

    Ask for the message a few seconds later. Its status moves from sent to delivered and then read, or to failed with the reason in error.

    Check the status
    curl "https://chatilo.me/api/v1/messages/3001" \
      -H "Authorization: Bearer YOUR_API_KEY"

Fill in the customer’s own details #

A value can be a placeholder that Chatilo fills from the contact: {{name}}, {{first_name}}, {{phone}}, {{email}}, or any of the contact’s custom attributes such as {{city}}. So "body": ["{{first_name}}", "#1042"] greets each person by name without you looking it up.

If the template has a text header with a variable, send it as "header": "…". If it has an image, video or document header, header is a public https link to the file.

When they reply #

The customer’s reply opens the 24-hour window. Now you can answer with ordinary text, in the conversation the template started:

Reply with text
curl -X POST "https://chatilo.me/api/v1/conversations/2001/messages" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "type": "text",
    "text": "It’s out for delivery and should reach you today."
}'

To hear about replies the moment they come in, subscribe to the message.received event: see webhooks.

If it doesn’t work #

You getIt meansDo this
template_not_foundNo approved template with that name and language on the sending number.Check the spelling and the language code, and that its status is APPROVED.
opted_outThe customer replied STOP.Don’t message them. They can reply START to opt back in.
invalid_phoneThe number has no country code or the wrong length.Send it as +919876543210.
window_closedYou sent text, not a template, and the customer hasn’t written in 24 hours.Send a template.
send_failedWhatsApp refused the message.The message text carries WhatsApp’s reason.

Cookies on this site

We use the cookies needed to run the site and keep you signed in. With your OK we also remember choices you make here, such as the currency for prices. We don’t use advertising or tracking cookies. Cookie policy