Skip to content

Commit 351b17b

Browse files
authored
Merge pull request #268588 from Shamkh/CPMPythonDocs
Advanced Messages Python quickstart.
2 parents cac2054 + 6f7927f commit 351b17b

File tree

5 files changed

+559
-14
lines changed

5 files changed

+559
-14
lines changed

articles/communication-services/quickstarts/advanced-messaging/whatsapp/get-started.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ ms.date: 02/29/2024
1010
ms.topic: quickstart
1111
ms.service: azure-communication-services
1212
ms.custom: devx-track-extended-java, devx-track-js
13-
zone_pivot_groups: acs-js-csharp-java
13+
zone_pivot_groups: acs-js-csharp-java-python
1414
---
1515

16-
# Quickstart: Add Advanced Messaging to your app
16+
# Quickstart: Send WhatsApp Messages using Advanced Messages
1717

1818
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.
1919

@@ -29,6 +29,10 @@ Azure Communication Services enables you to send and receive WhatsApp messages.
2929
[!INCLUDE [Send WhatsApp Messages JavaScript SDK](./includes/get-started/messages-get-started-js.md)]
3030
::: zone-end
3131

32+
::: zone pivot="programming-language-python"
33+
[!INCLUDE [Send WhatsApp Messages Python SDK](./includes/get-started/messages-quickstart-python.md)]
34+
::: zone-end
35+
3236
## Next steps
3337

3438
In this quickstart, you tried out the Advanced Messaging for WhatsApp SDK. Next you might also want to see the following articles:

articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/get-started/messages-get-started-java.md

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,14 @@ First, create a MessageTemplate using the values for a template.
235235
Here's MessageTemplate creation using a default template, `sample_template`.
236236
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.
237237

