Skip to content

Commit 662064c

Browse files
Merge pull request #268000 from memontic-ms/acs-cpm-ga
[ACS Advanced Messaging] GA Documentation Updates
2 parents 73b3d40 + d4a6f2d commit 662064c

29 files changed

+1343
-533
lines changed

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

Lines changed: 81 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
title: include file
3-
description: include file
2+
title: Include file
3+
description: Include file
44
services: azure-communication-services
5-
author: memontic-ms
5+
author: glorialimicrosoft
66
ms.service: azure-communication-services
77
ms.subservice: messages
8-
ms.date: 07/12/2023
8+
ms.date: 02/29/2024
99
ms.topic: include
1010
ms.custom: include file
1111
ms.author: memontic
@@ -15,7 +15,7 @@ ms.author: memontic
1515

1616
The sample template named `sample_template` takes no parameters.
1717

18-
:::image type="content" source="./../media/template-messages/sample-template-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_template.":::
18+
:::image type="content" source="./../media/template-messages/sample-template-details-azure-portal.png" lightbox="./../media/template-messages/sample-template-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_template.":::
1919

2020
Assemble the `MessageTemplate` by referencing the target template's name and language.
2121

@@ -30,7 +30,7 @@ var sampleTemplate = new MessageTemplate(templateName, templateLanguage);
3030

3131
Some templates take parameters. Only include the parameters that the template requires. Including parameters not in the template is invalid.
3232

33-
:::image type="content" source="./../media/template-messages/sample-shipping-confirmation-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_shipping_confirmation.":::
33+
:::image type="content" source="./../media/template-messages/sample-shipping-confirmation-details-azure-portal.png" lightbox="./../media/template-messages/sample-shipping-confirmation-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_shipping_confirmation.":::
3434

