Skip to main content
Version: 4.2.0

🧩 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'},
],
);
paramtyperequireddescription
phoneNumberStringyesRecipient with country code
templateStringyesApproved template name
languageStringyesLanguage/locale code, for example en_US
placeholderList<Map<String, dynamic>>noPositional 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.

Return methods​