Whatsapp icon integrated with an authentication API, showcased on a green square.

Channel | WhatsApp Business

With more than 2 billion people using WhatsApp around the world to send 60 billion messages every day, the chat app has revolutionized the way we communicate. With an enterprise-grade API, companies can now send notifications and provide customer service through WhatsApp in a secure, reliable, and customer-friendly way.

Send a Message Template

This short tutorial will show you how to send a WhatsApp message with variables.

Dynamic variables – also known as placeholders, parameters, or substitutions – allow you to pass dynamic contents to the message. While requesting message templates, you can specify the dynamic variable like {{1}}, {{2}}. By adding unique parameters, you can personalize information for your customers. 

For example, in the template below, you can replace {{1}} and {{2}] with your value when sending a message.

<p><code><span><span><span><span><span><span>You purchased <span class="nu0">{{1}}</span> using a credit card ending in <span class="nu0">{{2}}</span>.</span></span></span></span></span></span></code></p>

To input actual variables into a Message Template, you’ll need to send parameter values instead of sending the entire message.

For the following example Message Template:

<p><code><span><span><span><span><span><span>Hi <span class="nu0">{{1}}</span>! Thanks for placing an order at FabShoes. Your order <span class="nu0">{{2}}</span>, for a total of EUR <span class="nu0">{{3}}</span>, is confirmed. The expected delivery is <span class="nu0">{{4}}</span>.</span></span></span></span></span></span></code></p>

You’ll need to send the following example request:

<div class="geshifilter"><pre class="php geshifilter-php">curl –XPOST https<span class="sy0">:</span><span class="co1">//api.tyntec.com/conversations/v3/messages\</span>
  <span class="sy0">-</span>H <span class="st_h">'Content-Type: application/json'</span> \
  <span class="sy0">-</span>H <span class="st_h">'apikey: <API KEY>'</span> \
<span class="sy0">-</span>d <span class="st_h">'{
  "from": "{{whatsAppBusinessNumber}}",
  "to": "{{receiverPhoneNumber}}",
  "channel": "whatsapp",
  "content": {   
    "contentType": "template",
    "template": {
        "templateId" : "order_confirmation",
        "templateLanguage" : "en",
        "components" : {
            "body" : [
                    {
                        "type": "text",
                        "text": "Ben"
                    },
                    {
                        "type": "text",
                        "text": "2019-0000001"
                    },
                    {
                        "type": "text",
                        "text": "600.00"
                    },
                    {
                        "type": "text",
                        "text": "2019-06-01"
                    }
            ]           
        }
   }
  }
}'</span></pre></div>

If your request has been successful, the response will be similar to this:

<div class="geshifilter"><pre class="php geshifilter-php"><span class="br0">{</span>
  <span class="st0">"messageId"</span><span class="sy0">:</span> <span class="st0">"77185196-664a-43ec-b14a-fe97036c697f"</span><span class="sy0">,</span>
  <span class="st0">"acceptedAt"</span><span class="sy0">:</span> <span class="st0">"2019-05-17T09:45:00Z"</span>
<span class="br0">}</span></pre></div>