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
### 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).
15
23
16
24
### Authenticate the client
17
25
@@ -137,60 +145,3 @@ Example:
137
145
List<String> recipientList =newArrayList<>();
138
146
recipientList.add("+14255550199");
139
147
```
140
-
141
-
### Start sending messages between a business and a WhatsApp user
142
-
143
-
Conversations between a WhatsApp Business Account and a WhatsApp user can be initiated in one of two ways:
144
-
- The business sends a template message to the WhatsApp user.
145
-
- The WhatsApp user sends any message to the business number.
146
-
147
-
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).
148
-
149
-
#### (Option 1) Initiate conversation from business - Send a template message
150
-
Initiate a conversation by sending a template message.
151
-
152
-
First, create a MessageTemplate using the values for a template.
153
-
> [!NOTE]
154
-
> To check which templates you have available, see the instructions at [List templates](../../../../concepts/advanced-messaging/whatsapp/template-messages.md#list-templates).
155
-
> If you don't have a template to use, proceed to [Option 2](#option-2-initiate-conversation-from-user).
156
-
157
-
Here's MessageTemplate creation using a default template, `sample_template`.
158
-
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.
159
-
160
-
Messages SDK allows Contoso to send templated WhatsApp messages to WhatsApp users. To send template messages below details are required:
for (MessageReceipt messageReceipt : templateMessageResult.getReceipts()) {
182
-
System.out.println("Message sent to:"+ messageReceipt.getTo() +" and message id:"+ messageReceipt.getMessageId());
183
-
}
184
-
```
185
-
186
-
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.
187
-
188
-
> [!IMPORTANT]
189
-
> The recipient must respond to the template message to initiate the conversation before text or media message can be delivered to the recipient.
190
-
191
-
#### (Option 2) Initiate conversation from user
192
-
193
-
The other option to initiate a conversation between a WhatsApp Business Account and a WhatsApp user is to have the user initiate the conversation.
194
-
To do so, from your personal WhatsApp account, send a message to your business number (Sender ID).
195
-
196
-
:::image type="content" source="../media/get-started/user-initiated-conversation.png" lightbox="" 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/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.":::
0 commit comments