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
- Create an Azure Communication Services resource. For details, see [Create an Azure Communication Services resource](../../create-communication-resource.md). You'll need to record your resource **endpoint and connection string** for this quickstart.
20
-
- A [User Access Token](../../identity/access-tokens.md). Be sure to set the scope to **chat**, and **note the token string as well as the user_id string**. You can also use the Azure CLI and run the command below with your connection string to create a user and an access token.
19
+
- Create an Azure Communication Services resource. For details, see [Create an Azure Communication Services resource](../../quickstarts/create-communication-resource.md). You need to record your resource **endpoint and connection string**.
20
+
- A [User Access Token](../../quickstarts/identity/access-tokens.md). Be sure to set the scope to **chat**, and **note the token string and the user_id string**. You can also use the Azure CLI and run the following command with your connection string to create a user and an access token.
21
21
22
22
```azurecli-interactive
23
23
az communication identity token issue --scope chat --connection-string "yourConnectionString"
24
24
```
25
25
26
-
For details, see [Use Azure CLI to Create and Manage Access Tokens](../../identity/access-tokens.md?pivots=platform-azcli).
26
+
For details, see [Use Azure CLI to Create and Manage Access Tokens](../../quickstarts/identity/access-tokens.md?pivots=platform-azcli).
27
27
28
28
## Setting up
29
29
30
30
### Add the package references for the Chat SDK
31
31
32
32
#### Twilio
33
+
33
34
To use Twilio Conversations Chat APIs in your Java application, add the following dependency in your pom.xml:
35
+
34
36
```xml
35
37
<dependencies>
36
38
<!-- Twilio Java SDK -->
@@ -70,20 +72,22 @@ The following classes and interfaces handle some of the major features of the Az
| ChatClient | This class is needed for the Chat functionality. You instantiate it with your subscription information, and use it to create, get and delete threads. |
74
-
| ChatAsyncClient | This class is needed for the asynchronous Chat functionality. You instantiate it with your subscription information, and use it to create, get and delete threads. |
75
-
| ChatThreadClient | This class is needed for the Chat Thread functionality. You obtain an instance via the ChatClient, and use it to send/receive/update/delete messages, add/remove/get users, send typing notifications and read receipts. |
76
-
| ChatThreadAsyncClient | This class is needed for the asynchronous Chat Thread functionality. You obtain an instance via the ChatAsyncClient, and use it to send/receive/update/delete messages, add/remove/get users, send typing notifications and read receipts. |
75
+
|`ChatClient`| This class is needed for the Chat function. Instantiate it with your subscription information, and use it to create, get, and delete threads. |
76
+
|`ChatAsyncClient`| This class is needed for the asynchronous Chat function. Instantiate it with your subscription information, and use it to create, get, and delete threads. |
77
+
|`ChatThreadClient`| This class is needed for the Chat Thread function. You get an instance via the `ChatClient`, and use it to send/receive/update/delete messages, add/remove/get users, send typing notifications, and read receipts. |
78
+
|`ChatThreadAsyncClient`| This class is needed for the asynchronous Chat Thread function. You get an instance via the `ChatAsyncClient`, and use it to send/receive/update/delete messages, add/remove/get users, send typing notifications, and read receipts. |
To create a chat client, you'll use the Communications Service endpoint and the access token that was generated as part of pre-requisite steps. User access tokens enable you to build client applications that directly authenticate to Azure Communication Services. Once you generate these tokens on your server, pass them back to a client device. You need to use the CommunicationTokenCredential class from the Common SDK to pass the token to your chat client.
119
+
To create a chat client, use the Communications Service endpoint and the access token that was generated as part of prerequisite steps. User access tokens enable you to build client applications that directly authenticate to Azure Communication Services. Once you generate these tokens on your server, pass them back to a client device. You need to use the `CommunicationTokenCredentia`l class from the Common SDK to pass the token to your chat client.
114
120
115
-
Learn more about [Chat Architecture](../../../concepts/chat/concepts.md)
121
+
Learn more about [Chat Architecture](../../concepts/chat/concepts.md)
116
122
117
-
When adding the import statements, be sure to only add imports from the com.azure.communication.chat and com.azure.communication.chat.models namespaces, and not from the com.azure.communication.chat.implementation namespace. In the App.java file that was generated via Maven, you can use the following code to begin with:
123
+
When adding the import statements, be sure to only add imports from the `com.azure.communication.chat` and `com.azure.communication.chat.models` namespaces, and not from the `com.azure.communication.chat.implementation` namespace. In the `App.java` file that was generated via Maven, you can use the following code to start:
118
124
119
125
```Java
120
126
// Your unique Azure Communication service endpoint
@@ -137,8 +143,11 @@ final ChatClientBuilder builder = new ChatClientBuilder();
137
143
### Start a chat thread
138
144
139
145
#### Twilio
140
-
Creating a conversation in Twilio is straightforward using the Conversation.creator() method.
141
-
- Use the `setFriendlyName` to give a topic to this chat.
146
+
147
+
Creating a conversation in Twilio is straightforward using the `Conversation.creator()` method.
148
+
149
+
Use the `setFriendlyName` to give a topic to this chat.
@@ -148,13 +157,13 @@ Creating a conversation in Twilio is straightforward using the Conversation.crea
148
157
#### Azure Communication Services
149
158
150
159
Use the `createChatThread` method to create a chat thread.
151
-
`createChatThreadOptions` is used to describe the thread request.
152
-
153
-
- Use the `topic` parameter of the constructor to give a topic to this chat; Topic can be updated after the chat thread is created using the `UpdateThread` function.
154
-
- Use `participants` to list the thread participants to be added to the thread. `ChatParticipant` takes the user you created in the [User Access Token](../../identity/access-tokens.md) quickstart.
160
+
- Use`createChatThreadOptions` to describe the thread request.
161
+
- Use the `topic` parameter of the constructor to give a topic to this chat; update 'topic' after the chat thread is created using the `UpdateThread` function.
162
+
- Use `participants` to list the thread participants to be added to the thread. `ChatParticipant` takes the user you created in the [User Access Token](../../quickstarts/identity/access-tokens.md) quickstart.
155
163
156
164
`CreateChatThreadResult` is the response returned from creating a chat thread.
157
-
It contains a `getChatThread()` method, which returns the `ChatThread` object that can be used to get the thread client from which you can get the `ChatThreadClient` for performing operations on the created thread: add participants, send message, etc.
165
+
It contains a `getChatThread()` method, which returns the `ChatThread` object that can be used to get the thread client from which you can get the `ChatThreadClient` for performing operations on the created thread: add participants, send message, and so on.
166
+
158
167
The `ChatThread` object also contains the `getId()` method, which retrieves the unique ID of the thread.
The `getChatThreadClient` method returns a thread client for a thread that already exists. It can be used for performing operations on the created thread: add participants, send message, etc.
235
+
The `getChatThreadClient` method returns a thread client for a thread that already exists. Use it to perform operations on the created thread: add participants, send message, and so on.
224
236
`chatThreadId` is the unique ID of the existing chat thread.
Unlike Twilio, Azure Communication Services does not have separate functions to send media.
257
-
Use the `sendMessage` method to send a message to the thread you created, identified by chatThreadId.
258
-
`sendChatMessageOptions` is used to describe the chat message request.
259
269
270
+
Unlike Twilio, Azure Communication Services doesn't have separate functions to send media.
271
+
Use the `sendMessage` method to send a message to the thread you created, identified by `chatThreadId`.
272
+
273
+
Use `sendChatMessageOptions` to describe the chat message request.
260
274
- Use `content` to provide the chat message content.
261
-
- Use `type` to specify the chat message content type, TEXT or HTML.
275
+
- Use `type` to specify the chat message content type: `TEXT` or `HTML`.
262
276
- Use `senderDisplayName` to specify the display name of the sender.
263
-
- Use `metadata` optionally to include any additional data you want to send along with the message. This field provides a mechanism for developers to extend chat message functionality and add custom information for your use case. For example, when sharing a file link in the message, you might want to add `hasAttachment:true` in metadata so that recipient's application can parse that and display accordingly.
277
+
- Use `metadata` optionally to include any data you want to send with the message. This field enables developers to extend chat message function and add custom information for your use case. For example, when sharing a file link in the message, you might want to add `hasAttachment:true` in metadata so that recipient's application can parse that and display accordingly.
264
278
265
279
The response `sendChatMessageResult` contains an `id`, which is the unique ID of the message.
`listMessages` returns the latest version of the message, including any edits or deletes that happened to the message using `.editMessage()` and `.deleteMessage()`.For deleted messages, `chatMessage.getDeletedOn()` returns a datetime value indicating when that message was deleted. For edited messages, `chatMessage.getEditedOn()` returns a datetime indicating when the message was edited. The original time of message creation can be accessed using `chatMessage.getCreatedOn()`, and it can be used for ordering the messages.
350
+
`listMessages` returns the latest version of the message, including any edits or deletes that happened to the message using `.editMessage()` and `.deleteMessage()`.For deleted messages, `chatMessage.getDeletedOn()` returns a `datetime` value indicating when that message was deleted. For edited messages, `chatMessage.getEditedOn()` returns a datetime indicating when the message was edited. The original time of message creation can be accessed using `chatMessage.getCreatedOn()`, and it can be used for ordering the messages.
334
351
335
-
Read more about message types here: [MessageTypes](../../../concepts/chat/concepts.md#message-types).
352
+
Read more about message types here: [MessageTypes](../../concepts/chat/concepts.md#message-types).
336
353
337
354
### Send read receipt
338
355
339
356
#### Twilio
340
-
TwilioConversations does not have a direct APIfor sending read receipts. TwilioConversations manages read receipts automatically.
357
+
358
+
TwilioConversations doesn't have a direct API for sending read receipts. Twilio Conversations manages read receipts automatically.
341
359
342
360
#### Azure Communication Services
343
361
344
362
Use the `sendReadReceipt` method to post a read receipt event to a chat thread, on behalf of a user.
363
+
345
364
`chatMessageId` is the unique ID of the chat message that was read.
Once a chat thread is created, you can then add and remove users from it. By adding users, you give them access to send messages to the chat thread, and add/remove other participants. You'll need to start by getting a new access token and identity for that user. Before calling addParticipants method, ensure that you've acquired a new access token and identity for that user. The user will need that access token in order to initialize their chat client.
411
+
Once a chat thread is created, you can then add and remove users from it. By adding users, you give them access to send messages to the chat thread, and add/remove other participants. Start by getting a new access token and identity for that user. Before calling the `addParticipants` method, ensure that you acquired a new access token and identity for that user. The user needs that access token to initialize their chat client.
392
412
393
413
Use the `addParticipants` method to add participants to the thread.
394
414
395
-
- `communicationIdentifier`, required, is the CommunicationIdentifier you've created by the CommunicationIdentityClient in the [UserAccessToken](../../identity/access-tokens.md) quickstart.
415
+
- `communicationIdentifier`, required, is the `CommunicationIdentifier` you created using `CommunicationIdentityClient` in the [User Access Token](../../quickstart/identity/access-tokens.md) quickstart.
396
416
- `displayName`, optional, is the display name for the thread participant.
397
417
- `shareHistoryTime`, optional, is the time from which the chat history is shared with the participant. To share history since the inception of the chat thread, set this property to any date equal to, or less than the thread creation time. To share no history previous to when the participant was added, set it to the current date. To share partial history, set it to the required date.
0 commit comments