@azure-rest/communication-messages 2.0.1-alpha.20241216.1 → 2.0.1-alpha.20241219.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +105 -107
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -36,7 +36,7 @@ You can get a key and/or connection string from your Communication Services reso
36
36
  import MessageClient, { MessagesServiceClient } from "@azure-rest/communication-messages";
37
37
 
38
38
  const connectionString = `endpoint=https://<resource-name>.communication.azure.com/;accessKey=<Base64-Encoded-Key>`;
39
- const client:MessagesServiceClient = MessageClient(connectionString);
39
+ const client: MessagesServiceClient = MessageClient(connectionString);
40
40
  ```
41
41
 
42
42
  ### Using `AzureKeyCredential`
@@ -47,7 +47,7 @@ import MessageClient, { MessagesServiceClient } from "@azure-rest/communication-
47
47
 
48
48
  const endpoint = "https://<resource-name>.communication.azure.com";
49
49
  const credential = new AzureKeyCredential("<Base64-Encoded-Key>");
50
- const client:MessagesServiceClient = MessageClient(endpoint, credential);
50
+ const client: MessagesServiceClient = MessageClient(endpoint, credential);
51
51
  ```
52
52
 
53
53
  ### Using Azure Active Directory managed identity
@@ -67,87 +67,87 @@ import MessageClient, { MessagesServiceClient } from "@azure-rest/communication-
67
67
 
68
68
  const endpoint = "https://<resource-name>.communication.azure.com";
69
69
  const credential = new DefaultAzureCredential();
70
- const client:MessagesServiceClient = MessageClient(endpoint, credential);
70
+ const client: MessagesServiceClient = MessageClient(endpoint, credential);
71
71
  ```
72
72
 
73
73
  ## Send a Template Message with WhatsApp Channel
74
74
 
75
75
  `Note: Business always starts the conversation with a template message.`
76
76
 
77
- To send an Template Message, you need add template to your WhatsApp Bussiness Account. For more detail on WhatsApp Template, refer [Create and Manage Templates][create-manage-whatsapp-template]. In below example, we are using
77
+ To send an Template Message, you need add template to your WhatsApp Bussiness Account. For more detail on WhatsApp Template, refer [Create and Manage Templates][create-manage-whatsapp-template]. In below example, we are using
78
78
 
79
79
  ```
80
80
  Template Name: sample_issue_resolution
81
81
  Template Language: en_US
82
82
 
83
83
  Template Body: "Hi {{1}}, were we able to solve the issue that you were facing?"
84
-
84
+
85
85
  With Quick Action Button (Yes, No)
86
86
 
87
87
  ```
88
88
 
89
89
  ```typescript
