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
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/common-setting-javascript.md
### Start sending messages between a business and a WhatsApp user
17
+
18
+
Conversations between a WhatsApp Business Account and a WhatsApp user can be initiated in one of two ways:
19
+
- The business sends a template message to the WhatsApp user.
20
+
- The WhatsApp user sends any message to the business number.
21
+
22
+
Regardless of how the conversation was started, **a business can only send template messages until the user sends a message to the business.** Only after the user sends a message to the business, the business is allowed to send text or media messages to the user during the active conversation. Once the 24 hour conversation window expires, the conversation must be reinitiated. To learn more about conversations, see the definition at [WhatsApp Business Platform](https://developers.facebook.com/docs/whatsapp/pricing#conversations).
For more information on how to set an environment variable for your system, follow the steps at [Store your connection string in an environment variable](../../../create-communication-resource.md#store-your-connection-string-in-an-environment-variable).
35
43
36
44
37
-
To instantiate a MessageClient, add the following code to the `Main` method:
45
+
To instantiate a NotificationClient, add the following code to the `Main` method:
@@ -102,17 +110,17 @@ After you add the environment variable, you might need to restart any running pr
102
110
103
111
For more information on how to set an environment variable for your system, follow the steps at [Store your connection string in an environment variable](../../../create-communication-resource.md#store-your-connection-string-in-an-environment-variable).
104
112
105
-
To instantiate a `MessageClient`, add the following code to the `Main` method:
113
+
To instantiate a `NotificationClient`, add the following code to the `Main` method:
### Start sending messages between a business and a WhatsApp user
155
-
156
-
Conversations between a WhatsApp Business Account and a WhatsApp user can be initiated in one of two ways:
157
-
- The business sends a template message to the WhatsApp user.
158
-
- The WhatsApp user sends any message to the business number.
159
-
160
-
Regardless of how the conversation was started, **a business can only send template messages until the user sends a message to the business.** Only after the user sends a message to the business, the business is allowed to send text or media messages to the user during the active conversation. Once the 24 hour conversation window expires, the conversation must be reinitiated. To learn more about conversations, see the definition at [WhatsApp Business Platform](https://developers.facebook.com/docs/whatsapp/pricing#conversations).
161
-
162
-
#### (Option 1) Initiate conversation from business - Send a template message
163
-
Initiate a conversation by sending a template message.
164
-
165
-
First, create a MessageTemplate using the values for a template.
166
-
> [!NOTE]
167
-
> To check which templates you have available, see the instructions at [List templates](../../../../concepts/advanced-messaging/whatsapp/template-messages.md#list-templates).
168
-
> If you don't have a template to use, proceed to [Option 2](#option-2-initiate-conversation-from-user).
169
-
170
-
Here's MessageTemplate creation using a default template, `sample_template`.
171
-
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.
172
-
173
-
Messages SDK allows Contoso to send templated WhatsApp messages to WhatsApp users. To send template messages below details are required:
console.log("Message sent to:"+receipt.to+" with message id:"+receipt.messageId);
213
-
});
214
-
} else {
215
-
thrownewError("Failed to send message");
216
-
}
217
-
```
218
-
219
-
Now, the user needs to respond to the template message. From the WhatsApp user account, reply to the template message received from the WhatsApp Business Account. The content of the message is irrelevant for this scenario.
220
-
221
-
> [!IMPORTANT]
222
-
> The recipient must respond to the template message to initiate the conversation before text or media message can be delivered to the recipient.
223
-
224
-
#### (Option 2) Initiate conversation from user
225
-
226
-
The other option to initiate a conversation between a WhatsApp Business Account and a WhatsApp user is to have the user initiate the conversation.
227
-
To do so, from your personal WhatsApp account, send a message to your business number (Sender ID).
228
-
229
-
:::image type="content" source="../media/get-started/user-initiated-conversation.png" lightbox="../media/get-started/user-initiated-conversation.png" alt-text="A WhatsApp conversation viewed on the web showing a user message sent to the WhatsApp Business Account number.":::
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/get-started/messages-get-started-javascript.md
+9-31Lines changed: 9 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,50 +16,28 @@ ms.author: armohamed
16
16
-[WhatsApp Business Account registered with your Azure Communication Services resource](../../connect-whatsapp-business-account.md).
17
17
- Active WhatsApp phone number to receive messages.
18
18
-[Node.js](https://nodejs.org/) Active LTS and Maintenance LTS versions (We recommend 8.11.1 and 10.14.1).
19
-
- In a terminal or command window, make sure Node.js is installed.
19
+
-[Node.js](https://nodejs.org/) Active LTS and Maintenance LTS versions (8.11.1 and 10.14.1 are recommended)
20
+
- In a terminal or command window, run `node --version` to check that Node.js is installed
20
21
21
-
```console
22
-
node --version
23
-
```
24
-
25
-
## Set up the environment
26
-
27
-
To set up an environment for sending messages, complete the steps in the following sections.
22
+
## Setting up
28
23
29
24
[!INCLUDE [Setting up for JavaScript Application](../javascript-application-setup.md)]
30
25
31
-
## Object model
32
-
33
-
The following classes and interfaces handle some of the major features of the Azure Communication Services Advance Messaging SDK for JavaScript.
34
-
35
-
| Class Name | Description |
36
-
| --- | --- |
37
-
|`MessageClient`| Connects to your Azure Communication Services resource. It sends the messages. |
38
-
|`MessageTemplate`| Defines which template you use and the content of the template properties for your message. |
39
-
40
-
> [!NOTE]
41
-
> For more information, see the Azure SDK for JavaScript reference [@azure-rest/communication-messages package](/javascript/api/@azure-rest/communication-messages)
42
-
43
-
## Common configuration
44
-
45
-
Follow these steps to add required code snippets to the `messages-quickstart.py` python program.
26
+
## Code examples
46
27
28
+
Follow these steps to add required code snippets to the main function of your `send-messages.js` file.
29
+
-[Start sending messages between a business and a WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
47
30
-[Authenticate the client](#authenticate-the-client).
-[Start sending messages between a business and a WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
51
-
52
-
[!INCLUDE [Common setting for using Advanced Messages SDK](../common-setting-javascript.md)]
53
-
54
-
## Code examples
55
-
56
-
Follow these steps to add required code snippets to the main function of your `send-messages.js` file.
57
33
-[Send a text message to a WhatsApp user](#send-a-text-message-to-a-whatsapp-user).
58
34
-[Send an image media message to a WhatsApp user](#send-an-image-media-message-to-a-whatsapp-user).
59
35
-[Send a document media message to a WhatsApp user](#send-a-document-media-message-to-a-whatsapp-user).
60
36
-[Send an audio media message to a WhatsApp user](#send-an-audio-media-message-to-a-whatsapp-user).
61
37
-[Send a video media message to a WhatsApp user](#send-a-video-media-message-to-a-whatsapp-user).
62
38
39
+
[!INCLUDE [Common setting for using Advanced Messages SDK](../common-setting-javascript.md)]
40
+
63
41
> [!IMPORTANT]
64
42
> To send a 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).
65
43
@@ -251,4 +229,4 @@ node ./send-messages.js
251
229
252
230
## Full sample code
253
231
254
-
You can download the sample app from[GitHub](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest/samples).
232
+
Find the finalized code for this quickstart on[GitHub](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest/samples).
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/interactive/messages-quickstart-interactive-messages-javascript.md
+12-3Lines changed: 12 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,19 +11,28 @@ ms.custom: include file
11
11
ms.author: armohamed
12
12
---
13
13
14
-
## Set up environment
14
+
## Prerequisites
15
+
-[WhatsApp Business Account registered with your Azure Communication Services resource](../../connect-whatsapp-business-account.md).
16
+
- Active WhatsApp phone number to receive messages.
17
+
-[Node.js](https://nodejs.org/) Active LTS and Maintenance LTS versions (8.11.1 and 10.14.1 are recommended)
18
+
- In a terminal or command window, run `node --version` to check that Node.js is installed
15
19
16
-
To set up an environment for sending messages, complete the steps in the following sections.
20
+
## Setting up
17
21
18
22
[!INCLUDE [Setting up for JavaScript Application](../javascript-application-setup.md)]
19
23
20
24
## Code examples
21
25
22
26
Follow these steps to add required code snippets to your `send-messages.js` file.
27
+
-[Start sending messages between a business and a WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
28
+
-[Authenticate the client](#authenticate-the-client).
-[Send an Interactive List options message to a WhatsApp user](#send-an-interactive-reply-button-message-to-a-whatsapp-user).
24
32
-[Send an Interactive Reply Button message to a WhatsApp user](#send-an-interactive-reply-button-message-to-a-whatsapp-user).
25
33
-[Send an Interactive Click-to-action Url based message to a WhatsApp user](#send-an-interactive-click-to-action-url-based-message-to-a-whatsapp-user)
26
34
35
+
[!INCLUDE [Common setting for using Advanced Messages SDK](../common-setting-javascript.md)]
27
36
28
37
### Send an Interactive List options message to a WhatsApp user
29
38
@@ -293,4 +302,4 @@ node ./send-messages.js
293
302
294
303
## Full sample code
295
304
296
-
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest/samples).
305
+
Find the finalized code for this sample on [GitHub](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest/samples).
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/reactions/messages-quickstart-reaction-messages-javascript.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,10 @@ ms.author: armohamed
12
12
---
13
13
14
14
## Prerequisites
15
+
-[WhatsApp Business Account registered with your Azure Communication Services resource](../../connect-whatsapp-business-account.md).
16
+
- Active WhatsApp phone number to receive messages.
17
+
-[Node.js](https://nodejs.org/) Active LTS and Maintenance LTS versions (8.11.1 and 10.14.1 are recommended)
18
+
- In a terminal or command window, run `node --version` to check that Node.js is installed
15
19
16
20
## Setting up
17
21
@@ -20,8 +24,14 @@ ms.author: armohamed
20
24
## Code examples
21
25
22
26
Follow these steps to add required code snippets to your `send-messages.js` file.
27
+
-[Start sending messages between a business and a WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
28
+
-[Authenticate the client](#authenticate-the-client).
-[Send a Reaction messages to a WhatsApp user message](#send-a-reaction-messages-to-a-whatsapp-user-message).
24
32
33
+
[!INCLUDE [Common setting for using Advanced Messages SDK](../common-setting-javascript.md)]
34
+
25
35
### Send a Reaction messages to a WhatsApp user message
26
36
27
37
The Messages SDK enables Contoso to send reaction WhatsApp messages, when initiated by WhatsApp users. To send text messages:
@@ -88,4 +98,4 @@ node ./send-messages.js
88
98
89
99
## Full sample code
90
100
91
-
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest/samples).
101
+
Find the finalized code for this sample on [GitHub](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest/samples).
Copy file name to clipboardExpand all lines: articles/communication-services/quickstarts/advanced-messaging/whatsapp/includes/stickers/messages-quickstart-sticker-messages-javascript.md
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,10 @@ ms.author: armohamed
12
12
---
13
13
14
14
## Prerequisites
15
+
-[WhatsApp Business Account registered with your Azure Communication Services resource](../../connect-whatsapp-business-account.md).
16
+
- Active WhatsApp phone number to receive messages.
17
+
-[Node.js](https://nodejs.org/) Active LTS and Maintenance LTS versions (8.11.1 and 10.14.1 are recommended)
18
+
- In a terminal or command window, run `node --version` to check that Node.js is installed
15
19
16
20
## Setting up
17
21
@@ -20,8 +24,14 @@ ms.author: armohamed
20
24
## Code examples
21
25
22
26
Follow these steps to add required code snippets to your `send-messages.js` file.
27
+
-[Start sending messages between a business and a WhatsApp user](#start-sending-messages-between-a-business-and-a-whatsapp-user).
28
+
-[Authenticate the client](#authenticate-the-client).
-[Send a Sticker messages to a WhatsApp user](#send-a-sticker-messages-to-a-whatsapp-user).
24
32
33
+
[!INCLUDE [Common setting for using Advanced Messages SDK](../common-setting-javascript.md)]
34
+
25
35
### Send a sticker messages to a WhatsApp user
26
36
27
37
The Messages SDK enables Contoso to send reaction WhatsApp messages, when initiated by WhatsApp users. To send text messages:
@@ -87,4 +97,4 @@ node ./send-messages.js
87
97
88
98
## Full sample code
89
99
90
-
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest/samples).
100
+
Find the finalized code for this sample on [GitHub](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/communication/communication-messages-rest/samples).
0 commit comments