Skip to content

Commit 6749e0b

Browse files
Merge pull request #291538 from Shamkh/CPMTemplateDocAdditions
Adding location-based template sample
2 parents 55b6242 + 01b8aad commit 6749e0b

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

articles/communication-services/concepts/advanced-messaging/whatsapp/includes/template-messages-quick-reference-net.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,56 @@ template.Values.Add(media);
9898
- VIDEO: [Use sample template sample_happy_hour_announcement](#use-sample-template-sample_happy_hour_announcement)
9999
- DOCUMENT: [Use sample template sample_flight_confirmation](#use-sample-template-sample_flight_confirmation)
100100
101+
### Templates with location in the header
102+
103+
Use `MessageTemplateLocation` to define the location parameter in a header.
104+
105+
Template definition for header component requiring location as:
106+
```
107+
{
108+
"type": "header",
109+
"parameters": [
110+
{
111+
"type": "location",
112+
"location": {
113+
"latitude": "<LATITUDE>",
114+
"longitude": "<LONGITUDE>",
115+
"name": "<NAME>",
116+
"address": "<ADDRESS>"
117+
}
118+
}
119+
]
120+
}
121+
```
122+
123+
The "format" can require different media types. In the .NET SDK, each media type uses a corresponding MessageTemplateValue type.
124+
125+
| Properties | Description | Type |
126+
|----------|---------------------------|-----------|
127+
| ADDRESS | Address that will appear after the 'NAME' value, below the generic map at the top of the message. | string |
128+
| LATITUDE | Location latitude. | double |
129+
| LONGITUDE| Location longitude. | double |
130+
| LOCATIONNAME | Text that will appear immediately below the generic map at the top of the message. |string|
131+
132+
For more information on location based templates, see [WhatsApp's documentation for message media](https://developers.facebook.com/docs/whatsapp/cloud-api/guides/send-message-templates#location).
133+
134+
Location based Message template assembly:
135+
```csharp
136+
var location = new MessageTemplateLocation("location");
137+
location.LocationName = "Pablo Morales";
138+
location.Address = "1 Hacker Way, Menlo Park, CA 94025";
139+
location.Position = new Azure.Core.GeoJson.GeoPosition(longitude: 122.148981, latitude: 37.483307);
140+
141+
WhatsAppMessageTemplateBindings location_bindings = new();
142+
location_bindings.Header.Add(new(location.Name));
143+
144+
var messageTemplateWithLocation = new MessageTemplate(templateNameWithLocation, templateLanguage);
145+
messageTemplateWithLocation.Values.Add(location);
146+
messageTemplateWithLocation.Bindings = location_bindings;
147+
``````
148+
#### Example
149+
:::image type="content" source="./../media/template-messages/sample-location-based-template.jpg" lightbox="./../media/template-messages/sample-location-based-template.jpg" alt-text="Screenshot that shows template details for template named sample_location_template.":::
150+
101151
### Templates with quick reply buttons
102152
103153
Use `MessageTemplateQuickAction` to define the payload for quick reply buttons.
Loading

0 commit comments

Comments
 (0)