Skip to main content
Version: 3.0.0

💬 Send a template

Send a template message to the specified phone number.

await whatsapp.sendTemplate(
phoneNumber : 'PHONE_NUMBER',
template : 'one_time_password_template',
language : 'en_US',
placeholder: [
{"type": "text", "text": "123456"}
]
);
paramtyperequireddescription
phoneNumberStringyesPhone number with county code and plus.
templateStringyesA template id
languageStringyeslang code (ex. en_US)
placeholderList<Map<String, dynamic>>noPlaceholder variables for template

Placeholder

You can use placeholders (strings of characters) in WhatsApp operator templates. Its takes type as List<Map<String, dynamic>>.

info

Please find out supported Components and more details, at WhatsApp Cloud API.

Here the sample example.

whatsapp.sendTemplate(
phoneNumber : 'PHONE_NUMBER',
template : 'TEMPLATE_ID',
language : 'en_US',
placeholder: [
{
"type": "HEADER",
"format": "TEXT",
"text": "Our {{1}} is on!",
"example": {
"header_text": [
"Spring Sale"
]
}
},
{
"type": "BODY",
"text": "Shop now through {{1}} and use code {{2}} to get {{3}} off of all merchandise.",
"example": {
"body_text": [
[
"the end of April",
"25OFF",
"25%"
]
]
}
},
{
"type": "FOOTER",
"text": "Use the buttons below to manage your marketing subscriptions"
},
{
"type": "BUTTONS",
"buttons": [
{
"type": "QUICK_REPLY",
"text": "Unsubcribe from Promos"
},
{
"type": "QUICK_REPLY",
"text": "Unsubscribe from All"
}
]
}
]
);