238+
Messages SDK allows Contoso to send templated WhatsApp messages to WhatsApp users. To send template messages below details are required:
239+
- [WhatsApp Channel ID](#set-channel-registration-id)
240+
- [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+
238246
```java
239247
// Assemble the template content
240248
String templateName = "sample_template";
@@ -267,15 +275,20 @@ To do so, from your personal WhatsApp account, send a message to your business n
267275

268276
### Send a text message to a WhatsApp user
269277

278+
Messages SDK allows Contoso to send text WhatsApp messages, which initiated WhatsApp users initiated. To send text messages below details are required:
279+
- [WhatsApp Channel ID](#set-channel-registration-id)
280+
- [Recipient Phone Number in E16 format](#set-recipient-list)
281+
- Message body/text to be sent
282+
270283
> [!IMPORTANT]
271284
> 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).
272285
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".
274287

275288
Assemble then send the text message:
276289
```java
277290
// Assemble text message
278-
TextNotificationContent textContent = new TextNotificationContent(channelRegistrationId, recipientList, "“Thanks for your feedback.");
291+
TextNotificationContent textContent = new TextNotificationContent(channelRegistrationId, recipientList, "“Thanks for your feedback.\n From Notification Messaging SDK");
279292

280293
// Send text message
281294
SendMessageResult textMessageResult = notificationClient.send(textContent);
@@ -288,10 +301,14 @@ for (MessageReceipt messageReceipt : textMessageResult.getReceipts()) {
288301

289302
### Send a media message to a WhatsApp user
290303

304+
Messages SDK allows Contoso to send Image WhatsApp messages to WhatsApp users. To send Image embedded messages below details are required:
305+
- [WhatsApp Channel ID](#set-channel-registration-id)
306+
- [Recipient Phone Number in E16 format](#set-recipient-list)
307+
- MediaUri of the Image
308+
291309
> [!IMPORTANT]
292310
> 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).
293311
294-
To send a media message, provide a URI to an image.
295312
As an example, create a URI:
296313
```java
297314
String mediaUrl = "https://aka.ms/acsicon1";
@@ -325,7 +342,7 @@ for (MessageReceipt messageReceipt : mediaMessageResult.getReceipts()) {
325342
mvn exec:java -D"exec.mainClass"="com.communication.quickstart.App" -D"exec.cleanupDaemonThreads"="false"
326343
```
327344

328-
## Sample code
345+
## Full sample code
329346

330347
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).
331348

articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/get-started/messages-get-started-js.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,15 @@ First, create a MessageTemplate using the values for a template.
238238
239239
Here's MessageTemplate creation using a default template, `sample_template`.
240240
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:
243+
- [WhatsApp Channel ID](#set-channel-registration-id)
244+
- [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+
241250
```javascript
242251
// Assemble the template content
243252
const template = {
@@ -290,10 +299,15 @@ To do so, from your personal WhatsApp account, send a message to your business n
290299

291300
### Send a text message to a WhatsApp user
292301

302+
Messages SDK allows Contoso to send text WhatsApp messages, which initiated WhatsApp users initiated. To send text messages below details are required:
303+
- [WhatsApp Channel ID](#set-channel-registration-id)
304+
- [Recipient Phone Number in E16 format](#set-recipient-list)
305+
- Message body/text to be sent
306+
293307
> [!IMPORTANT]
294308
> 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).
295309
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".
297311

298312
Assemble and send the media message:
299313
```javascript
@@ -304,7 +318,7 @@ const textMessageResult = await client.path("/messages/notifications:send").post
304318
channelRegistrationId: channelRegistrationId,
305319
to: recipientList,
306320
kind: "text",
307-
content: "Thanks for your feedback."
321+
content: "Thanks for your feedback.\n From Notification Messaging SDK"
308322
}
309323
});
310324

@@ -320,6 +334,11 @@ if (textMessageResult.status === "202") {
320334

321335
### Send a media message to a WhatsApp user
322336

337+
Messages SDK allows Contoso to send Image WhatsApp messages to WhatsApp users. To send Image embedded messages below details are required:
338+
- [WhatsApp Channel ID](#set-channel-registration-id)
339+
- [Recipient Phone Number in E16 format](#set-recipient-list)
340+
- MediaUri of the Image
341+
323342
> [!IMPORTANT]
324343
> 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).
325344
@@ -359,7 +378,7 @@ Use the node command to run the code you added to the send-messages.js file.
359378
node ./send-messages.js
360379
```
361380

362-
## Sample code
381+
## Full sample code
363382

364383
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).
365384

articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/get-started/messages-get-started-net.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,15 @@ First, create a MessageTemplate using the values for a template.
290290
291291
Here's MessageTemplate creation using a default template, `sample_template`.
292292
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:
295+
- [WhatsApp Channel ID](#set-channel-registration-id)
296+
- [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+
293302
```csharp
294303
// Assemble the template content
295304
string templateName = "sample_template";
@@ -330,16 +339,21 @@ To do so, from your personal WhatsApp account, send a message to your business n
330339

331340
### Send a text message to a WhatsApp user
332341

342+
Messages SDK allows Contoso to send text WhatsApp messages, which initiated WhatsApp users initiated. To send text messages below details are required:
343+
- [WhatsApp Channel ID](#set-channel-registration-id)
344+
- [Recipient Phone Number in E16 format](#set-recipient-list)
345+
- Message body/text to be sent
346+
333347
> [!IMPORTANT]
334348
> 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).
335349
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".
337351

338352
Assemble then send the text message:
339353
```csharp
340354
// Assemble text message
341355
var textContent =
342-
new TextNotificationContent(channelRegistrationId, recipientList, "Thanks for your feedback.");
356+
new TextNotificationContent(channelRegistrationId, recipientList, "Thanks for your feedback.\n From Notification Messaging SDK");
343357

344358
// Send text message
345359
Response<SendMessageResult> sendTextMessageResult =
@@ -348,10 +362,14 @@ Response<SendMessageResult> sendTextMessageResult =
348362

349363
### Send a media message to a WhatsApp user
350364

365+
Messages SDK allows Contoso to send Image WhatsApp messages to WhatsApp users. To send Image embedded messages below details are required:
366+
- [WhatsApp Channel ID](#set-channel-registration-id)
367+
- [Recipient Phone Number in E16 format](#set-recipient-list)
368+
- MediaUri of the Image
369+
351370
> [!IMPORTANT]
352371
> 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).
353372
354-
To send a media message, provide a URI to an image.
355373
As an example, create a URI:
356374
```csharp
357375
var uri = new Uri("https://aka.ms/acsicon1");
@@ -373,7 +391,7 @@ Response<SendMessageResult> sendMediaMessageResult =
373391
Build and run your program.
374392

375393
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.
377395

378396
If successful, you receive three messages on the user's WhatsApp account.
379397

@@ -400,6 +418,6 @@ dotnet run
400418

401419
---
402420

403-
## Sample code
421+
## Full sample code
404422

405423
[!INCLUDE [Full code example with .NET](./messages-get-started-full-example-net.md)]

0 commit comments

Comments
 (0)