3535
In this sample, the body of the template has one parameter:
3636
```
@@ -47,18 +47,20 @@ string templateName = "sample_shipping_confirmation";
4747
string templateLanguage = "en_us";
4848
4949
var threeDays = new MessageTemplateText("threeDays", "3");
50-
IEnumerable<MessageTemplateValue> values =
51-
new List<MessageTemplateValue> { threeDays };
52-
MessageTemplateWhatsAppBindings bindings = new MessageTemplateWhatsAppBindings(
53-
body: new[] { threeDays.Name });
54-
var shippingConfirmationTemplate = new MessageTemplate(templateName, templateLanguage, values, bindings);
50+
51+
WhatsAppMessageTemplateBindings bindings = new();
52+
bindings.Body.Add(new(threeDays.Name));
53+
54+
MessageTemplate shippingConfirmationTemplate = new(templateName, templateLanguage);
55+
shippingConfirmationTemplate.Bindings = bindings;
56+
shippingConfirmationTemplate.Values.Add(threeDays);
5557
``````
5658
5759
### Use sample template sample_movie_ticket_confirmation
5860
5961
Templates can require various types of parameters such as text and images.
6062
61-
:::image type="content" source="./../media/template-messages/sample-movie-ticket-confirmation-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_movie_ticket_confirmation.":::
63+
:::image type="content" source="./../media/template-messages/sample-movie-ticket-confirmation-details-azure-portal.png" lightbox="./../media/template-messages/sample-movie-ticket-confirmation-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_movie_ticket_confirmation.":::
6264
6365
In this sample, the header of the template requires an image:
6466
```
@@ -88,25 +90,28 @@ var title = new MessageTemplateText("title", "Contoso");
8890
var time = new MessageTemplateText("time", "July 1st, 2023 12:30PM");
8991
var venue = new MessageTemplateText("venue", "Southridge Video");
9092
var seats = new MessageTemplateText("seats", "Seat 1A");
91-
IEnumerable<MessageTemplateValue> values = new List<MessageTemplateValue>
92-
{
93-
image,
94-
title,
95-
time,
96-
venue,
97-
seats
98-
};
99-
var bindings = new MessageTemplateWhatsAppBindings(
100-
header: new[] { image.Name },
101-
body: new[] { title.Name, time.Name, venue.Name, seats.Name });
102-
MessageTemplate movieTicketConfirmationTemplate = new MessageTemplate(templateName, templateLanguage, values, bindings);
93+
94+
WhatsAppMessageTemplateBindings bindings = new();
95+
bindings.Header.Add(new(image.Name));
96+
bindings.Body.Add(new(title.Name));
97+
bindings.Body.Add(new(time.Name));
98+
bindings.Body.Add(new(venue.Name));
99+
bindings.Body.Add(new(seats.Name));
100+
101+
MessageTemplate movieTicketConfirmationTemplate = new(templateName, templateLanguage);
102+
movieTicketConfirmationTemplate.Values.Add(image);
103+
movieTicketConfirmationTemplate.Values.Add(title);
104+
movieTicketConfirmationTemplate.Values.Add(time);
105+
movieTicketConfirmationTemplate.Values.Add(venue);
106+
movieTicketConfirmationTemplate.Values.Add(seats);
107+
movieTicketConfirmationTemplate.Bindings = bindings;
103108
``````
104109
105110
### Use sample template sample_happy_hour_announcement
106111
107112
This sample template uses a video in the header and two text parameters in the body.
108113
109-
:::image type="content" source="./../media/template-messages/sample-happy-hour-announcement-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_happy_hour_announcement.":::
114+
:::image type="content" source="./../media/template-messages/sample-happy-hour-announcement-details-azure-portal.png" lightbox="./../media/template-messages/sample-happy-hour-announcement-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_happy_hour_announcement.":::
110115
111116
Here, the header of the template requires a video:
112117
```
@@ -135,25 +140,23 @@ var videoUrl = new Uri("< Your .mp4 Video URL >");
135140
var video = new MessageTemplateVideo("video", videoUrl);
136141
var venue = new MessageTemplateText("venue", "Fourth Coffee");
137142
var time = new MessageTemplateText("time", "Today 2-4PM");
138-
139-
IEnumerable<MessageTemplateValue> values = new List<MessageTemplateValue>
140-
{
141-
video,
142-
venue,
143-
time
144-
};
145-
var bindings = new MessageTemplateWhatsAppBindings(
146-
header: new[] { video.Name },
147-
body: new[] { venue.Name, time.Name });
148-
149-
var happyHourAnnouncementTemplate = MessageTemplate(templateName, templateLanguage, values, bindings);
143+
WhatsAppMessageTemplateBindings bindings = new();
144+
bindings.Header.Add(new(video.Name));
145+
bindings.Body.Add(new(venue.Name));
146+
bindings.Body.Add(new(time.Name));
147+
148+
MessageTemplate happyHourAnnouncementTemplate = new(templateName, templateLanguage);
149+
happyHourAnnouncementTemplate.Values.Add(venue);
150+
happyHourAnnouncementTemplate.Values.Add(time);
151+
happyHourAnnouncementTemplate.Values.Add(video);
152+
happyHourAnnouncementTemplate.Bindings = bindings;
150153
``````
151154
152155
### Use sample template sample_flight_confirmation
153156
154157
This sample template uses a document in the header and three text parameters in the body.
155158
156-
:::image type="content" source="./../media/template-messages/sample-flight-confirmation-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_flight_confirmation.":::
159+
:::image type="content" source="./../media/template-messages/sample-flight-confirmation-details-azure-portal.png" lightbox="./../media/template-messages/sample-flight-confirmation-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_flight_confirmation.":::
157160
158161
Here, the header of the template requires a document:
159162
```
@@ -184,25 +187,25 @@ var firstName = new MessageTemplateText("firstName", "Kat");
184187
var lastName = new MessageTemplateText("lastName", "Larssen");
185188
var date = new MessageTemplateText("date", "July 1st, 2023");
186189
187-
IEnumerable<MessageTemplateValue> values = new List<MessageTemplateValue>
188-
{
189-
document,
190-
firstName,
191-
lastName,
192-
date
193-
};
194-
var bindings = new MessageTemplateWhatsAppBindings(
195-
header: new[] { document.Name },
196-
body: new[] { firstName.Name, lastName.Name, date.Name });
197-
198-
var flightConfirmationTemplate = new MessageTemplate(templateName, templateLanguage, values, bindings);
190+
WhatsAppMessageTemplateBindings bindings = new();
191+
bindings.Header.Add(new(document.Name));
192+
bindings.Body.Add(new(firstName.Name));
193+
bindings.Body.Add(new(lastName.Name));
194+
bindings.Body.Add(new(date.Name));
195+
196+
MessageTemplate flightConfirmationTemplate = new(templateName, templateLanguage);
197+
flightConfirmationTemplate.Values.Add(document);
198+
flightConfirmationTemplate.Values.Add(firstName);
199+
flightConfirmationTemplate.Values.Add(lastName);
200+
flightConfirmationTemplate.Values.Add(date);
201+
flightConfirmationTemplate.Bindings = bindings;
199202
``````
200203
201204
### Use sample template sample_issue_resolution
202205
203206
This sample template adds two prefilled reply buttons to the message. It also includes one text parameter in the body.
204207
205-
:::image type="content" source="./../media/template-messages/sample-issue-resolution-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_issue_resolution.":::
208+
:::image type="content" source="./../media/template-messages/sample-issue-resolution-details-azure-portal.png" lightbox="./../media/template-messages/sample-issue-resolution-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_issue_resolution.":::
206209
207210
Here, the body of the template requires one text parameter:
208211
```
@@ -245,25 +248,19 @@ string templateName = "sample_issue_resolution";
245248
string templateLanguage = "en_us";
246249
247250
var name = new MessageTemplateText(name: "name", text: "Kat");
248-
var yes = new MessageTemplateQuickAction(name: "Yes", payload: "Kat said yes");
249-
var no = new MessageTemplateQuickAction(name: "No", payload: "Kat said no");
250-
251-
IEnumerable<MessageTemplateValue> values = new List<MessageTemplateValue>
252-
{
253-
name,
254-
yes,
255-
no
256-
};
257-
var bindings = new MessageTemplateWhatsAppBindings(
258-
body: new[] { name.Name },
259-
button: new[] {
260-
new KeyValuePair<string, MessageTemplateValueWhatsAppSubType>(yes.Name,
261-
MessageTemplateValueWhatsAppSubType.QuickReply),
262-
new KeyValuePair<string, MessageTemplateValueWhatsAppSubType>(no.Name,
263-
MessageTemplateValueWhatsAppSubType.QuickReply)
264-
});
265-
266-
var issueResolutionTemplate = new MessageTemplate(templateName, templateLanguage, values, bindings);
251+
var yes = new MessageTemplateQuickAction(name: "Yes"){ Payload = "Kat said yes" };
252+
var no = new MessageTemplateQuickAction(name: "No") { Payload = "Kat said no" };
253+
254+
WhatsAppMessageTemplateBindings bindings = new();
255+
bindings.Body.Add(new(name.Name));
256+
bindings.Buttons.Add(new(WhatsAppMessageButtonSubType.QuickReply.ToString(), yes.Name));
257+
bindings.Buttons.Add(new(WhatsAppMessageButtonSubType.QuickReply.ToString(), no.Name));
258+
259+
MessageTemplate issueResolutionTemplate = new(templateName, templateLanguage);
260+
issueResolutionTemplate.Values.Add(name);
261+
issueResolutionTemplate.Values.Add(yes);
262+
issueResolutionTemplate.Values.Add(no);
263+
issueResolutionTemplate.Bindings = bindings;
267264
``````
268265
269266
### Use sample template sample_purchase_feedback
@@ -273,10 +270,10 @@ This sample template adds a button with a dynamic URL link to the message. It al
273270
If using the precreated sample template `sample_purchase_feedback`, you need to modify the URL Type of its button from `Static` to `Dynamic`.
274271
Go to your [Message templates in the WhatsApp manager](https://business.facebook.com/wa/manage/message-templates/) and edit the template for `sample_purchase_feedback`. In the dropdown for URL Type, change it from `Static` to `Dynamic`. Include a sample URL if necessary.
275272
276-
:::image type="content" source="./../media/template-messages/edit-sample-purchase-feedback-whatsapp-manager.png" alt-text="Screenshot that shows editing URL Type in the WhatsApp manager.":::
273+
:::image type="content" source="./../media/template-messages/edit-sample-purchase-feedback-whatsapp-manager.png" lightbox="./../media/template-messages/edit-sample-purchase-feedback-whatsapp-manager.png" alt-text="Screenshot that shows editing URL Type in the WhatsApp manager.":::
277274
278275
Now, if you view the template details in the Azure portal, you see:
279-
:::image type="content" source="./../media/template-messages/sample-purchase-feedback-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_purchase_feedback.":::
276+
:::image type="content" source="./../media/template-messages/sample-purchase-feedback-details-azure-portal.png" lightbox="./../media/template-messages/sample-purchase-feedback-details-azure-portal.png" alt-text="Screenshot that shows template details for template named sample_purchase_feedback.":::
280277
281278
In this sample, the header of the template requires an image:
282279
```
@@ -327,22 +324,16 @@ var imageUrl = new Uri("https://aka.ms/acsicon1");
327324
328325
var image = new MessageTemplateImage(name: "image", uri: imageUrl);
329326
var product = new MessageTemplateText(name: "product", text: "coffee");
330-
var urlSuffix = new MessageTemplateQuickAction(name: "text", text: "survey-code");
331-
332-
IEnumerable<MessageTemplateValue> values = new List<MessageTemplateValue>
333-
{
334-
image,
335-
product,
336-
urlSuffix
337-
};
338-
var bindings = new MessageTemplateWhatsAppBindings(
339-
header: new[] { image.Name },
340-
body: new[] { product.Name },
341-
button: new[]
342-
{
343-
new KeyValuePair<string, MessageTemplateValueWhatsAppSubType>(urlSuffix.Name,
344-
MessageTemplateValueWhatsAppSubType.Url)
345-
});
346-
347-
var purchaseFeedbackTemplate = new MessageTemplate(templateName, templateLanguage, values, bindings);
327+
var urlSuffix = new MessageTemplateQuickAction(name: "text") { Text = "survey-code" };
328+
329+
WhatsAppMessageTemplateBindings bindings = new();
330+
bindings.Header.Add(new(image.Name));
331+
bindings.Body.Add(new(product.Name));
332+
bindings.Buttons.Add(new(WhatsAppMessageButtonSubType.Url.ToString(), urlSuffix.Name));
333+
334+
MessageTemplate purchaseFeedbackTemplate = new("sample_purchase_feedback", "en_us");
335+
purchaseFeedbackTemplate.Values.Add(image);
336+
purchaseFeedbackTemplate.Values.Add(product);
337+
purchaseFeedbackTemplate.Values.Add(urlSuffix);
338+
purchaseFeedbackTemplate.Bindings = bindings;
348339
``````

0 commit comments

Comments
 (0)