Skip to content

Commit 7ec0014

Browse files
authored
Add acs whatsapp interactive message (Azure#32585)
### Packages impacted by this PR @azure-rest/communication-messages ### Issues associated with this PR New feature is added for ACS WhatsApp Channel, Issue is tracked by internal ticket. ### Describe the problem that is addressed by this PR - Added Interactive Message. - Added Reaction Message. - Added Sticker Message. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ Yes ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [x] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [x] Added a changelog (if necessary)
1 parent dbc07dc commit 7ec0014

File tree

84 files changed

+4243
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+4243
-365
lines changed

.github/CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
# ServiceLabel: %Communication - Job Router
9292
/sdk/communication/communication-job-router-rest/ @marche0133
9393

94+
# PRLabel: %Communication - Messages
95+
# ServiceLabel: %Communication - Messages
96+
/sdk/communication/communication-messages-rest/ @arifibrahim4 @juancamilor @glorialimicrosoft @Shamkh
97+
9498
# PRLabel: %Communication - Phone Numbers
9599
# ServiceLabel: %Communication - Phone Numbers
96100
/sdk/communication/communication-phone-numbers/ @miguhern @whisper6284 @danielav7

sdk/communication/communication-messages-rest/CHANGELOG.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
# Release History
22

3-
## 2.0.1 (Unreleased)
3+
## 2.1.0-beta.1 (2025-02-11)
44

55
### Features Added
66

7-
### Breaking Changes
8-
9-
### Bugs Fixed
10-
11-
### Other Changes
7+
- Added Interactive Message.
8+
- Added Reaction Message.
9+
- Added Sticker Message.
1210

1311
## 2.0.0 (2024-10-23)
1412

sdk/communication/communication-messages-rest/README.md

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,169 @@ if (!isUnexpected(result)) {
213213
}
214214
```
215215

216+
## Send a Button Action Interactive Message with WhatsApp Channel
217+
218+
`Note: Business can't start a conversation with a media message. It needs to be user initiated.`
219+
220+
```typescript
221+
const interactiveMessage: InteractiveMessage = {
222+
body: {
223+
kind: "text",
224+
text: "Do you want to proceed?",
225+
},
226+
action: {
227+
kind: "whatsAppButtonAction",
228+
content: {
229+
kind: "buttonSet",
230+
buttons: [
231+
{
232+
id: "yes",
233+
title: "Yes",
234+
},
235+
{
236+
id: "no",
237+
title: "No",
238+
},
239+
]
240+
}
241+
}
242+
};
243+
244+
const result = await client.path("/messages/notifications:send").post({
245+
contentType: "application/json",
246+
body: {
247+
channelRegistrationId: "<Channel_Registration_Id>",
248+
to: ["<to-phone-number-1>"],
249+
kind: "interactive",
250+
interactiveMessage: interactiveMessage,
251+
},
252+
});
253+
254+
if (result.status === "202") {
255+
const response: Send202Response = result as Send202Response;
256+
response.body.receipts.forEach((receipt) => {
257+
console.log("Message sent to:" + receipt.to + " with message id:" + receipt.messageId);
258+
});
259+
} else {
260+
throw new Error("Failed to send message");
261+
}
262+
```
263+
264+
## Send a List Action Interactive Message with WhatsApp Channel
265+
266+
`Note: Business can't start a conversation with a media message. It needs to be user initiated.`
267+
268+
```typescript
269+
const interactiveMessage: InteractiveMessage = {
270+
body: {
271+
kind: "text",
272+
text: "Which shipping option do you want?",
273+
},
274+
action: {
275+
kind: "whatsAppListAction",
276+
content: {
277+
kind: "group",
278+
title: "Shipping Options",
279+
groups:[
280+
{
281+
title: "Express Delivery",
282+
items: [
283+
{
284+
id: "priority_mail_express",
285+
title: "Priority Mail Express",
286+
description: "Delivered on same day!",
287+
},
288+
{
289+
id: "priority_mail",
290+
title: "Priority Mail",
291+
description: "Delivered in 1-2 days",
292+
}
293+
]
294+
},
295+
{
296+
title: "Normal Delivery",
297+
items: [
298+
{
299+
id: "usps_ground_advantage",
300+
title: "USPS Ground Advantage",
301+
description: "Delivered in 2-5 days",
302+
},
303+
{
304+
id: "usps_mail",
305+
title: "Normal Mail",
306+
description: "Delivered in 5-8 days",
307+
}
308+
]
309+
}
310+
]
311+
}
312+
}
313+
};
314+
315+
const result = await client.path("/messages/notifications:send").post({
316+
contentType: "application/json",
317+
body: {
318+
channelRegistrationId: "<Channel_Registration_Id>",
319+
to: ["<to-phone-number-1>"],
320+
kind: "interactive",
321+
interactiveMessage: interactiveMessage,
322+
},
323+
});
324+
325+
if (result.status === "202") {
326+
const response: Send202Response = result as Send202Response;
327+
response.body.receipts.forEach((receipt) => {
328+
console.log("Message sent to:" + receipt.to + " with message id:" + receipt.messageId);
329+
});
330+
} else {
331+
throw new Error("Failed to send message");
332+
}
333+
```
334+
335+
## Send a Url Action Interactive Message with WhatsApp Channel
336+
337+
`Note: Business can't start a conversation with a media message. It needs to be user initiated.`
338+
339+
```typescript
340+
const interactiveMessage: InteractiveMessage = {
341+
body: {
342+
kind: "text",
343+
text: "Find more detail in the link.",
344+
},
345+
action: {
346+
kind: "whatsAppUrlAction",
347+
content: {
348+
kind: "url",
349+
title: "link",
350+
url: "https://<your-url-link>",
351+
}
352+
},
353+
footer: {
354+
kind: "text",
355+
text: "This is a footer message",
356+
}
357+
};
358+
359+
const result = await client.path("/messages/notifications:send").post({
360+
contentType: "application/json",
361+
body: {
362+
channelRegistrationId: "<Channel_Registration_Id>",
363+
to: ["<to-phone-number-1>"],
364+
kind: "interactive",
365+
interactiveMessage: interactiveMessage,
366+
},
367+
});
368+
369+
if (result.status === "202") {
370+
const response: Send202Response = result as Send202Response;
371+
response.body.receipts.forEach((receipt) => {
372+
console.log("Message sent to:" + receipt.to + " with message id:" + receipt.messageId);
373+
});
374+
} else {
375+
throw new Error("Failed to send message");
376+
}
377+
```
378+
216379
## Troubleshooting
217380

218381
### Logging

sdk/communication/communication-messages-rest/assets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"AssetsRepo": "Azure/azure-sdk-assets",
33
"AssetsRepoPrefixPath": "js",
44
"TagPrefix": "js/communication/communication-messages-rest",
5-
"Tag": "js/communication/communication-messages-rest_2ccfd5f35e"
5+
"Tag": "js/communication/communication-messages-rest_11b23d0f82"
66
}

sdk/communication/communication-messages-rest/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@azure-rest/communication-messages",
33
"sdk-type": "client",
44
"author": "Microsoft Corporation",
5-
"version": "2.0.1",
5+
"version": "2.1.0-beta.1",
66
"description": "Azure client library for Azure Communication Messages services",
77
"keywords": [
88
"node",

0 commit comments

Comments
 (0)