90
- const nameValue:MessageTemplateValue = {
91
- kind: "text",
92
- name: "name",
93
- text: "Arif"
94
- };
95
-
96
- const yesAction: MessageTemplateValue = {
97
- kind: "quickAction",
98
- name: "Yes",
99
- payload: "Yes"
100
- };
101
-
102
- const noAction: MessageTemplateValue = {
103
- kind: "quickAction",
104
- name: "No",
105
- payload: "No"
106
- };
107
-
108
- const templateBindings:MessageTemplateBindings = {
109
- kind: "whatsApp",
110
- body: [
111
- {
112
- refValue: "name"
113
- }
114
- ],
115
- buttons: [
116
- {
117
- subType: "quickReply",
118
- refValue: "Yes"
119
- },
120
- {
121
- subType: "quickReply",
122
- refValue: "No"
123
- }
124
- ]
125
- };
126
-
127
- const template:MessageTemplate = {
128
- name: "sample_issue_resolution",
129
- language: "en_US",
130
- bindings: templateBindings,
131
- values: [nameValue, yesAction, noAction]
132
- };
133
-
134
- const result = await client.path("/messages/notifications:send").post({
135
- contentType: "application/json",
136
- body: {
137
- channelRegistrationId: "<Channel_Registration_Id>",
138
- to: ["<to-phone-number-1>"],
139
- kind: "template",
140
- template: template
141
- }
142
- });
143
- if (result.status === "202") {
144
- const response:Send202Response = result as Send202Response;
145
- response.body.receipts.forEach((receipt) => {
146
- console.log("Message sent to:"+receipt.to+" with message id:"+receipt.messageId);
147
- });
148
- } else {
149
- throw new Error("Failed to send message");
150
- }
90
+ const nameValue: MessageTemplateValue = {
91
+ kind: "text",
92
+ name: "name",
93
+ text: "Arif",
94
+ };
95
+
96
+ const yesAction: MessageTemplateValue = {
97
+ kind: "quickAction",
98
+ name: "Yes",
99
+ payload: "Yes",
100
+ };
101
+
102
+ const noAction: MessageTemplateValue = {
103
+ kind: "quickAction",
104
+ name: "No",
105
+ payload: "No",
106
+ };
107
+
108
+ const templateBindings: MessageTemplateBindings = {
109
+ kind: "whatsApp",
110
+ body: [
111
+ {
112
+ refValue: "name",
113
+ },
114
+ ],
115
+ buttons: [
116
+ {
117
+ subType: "quickReply",
118
+ refValue: "Yes",
119
+ },
120
+ {
121
+ subType: "quickReply",
122
+ refValue: "No",
123
+ },
124
+ ],
125
+ };
126
+
127
+ const template: MessageTemplate = {
128
+ name: "sample_issue_resolution",
129
+ language: "en_US",
130
+ bindings: templateBindings,
131
+ values: [nameValue, yesAction, noAction],
132
+ };
133
+
134
+ const result = await client.path("/messages/notifications:send").post({
135
+ contentType: "application/json",
136
+ body: {
137
+ channelRegistrationId: "<Channel_Registration_Id>",
138
+ to: ["<to-phone-number-1>"],
139
+ kind: "template",
140
+ template: template,
141
+ },
142
+ });
143
+ if (result.status === "202") {
144
+ const response: Send202Response = result as Send202Response;
145
+ response.body.receipts.forEach((receipt) => {
146
+ console.log("Message sent to:" + receipt.to + " with message id:" + receipt.messageId);
147
+ });
148
+ } else {
149
+ throw new Error("Failed to send message");
150
+ }
151
151
  ```
152
152
 
153
153
  ## Send a Text Message with WhatsApp Channel
@@ -155,24 +155,24 @@ const nameValue:MessageTemplateValue = {
155
155
  `Note: Business can't start a conversation with a text message. It needs to be user initiated.`
156
156
 
157
157
  ```typescript
158
- const result = await client.path("/messages/notifications:send").post({
159
- contentType: "application/json",
160
- body: {
161
- channelRegistrationId: "<Channel_Registration_Id>",
162
- to: ["<to-phone-number-1>"],
163
- kind: "text",
164
- content: "Hello World!!"
165
- }
166
- });
167
-
168
- if (result.status === "202") {
169
- const response:Send202Response = result as Send202Response;
170
- response.body.receipts.forEach((receipt) => {
171
- console.log("Message sent to:"+receipt.to+" with message id:"+receipt.messageId);
172
- });
173
- } else {
174
- throw new Error("Failed to send message");
175
- }
158
+ const result = await client.path("/messages/notifications:send").post({
159
+ contentType: "application/json",
160
+ body: {
161
+ channelRegistrationId: "<Channel_Registration_Id>",
162
+ to: ["<to-phone-number-1>"],
163
+ kind: "text",
164
+ content: "Hello World!!",
165
+ },
166
+ });
167
+
168
+ if (result.status === "202") {
169
+ const response: Send202Response = result as Send202Response;
170
+ response.body.receipts.forEach((receipt) => {
171
+ console.log("Message sent to:" + receipt.to + " with message id:" + receipt.messageId);
172
+ });
173
+ } else {
174
+ throw new Error("Failed to send message");
175
+ }
176
176
  ```
