🧩 Send a Template
Templates are required to start a conversation outside the 24-hour customer service
window. sendTemplate fills positional body parameters. sendTemplateMessage gives you
full control over the components array for media headers, named parameters, buttons and
carousels.
Body parameters
await whatsapp.sendTemplate(
phoneNumber: 'RECIPIENT_NUMBER',
template: 'welcome',
language: 'en_US',
placeholder: [
{'type': 'text', 'text': 'Rohit'},
{'type': 'text', 'text': 'ORD-1042'},
],
);
| param | type | required | description |
|---|---|---|---|
phoneNumber | String | yes | Recipient with country code |
template | String | yes | Approved template name |
language | String | yes | Language/locale code, for example en_US |
placeholder | List<Map<String, dynamic>> | no | Positional body parameters |
Full components
await whatsapp.sendTemplateMessage(
phoneNumber: 'RECIPIENT_NUMBER',
template: 'order_update',
language: 'en_US',
components: [
{
'type': 'header',
'parameters': [
{
'type': 'image',
'image': {'id': 'MEDIA_ID'},
},
],
},
{
'type': 'body',
'parameters': [
{'type': 'text', 'text': 'Rohit'},
{'type': 'text', 'text': 'ORD-1042'},
],
},
{
'type': 'button',
'sub_type': 'url',
'index': 0,
'parameters': [
{'type': 'text', 'text': 'tracking-id'},
],
},
],
);
Named parameters
Templates created with named parameters use parameter_name instead of relying on
position:
{
'type': 'body',
'parameters': [
{
'type': 'text',
'parameter_name': 'first_name',
'text': 'Rohit',
},
],
}
Template approval
Templates must be approved in WhatsApp Manager before you can send them. The language code must match the approved template exactly.