Skip to content

Commit f5fd3cb

Browse files
committed
include file
for chat
1 parent 68eb0cc commit f5fd3cb

File tree

8 files changed

+120
-117
lines changed

8 files changed

+120
-117
lines changed

articles/communication-services/quickstarts/chat/includes/chat-android.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,4 +434,4 @@ In Android Studio, hit the Run button to build and run the project. In the conso
434434

435435
## Sample code
436436

437-
Find the finalized code for this quickstart on GitHub at [Add chat to your app](https://github.com/Azure-Samples/communication-services-android-quickstarts/tree/main/Add-chat).
437+
Find the finalized code for this article in the GitHub sample [Add Chat to your application](https://github.com/Azure-Samples/communication-services-android-quickstarts/tree/main/Add-chat).

articles/communication-services/quickstarts/chat/includes/chat-az-cli.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,7 @@ az communication chat message receipt send --thread "<chatThreadId>" --message-i
216216
- Replace `<chatThreadId>` with your chat thread ID.
217217
- Replace `<messageId>` to specify the ID of the latest message read by current user.
218218
- Replace `<endpoint>` with your Azure Communication Services endpoint.
219-
- Replace `<token>` with your access token obtained earlier with running `identity token issue` command.
220-
219+
- Replace `<token>` with your access token obtained earlier with running `identity token issue` command.
221220

222221
### Add a user as a participant to the chat thread
223222

@@ -248,8 +247,7 @@ az communication chat participant list --thread "<chatThreadId>" --skip "<skip>"
248247
- Replace `<chatThreadId>` with your chat thread ID.
249248
- Use `<skip>` optionally to skip participants up to a specified position in the response.
250249
- Replace `<endpoint>` with your Azure Communication Services endpoint.
251-
- Replace `<token>` with your access token obtained earlier with running `identity token issue` command.
252-
250+
- Replace `<token>` with your access token obtained earlier with running `identity token issue` command.
253251

254252
### Remove a participant from a chat thread
255253

articles/communication-services/quickstarts/chat/includes/chat-csharp.md

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@ ms.author: rifox
1313
---
1414

1515
## Prerequisites
16-
Before you get started, make sure to:
16+
1717
- Create an Azure account with an active subscription. For details, see [Create an account for free](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
1818
- Install [Visual Studio](https://visualstudio.microsoft.com/downloads/)
19-
- 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](../../create-communication-resource.md). You need to record your resource **endpoint and connection string** for this article.
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 following command with your connection string to create a user and an access token.
2121

2222
```azurecli-interactive
2323
az communication identity token issue --scope chat --connection-string "yourConnectionString"
2424
```
2525

2626
For details, see [Use Azure CLI to Create and Manage Access Tokens](../../identity/access-tokens.md?pivots=platform-azcli).
2727

28-
## Setting up
28+
## Set up
2929

3030
### Create a new C# application
3131

@@ -56,18 +56,19 @@ The following classes handle some of the major features of the Azure Communicati
5656

5757
| Name | Description |
5858
| ------------------------------------- | ------------------------------------------------------------ |
59-
| 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. |
59+
| 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. |
6060
| 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 participants, send typing notifications and read receipts. |
6161

6262
## Create a chat client
6363

64-
To create a chat client, you'll use your Communication Services endpoint and the access token that was generated as part of the prerequisite steps. You need to use the `CommunicationIdentityClient` class from the Identity SDK to create a user and issue a token to pass to your chat client.
64+
To create a chat client, use your Communication Services endpoint and the access token that was generated as part of the prerequisite steps. You need to use the `CommunicationIdentityClient` class from the Identity SDK to create a user and issue a token to pass to your chat client.
6565

6666
Learn more about [User Access Tokens](../../identity/access-tokens.md).
6767

68-
This quickstart doesn't cover creating a service tier to manage tokens for your chat application, although it's recommended. Learn more about [Chat Architecture](../../../concepts/chat/concepts.md)
68+
This article doesn't cover creating a service tier to manage tokens for your chat application, although we recommend it. For more information, see [Chat Architecture](../../../concepts/chat/concepts.md).
69+
70+
Copy the following code snippets and paste into the `Program.cs` source file.
6971

70-
Copy the following code snippets and paste into source file: **Program.cs**
7172
```csharp
7273
using Azure;
7374
using Azure.Communication;
@@ -93,10 +94,10 @@ namespace ChatQuickstart
9394
## Start a chat thread
9495

9596
Use the `createChatThread` method on the chatClient to create a chat thread
96-
- Use `topic` to give a topic to this chat; Topic can be updated after the chat thread is created using the `UpdateTopic` function.
97-
- Use `participants` property to pass a list of `ChatParticipant` objects to be added to the chat thread. The `ChatParticipant` object is initialized with a `CommunicationIdentifier` object. `CommunicationIdentifier` could be of type `CommunicationUserIdentifier`, `MicrosoftTeamsUserIdentifier` or `PhoneNumberIdentifier`. For example, to get a `CommunicationIdentifier` object, you'll need to pass an Access ID which you created by following instruction to [Create a user](../../identity/access-tokens.md#create-an-identity)
97+
- Use `topic` to give a topic to this chat. You can update the topic after creating the chat thread using the `UpdateTopic` function.
98+
- Use `participants` property to pass a list of `ChatParticipant` objects to be added to the chat thread. The `ChatParticipant` object is initialized with a `CommunicationIdentifier` object. `CommunicationIdentifier` could be of type `CommunicationUserIdentifier`, `MicrosoftTeamsUserIdentifier`, or `PhoneNumberIdentifier`. For example, to get a `CommunicationIdentifier` object, you need to pass an Access ID which you created by following instruction to [Create a user](../../identity/access-tokens.md#create-an-identity)
9899

99-
The response object from the `createChatThread` method contains the `chatThread` details. To interact with the chat thread operations such as adding participants, sending a message, deleting a message, etc., a `chatThreadClient` client instance needs to instantiated using the `GetChatThreadClient` method on the `ChatClient` client.
100+
The response object from the `createChatThread` method contains the `chatThread` details. To interact with the chat thread operations such as adding participants, sending a message, deleting a message, and so on, a `chatThreadClient` client instance needs to instantiated using the `GetChatThreadClient` method on the `ChatClient` client.
100101

101102
```csharp
102103
var chatParticipant = new ChatParticipant(identifier: new CommunicationUserIdentifier(id: "<Access_ID>"))
@@ -109,7 +110,7 @@ string threadId = chatThreadClient.Id;
109110
```
110111

111112
## Get a chat thread client
112-
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 members, send message, etc. threadId is the unique ID of the existing chat thread.
113+
The `GetChatThreadClient` method returns a thread client for a thread that already exists. You can use it to perform operations on the created thread: add members, send message, and so on. `threadId` is the unique ID of the existing chat thread.
113114

114115
```csharp
115116
string threadId = "<THREAD_ID>";
@@ -131,10 +132,10 @@ await foreach (ChatThreadItem chatThreadItem in chatThreadItems)
131132

132133
Use `SendMessage` to send a message to a thread.
133134

134-
- Use `content` to provide the content for the message, it's required.
135-
- Use `type` for the content type of the message such as 'Text' or 'Html'. If not specified, 'Text' will be set.
136-
- Use `senderDisplayName` to specify the display name of the sender. If not specified, empty string will be set.
137-
- 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.
135+
- Use `content` to provide the content for the message. Required.
136+
- Use `type` for the content type of the message such as 'Text' or 'Html'. If not specified, 'Text' is set.
137+
- Use `senderDisplayName` to specify the display name of the sender. If not specified, empty string is set.
138+
- Optional: Use `metadata` to include other 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.
138139

139140
```csharp
140141
SendChatMessageOptions sendChatMessageOptions = new SendChatMessageOptions()
@@ -162,29 +163,29 @@ await foreach (ChatMessage message in allMessages)
162163
}
163164
```
164165

165-
`GetMessages` takes an optional `DateTimeOffset` parameter. If that offset is specified, you'll receive messages that were received, updated or deleted after it. Note that messages received before the offset time but edited or removed after it will also be returned.
166+
`GetMessages` takes an optional `DateTimeOffset` parameter. If that offset is specified, you receive messages that were received, updated, or deleted after it. Messages received before the offset time but edited or removed afterward are also returned.
166167

167168
`GetMessages` returns the latest version of the message, including any edits or deletes that happened to the message using `UpdateMessage` and `DeleteMessage`. For deleted messages, `chatMessage.DeletedOn` returns a datetime value indicating when that message was deleted. For edited messages, `chatMessage.EditedOn` returns a datetime indicating when the message was edited. The original time of message creation can be accessed using `chatMessage.CreatedOn`, and it can be used for ordering the messages.
168169

169-
`GetMessages` returns different types of messages which can be identified by `chatMessage.Type`. These types are:
170+
`GetMessages` returns different types of messages. You can identify the type from the `chatMessage.Type`. The types are:
170171

171172
- `Text`: Regular chat message sent by a thread member.
172173

173-
- `Html`: A formatted text message. Note that Communication Services users currently can't send RichText messages. This message type is supported by messages sent from Teams users to Communication Services users in Teams Interop scenarios.
174+
- `Html`: A formatted text message. Communication Services users currently can't send RichText messages. This message type is supported for messages sent from Teams users to Communication Services users in Teams Interop scenarios.
174175

175-
- `TopicUpdated`: System message that indicates the topic has been updated. (readonly)
176+
- `TopicUpdated`: System message that indicates the topic is updated. (readonly)
176177

177-
- `ParticipantAdded`: System message that indicates one or more participants have been added to the chat thread.(readonly)
178+
- `ParticipantAdded`: System message that indicates one or more participants are added to the chat thread (readonly).
178179

179-
- `ParticipantRemoved`: System message that indicates a participant has been removed from the chat thread.
180+
- `ParticipantRemoved`: System message that indicates a participant is removed from the chat thread.
180181

181-
For more details, see [Message Types](../../../concepts/chat/concepts.md#message-types).
182+
For more information, see [Message Types](../../../concepts/chat/concepts.md#message-types).
182183

183184
## Add a user as a participant to the chat thread
184185

185-
Once a thread is created, you can then add and remove users from it. By adding users, you give them access to be able to send messages to the thread, and add/remove other participant. Before calling `AddParticipants`, ensure that you have acquired a new access token and identity for that user. The user will need that access token in order to initialize their chat client.
186+
Once a thread is created, you can then add and remove users from it. By adding users, you give them access to be able to send messages to the thread, and add/remove other participant. Before calling `AddParticipants`, ensure that you acquire a new access token and identity for that user. The user needs that access token in order to initialize their chat client.
186187

187-
Use `AddParticipants` to add one or more participants to the chat thread. The following are the supported attributes for each thread participant(s):
188+
Use `AddParticipants` to add one or more participants to the chat thread. The following are the supported attributes for each thread participant:
188189
- `communicationUser`, required, is the identity of the thread participant.
189190
- `displayName`, optional, is the display name for the thread participant.
190191
- `shareHistoryTime`, optional, time from which the chat history is shared with the participant.
@@ -218,7 +219,7 @@ await foreach (ChatParticipant participant in allParticipants)
218219

219220
## Send read receipt
220221

221-
Use `SendReadReceipt` to notify other participants that the message is read by the user.
222+
Use `SendReadReceipt` to notify other participants that the user read the message.
222223

223224
```csharp
224225
await chatThreadClient.SendReadReceiptAsync(messageId: messageId);
@@ -233,4 +234,5 @@ dotnet run
233234
```
234235

235236
## Sample Code
236-
Find the finalized code for this quickstart on [GitHub](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/add-chat).
237+
238+
Find the finalized code for this article in the GitHub sample [Add Chat to your application](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/add-chat).

0 commit comments

Comments
 (0)