177
177
 
178
178
  ## Send a Media Message with WhatsApp Channel
@@ -180,27 +180,26 @@ const result = await client.path("/messages/notifications:send").post({
180
180
  `Note: Business can't start a conversation with a media message. It needs to be user initiated.`
181
181
 
182
182
  ```typescript
183
- const result = await client.path("/messages/notifications:send").post({
184
- contentType: "application/json",
185
- body: {
186
- channelRegistrationId: "<Channel_Registration_Id>",
187
- to: ["<to-phone-number-1>"],
188
- kind: "image",
189
- mediaUri: "https://<your-media-image-file>"
190
- }
191
- });
192
-
193
- if (result.status === "202") {
194
- const response:Send202Response = result as Send202Response;
195
- response.body.receipts.forEach((receipt) => {
196
- console.log("Message sent to:"+receipt.to+" with message id:"+receipt.messageId);
197
- });
198
- } else {
199
- throw new Error("Failed to send message");
200
- }
183
+ const result = await client.path("/messages/notifications:send").post({
184
+ contentType: "application/json",
185
+ body: {
186
+ channelRegistrationId: "<Channel_Registration_Id>",
187
+ to: ["<to-phone-number-1>"],
188
+ kind: "image",
189
+ mediaUri: "https://<your-media-image-file>",
190
+ },
191
+ });
192
+
193
+ if (result.status === "202") {
194
+ const response: Send202Response = result as Send202Response;
195
+ response.body.receipts.forEach((receipt) => {
196
+ console.log("Message sent to:" + receipt.to + " with message id:" + receipt.messageId);
197
+ });
198
+ } else {
199
+ throw new Error("Failed to send message");
200
+ }
201
201
  ```
202
202
 
203
-
204
203
  ## Troubleshooting
205
204
 
206
205
  ### Logging
@@ -223,19 +222,18 @@ Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/bl
223
222
 
224
223
  If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
225
224
 
226
-
227
225
  ## Related projects
228
226
 
229
227
  - [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)
230
228
 
231
- [azure_cli]: https://docs.microsoft.com/cli/azure
229
+ [azure_cli]: https://learn.microsoft.com/cli/azure
232
230
  [azure_sub]: https://azure.microsoft.com/free/
233
231
  [azure_portal]: https://portal.azure.com
234
- [azure_powershell]: https://docs.microsoft.com/powershell/module/az.communication/new-azcommunicationservice
232
+ [azure_powershell]: https://learn.microsoft.com/powershell/module/az.communication/new-azcommunicationservice
235
233
  [defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
236
234
  [azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity
237
235
  [azure_communication_messaging_qs]: https://learn.microsoft.com/azure/communication-services/concepts/advanced-messaging/whatsapp/whatsapp-overview
238
236
  [register_whatsapp_business_account]: https://learn.microsoft.com/azure/communication-services/quickstarts/advanced-messaging/whatsapp/connect-whatsapp-business-account
239
237
  [create-manage-whatsapp-template]: https://developers.facebook.com/docs/whatsapp/business-management-api/message-templates/
240
238
 
241
- ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcommunication%2Fcommunication-sms%2FREADME.png)
239
+ ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcommunication%2Fcommunication-sms%2FREADME.png)
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@azure-rest/communication-messages",
3
3
  "sdk-type": "client",
4
4
  "author": "Microsoft Corporation",
5
- "version": "2.0.1-alpha.20241216.1",
5
+ "version": "2.0.1-alpha.20241219.1",
6
6
  "description": "Azure client library for Azure Communication Messages services",
7
7
  "keywords": [
8
8
  "node",
@@ -82,7 +82,7 @@
82
82
  "eslint": "^9.9.0",
83
83
  "karma-source-map-support": "~1.4.0",
84
84
  "playwright": "^1.48.2",
85
- "typescript": "~5.6.2",
85
+ "typescript": "~5.7.2",
86
86
  "vitest": "^2.1.5"
87
87
  },
88
88
  "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest-rest/README.md",