You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Quickstart: Send WhatsApp Messages using Advanced Messages
17
17
18
18
Azure Communication Services enables you to send and receive WhatsApp messages. In this quickstart, get started integrating your app with Azure Communication Advanced Messages SDK and start sending/receiving WhatsApp messages. Completing this quickstart incurs a small cost of a few USD cents or less in your Azure account.
19
19
@@ -29,6 +29,10 @@ Azure Communication Services enables you to send and receive WhatsApp messages.
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/get-started/messages-get-started-java.md
+21-4Lines changed: 21 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -235,6 +235,14 @@ First, create a MessageTemplate using the values for a template.
235
235
Here's MessageTemplate creation using a default template, `sample_template`.
236
236
If `sample_template` isn't available to you, skip to [Option 2](#option-2-initiate-conversation-from-user). For advanced users, see the page [Templates](../../../../../concepts/advanced-messaging/whatsapp/template-messages.md) to understand how to send a different template with Option 1.
237
237
238
+
Messages SDK allows Contoso to send templated WhatsApp messages to WhatsApp users. To send template messages below details are required:
-[Recipient Phone Number in E16 format](#set-recipient-list)
241
+
- Template details
242
+
- Name like 'sample_template'
243
+
- Language like 'en_us'
244
+
- Parameters if any
245
+
238
246
```java
239
247
// Assemble the template content
240
248
String templateName ="sample_template";
@@ -267,15 +275,20 @@ To do so, from your personal WhatsApp account, send a message to your business n
267
275
268
276
### Send a text message to a WhatsApp user
269
277
278
+
Messages SDK allows Contoso to send text WhatsApp messages, which initiated WhatsApp users initiated. To send text messages below details are required:
-[Recipient Phone Number in E16 format](#set-recipient-list)
281
+
- Message body/text to be sent
282
+
270
283
> [!IMPORTANT]
271
284
> To send a text message to a WhatsApp user, the WhatsApp user must first send a message to the WhatsApp Business Account. For more information, see [Start sending messages between business and WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
272
285
273
-
In the text message, provide text to send to the recipient. In this example, we reply to the WhatsApp user with the text "Thanks for your feedback.".
286
+
In this example, we reply to the WhatsApp user with the text "Thanks for your feedback.\n From Notification Messaging SDK".
274
287
275
288
Assemble then send the text message:
276
289
```java
277
290
// Assemble text message
278
-
TextNotificationContent textContent =newTextNotificationContent(channelRegistrationId, recipientList, "“Thanks for your feedback.");
291
+
TextNotificationContent textContent =newTextNotificationContent(channelRegistrationId, recipientList, "“Thanks for your feedback.\n From Notification Messaging SDK");
-[Recipient Phone Number in E16 format](#set-recipient-list)
307
+
- MediaUri of the Image
308
+
291
309
> [!IMPORTANT]
292
310
> To send a text message to a WhatsApp user, the WhatsApp user must first send a message to the WhatsApp Business Account. For more information, see [Start sending messages between business and WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
293
311
294
-
To send a media message, provide a URI to an image.
295
312
As an example, create a URI:
296
313
```java
297
314
String mediaUrl ="https://aka.ms/acsicon1";
@@ -325,7 +342,7 @@ for (MessageReceipt messageReceipt : mediaMessageResult.getReceipts()) {
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure/azure-sdk-for-java/tree/d668cb44f64d303e71d2ee72a8b0382896aa09d5/sdk/communication/azure-communication-messages/src/samples/java/com/azure/communication/messages).
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/get-started/messages-get-started-js.md
+22-3Lines changed: 22 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -238,6 +238,15 @@ First, create a MessageTemplate using the values for a template.
238
238
239
239
Here's MessageTemplate creation using a default template, `sample_template`.
240
240
If `sample_template` isn't available to you, skip to [Option 2](#option-2-initiate-conversation-from-user). For advanced users, see the page [Templates](../../../../../concepts/advanced-messaging/whatsapp/template-messages.md) to understand how to send a different template with Option 1.
241
+
242
+
Messages SDK allows Contoso to send templated WhatsApp messages to WhatsApp users. To send template messages below details are required:
-[Recipient Phone Number in E16 format](#set-recipient-list)
245
+
- Template details
246
+
- Name like 'sample_template'
247
+
- Language like 'en_us'
248
+
- Parameters if any
249
+
241
250
```javascript
242
251
// Assemble the template content
243
252
consttemplate= {
@@ -290,10 +299,15 @@ To do so, from your personal WhatsApp account, send a message to your business n
290
299
291
300
### Send a text message to a WhatsApp user
292
301
302
+
Messages SDK allows Contoso to send text WhatsApp messages, which initiated WhatsApp users initiated. To send text messages below details are required:
-[Recipient Phone Number in E16 format](#set-recipient-list)
305
+
- Message body/text to be sent
306
+
293
307
> [!IMPORTANT]
294
308
> To send a text message to a WhatsApp user, the WhatsApp user must first send a message to the WhatsApp Business Account. For more information, see [Start sending messages between business and WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
295
309
296
-
In the text message, provide text to send to the recipient. In this example, we reply to the WhatsApp user with the text "Thanks for your feedback.".
310
+
In this example, we reply to the WhatsApp user with the text "Thanks for your feedback.\n From Notification Messaging SDK".
-[Recipient Phone Number in E16 format](#set-recipient-list)
340
+
- MediaUri of the Image
341
+
323
342
> [!IMPORTANT]
324
343
> To send a text message to a WhatsApp user, the WhatsApp user must first send a message to the WhatsApp Business Account. For more information, see [Start sending messages between business and WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
325
344
@@ -359,7 +378,7 @@ Use the node command to run the code you added to the send-messages.js file.
359
378
node ./send-messages.js
360
379
```
361
380
362
-
## Sample code
381
+
## Full sample code
363
382
364
383
You can download the sample app from [GitHub](https://github.com/Azure/azure-sdk-for-js/tree/7efc61a0414c6f898409e355d0ba8d228882625f/sdk/communication/communication-messages-rest/samples-dev).
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/get-started/messages-get-started-net.md
+23-5Lines changed: 23 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -290,6 +290,15 @@ First, create a MessageTemplate using the values for a template.
290
290
291
291
Here's MessageTemplate creation using a default template, `sample_template`.
292
292
If `sample_template` isn't available to you, skip to [Option 2](#option-2-initiate-conversation-from-user). For advanced users, see the page [Templates](../../../../../concepts/advanced-messaging/whatsapp/template-messages.md) to understand how to send a different template with Option 1.
293
+
294
+
Messages SDK allows Contoso to send templated WhatsApp messages to WhatsApp users. To send template messages below details are required:
-[Recipient Phone Number in E16 format](#set-recipient-list)
297
+
- Template details
298
+
- Name like 'sample_template'
299
+
- Language like 'en_us'
300
+
- Parameters if any
301
+
293
302
```csharp
294
303
// Assemble the template content
295
304
stringtemplateName="sample_template";
@@ -330,16 +339,21 @@ To do so, from your personal WhatsApp account, send a message to your business n
330
339
331
340
### Send a text message to a WhatsApp user
332
341
342
+
Messages SDK allows Contoso to send text WhatsApp messages, which initiated WhatsApp users initiated. To send text messages below details are required:
-[Recipient Phone Number in E16 format](#set-recipient-list)
345
+
- Message body/text to be sent
346
+
333
347
> [!IMPORTANT]
334
348
> To send a text message to a WhatsApp user, the WhatsApp user must first send a message to the WhatsApp Business Account. For more information, see [Start sending messages between business and WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
335
349
336
-
In the text message, provide text to send to the recipient. In this example, we reply to the WhatsApp user with the text "Thanks for your feedback.".
350
+
In this example, we reply to the WhatsApp user with the text "Thanks for your feedback.\n From Notification Messaging SDK".
337
351
338
352
Assemble then send the text message:
339
353
```csharp
340
354
// Assemble text message
341
355
vartextContent=
342
-
newTextNotificationContent(channelRegistrationId, recipientList, "Thanks for your feedback.");
356
+
newTextNotificationContent(channelRegistrationId, recipientList, "Thanks for your feedback.\n From Notification Messaging SDK");
-[Recipient Phone Number in E16 format](#set-recipient-list)
368
+
- MediaUri of the Image
369
+
351
370
> [!IMPORTANT]
352
371
> To send a text message to a WhatsApp user, the WhatsApp user must first send a message to the WhatsApp Business Account. For more information, see [Start sending messages between business and WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
353
372
354
-
To send a media message, provide a URI to an image.
To send a text or media message to a WhatsApp user, there must be an active conversation between the WhatsApp Business Account and the WhatsApp user.
376
-
If you don't have an active conversation, for the purposes of this quickstart, you should add a wait between sending the template message and sending the text message. This added delay gives you enough time to reply to the business on the user's WhatsApp account. For reference, the full example at [Sample code](#sample-code) prompts for manual user input before sending the next message.
394
+
If you don't have an active conversation, for the purposes of this quickstart, you should add a wait between sending the template message and sending the text message. This added delay gives you enough time to reply to the business on the user's WhatsApp account. For reference, the full example at [Sample code](#full-sample-code) prompts for manual user input before sending the next message.
377
395
378
396
If successful, you receive three messages on the user's WhatsApp account.
379
397
@@ -400,6 +418,6 @@ dotnet run
400
418
401
419
---
402
420
403
-
## Sample code
421
+
## Full sample code
404
422
405
423
[!INCLUDE [Full code example with .NET](./messages-get-started-full-example-net.md)]
0 commit comments