Send WhatsApp template messages
This document provides guidance to send WhatsApp Template messages using Advanced Communication Messages SDK.
Why do I need to send a template message?
A business can only send template messages until the user sends a message to the business.
A business or a user can initiate a conversation window, but the business is limited on which kinds of messages they can send. Only after the user sends a message to the business, the business is allowed to send text or media messages to the user during the active conversation. Once the 24 hour conversation window expires, the conversation must be reinitiated. To learn more about conversations, see the definition at WhatsApp Business Platform.
For further WhatsApp requirements on templates, refer to the WhatsApp Business Platform API references:
- Create and Manage Templates
- Template Components
- Sending Template Messages
- Businesses must also adhere to opt-in requirements before sending messages to WhatsApp users
Choosing a template
When you create a WhatsApp Business Account through the Azure portal during embedded signup, a set of sample templates are available to you.
Create template
To create your own templates, use the Meta WhatsApp Manager.
Follow the instructions in the Meta Business Help Center at Create message templates for your WhatsApp Business account.
List templates
You can view your templates in the Azure portal by going to your Azure Communication Service resource > Templates.
Select a template to view the details.
The content
field of the template details can include parameter bindings. The parameter bindings can be denoted as:
- A
format
field with a value such asIMAGE
. - Double brackets surrounding a number, such as
{{1}}
. The number, indexed started at 1, indicates the order in which the binding values must be supplied to create the message template.
Alternatively, you can view and edit all of your WhatsApp Business Account's templates in the WhatsApp Manager > Account tools > Message templates.
To list out your templates programmatically, you can fetch all templates for your channel ID:
MessageTemplateClient messageTemplateClient = new MessageTemplateClient(connectionString);
Pageable<MessageTemplateItem> templates = messageTemplateClient.GetTemplates(channelRegistrationId);
Quick reference
The sample_template
takes no parameters.
Assemble the MessageTemplate
by referencing the target template's name and language.
string templateName = "sample_template";
string templateLanguage = "en_us";
var sampleTemplate = new MessageTemplate(templateName, templateLanguage);
For detailed examples and template supported scenarios by Advanced Messages SDK, see: