Skip to content

Commit f502fb7

Browse files
Merge pull request #272242 from vac0224/patch-1
Patch-1
2 parents e07630c + f6ca593 commit f502fb7

File tree

6 files changed

+194
-59
lines changed

6 files changed

+194
-59
lines changed

articles/communication-services/concepts/interop/guest/capabilities.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ ms.subservice: teams-interop
1212

1313
# Teams meeting capabilities for Teams external users
1414

15-
In this article, you will learn which capabilities are supported for Teams external users using Azure Communication Services SDKs in Teams meetings. You can find per platform availability in [voice and video calling capabilities](../../voice-video-calling/calling-sdk-features.md).
15+
This article describes which capabilities Azure Communication Services SDKs support for Teams external users in Teams meetings. For availability by platform, see [voice and video calling capabilities](../../voice-video-calling/calling-sdk-features.md).
1616

1717

1818
| Group of features | Capability | Supported |
@@ -25,7 +25,7 @@ In this article, you will learn which capabilities are supported for Teams exter
2525
| | Prevent joining locked meeting | ✔️ |
2626
| | Honor assigned Teams meeting role | ✔️ |
2727
| Chat | Send and receive chat messages | ✔️ |
28-
| | [Receive inline images](../../../tutorials/chat-interop/meeting-interop-features-inline-image.md) | ✔️ |
28+
| | [Receive inline images](../../../tutorials/chat-interop/meeting-interop-features-inline-image.md) | ✔️** |
2929
| | Send inline images ||
3030
| | [Receive file attachments](../../../tutorials/chat-interop/meeting-interop-features-file-attachment.md) | ✔️** |
3131
| | Send file attachments ||
@@ -140,7 +140,7 @@ In this article, you will learn which capabilities are supported for Teams exter
140140
| | Honor setting "Mode for IP video" ||
141141
| | Honor setting "IP video" ||
142142
| | Honor setting "Local broadcasting" ||
143-
| | Honor setting "Media bit rate (Kbs)" ||
143+
| | Honor setting "Media bit rate (Kbps)" ||
144144
| | Honor setting "Network configuration lookup" ||
145145
| | Honor setting "Transcription" | No API available |
146146
| | Honor setting "Cloud recording" | No API available |
@@ -170,11 +170,11 @@ In this article, you will learn which capabilities are supported for Teams exter
170170
| | [Teams Call Analytics](/MicrosoftTeams/use-call-analytics-to-troubleshoot-poor-call-quality) | ✔️ |
171171
| | [Teams real-time Analytics](/microsoftteams/use-real-time-telemetry-to-troubleshoot-poor-meeting-quality) ||
172172

173-
When Teams external users leave the meeting, or the meeting ends, they can no longer send or receive new chat messages and no longer have access to messages sent and received during the meeting.
173+
When Teams external users leave the meeting, or the meeting ends, they can no longer exchange new chat messages nor access messages sent and received during the meeting.
174174

175-
*Azure Communication Services provides developers tools to integrate Microsoft Teams Data Loss Prevention that is compatible with Microsoft Teams. For more information, go to [how to implement Data Loss Prevention (DLP)](../../../how-tos/chat-sdk/data-loss-prevention.md)
175+
\* Azure Communication Services provides developer tools to integrate Microsoft Teams Data Loss Prevention compatible with Microsoft Teams. For more information, see [how to implement Data Loss Prevention (DLP)](../../../how-tos/chat-sdk/data-loss-prevention.md).
176176

177-
**File attachment support is currently in public preview and is available in the Chat SDK for JavaScript only. Preview APIs and SDKs are provided without a service-level agreement. We recommend that you don't use them for production workloads. Some features might not be supported, or they might have constrained capabilities. For more information, review [Supplemental Terms of Use for Microsoft Azure Previews.](https://azure.microsoft.com/support/legal/preview-supplemental-terms/)
177+
\*\* Inline image and file attachment support are available in the Chat SDK for JavaScript and C# only.
178178

179179
## Server capabilities
180180

@@ -205,4 +205,4 @@ The following table shows supported Teams capabilities:
205205
- [Join Teams meeting audio and video as Teams external user](../../../quickstarts/voice-video-calling/get-started-teams-interop.md)
206206
- [Join Teams meeting chat as Teams external user](../../../quickstarts/chat/meeting-interop.md)
207207
- [Join meeting options](../../../how-tos/calling-sdk/teams-interoperability.md)
208-
- [Communicate as Teams user](../../teams-endpoint.md).
208+
- [Communicate as Teams user](../../teams-endpoint.md)
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
title: Tutorial - Enable File Attachment Support
3+
author: jpeng-ms
4+
ms.author: jopeng
5+
ms.date: 04/10/2024
6+
ms.topic: include
7+
ms.service: azure-communication-services
8+
---
9+
10+
This tutorial describes how to enable file attachment support using the Azure Communication Services Chat SDK for C#.
11+
12+
## Sample code
13+
Find the finalized code for this tutorial at [GitHub](https://github.com/Azure-Samples/communication-services-dotnet-quickstarts/tree/main/ChatTeamsInteropQuickStart).
14+
15+
## Prerequisites
16+
17+
* Complete the quickstart [Join your chat app to a Teams meeting](../../../quickstarts/chat/meeting-interop.md).
18+
* Create an Azure Communication Services resource as described in [Create an Azure Communication Services resource](../../../quickstarts/create-communication-resource.md). You need to **record your connection string** for this tutorial.
19+
* Set up a Teams meeting using your business account and have the meeting URL ready.
20+
* Download the Chat SDK for C# (@azure/communication-chat) 1.3.0 or the latest. See [Azure Communication Chat client library](https://www.nuget.org/packages/Azure.Communication.Chat).
21+
22+
## Handle file attachments
23+
24+
The Chat SDK for C# returns a `ChatAttachmentType` of `file` for regular file attachments and `image` for inline images.
25+
26+
```csharp
27+
public readonly partial struct ChatAttachmentType : IEquatable<ChatAttachmentType>
28+
{
29+
private const string ImageValue = "image";
30+
private const string FileValue = "file";
31+
/// <summary> image. </summary>
32+
public static ChatAttachmentType Image { get; } = new ChatAttachmentType(ImageValue);
33+
/// <summary> file. </summary>
34+
public static ChatAttachmentType File { get; } = new ChatAttachmentType(FileValue);
35+
}
36+
37+
38+
```
39+
40+
For example, the following JSON shows what `ChatAttachment` might look like for an image attachment and a file attachment when receiving requests from the server side:
41+
42+
```json
43+
"attachments": [
44+
{
45+
"id": "08a182fe-0b29-443e-8d7f-8896bc1908a2",
46+
"attachmentType": "file",
47+
"name": "business report.pdf",
48+
"previewUrl": "https://contoso.sharepoint.com/:u:/g/user/h8jTwB0Zl1AY"
49+
},
50+
{
51+
"id": "9d89acb2-c4e4-4cab-b94a-7c12a61afe30",
52+
"attachmentType": "image",
53+
"name": "Screenshot.png",
54+
"url": "https://contoso.communication.azure.com/chat/threads/19:[email protected]/messages/123/images/9d89acb2-c4e4-4cab-b94a-7c12a61afe30/views/original?api-version=2023-11-15-preview",
55+
"previewUrl": "https://contoso.communication.azure.com/chat/threads/19:[email protected]/messages/123/images/9d89acb2-c4e4-4cab-b94a-7c12a61afe30/views/small?api-version=2023-11-15-preview"
56+
}
57+
]
58+
```
59+
60+
Now let's go back to the event handler we created in previous [quickstart](../../../quickstarts/chat/meeting-interop.md) and add some extra logic to handle attachments with `ChatAttachmentType` of `file`:
61+
62+
```csharp
63+
64+
await foreach (ChatMessage message in allMessages)
65+
{
66+
// Get message attachments that are of type 'file'
67+
IEnumerable<ChatAttachment> fileAttachments = message.Content.Attachments.Where(x => x.AttachmentType == ChatAttachmentType.File);
68+
var chatAttachmentFileUris = new List<Uri>();
69+
foreach (var file in fileAttachments)
70+
{
71+
chatAttachmentFileUris.Add(file.PreviewUri);
72+
}
73+
74+
// Build message list
75+
if (message.Type == ChatMessageType.Html || message.Type == ChatMessageType.Text)
76+
{
77+
textMessages++;
78+
var userPrefix = message.Sender.Equals(currentUser) ? "[you]:" : "";
79+
var strippedMessage = StripHtml(message.Content.Message);
80+
81+
82+
83+
var chatAttachments = fileAttachments.Count() > 0 ? "[Attachments]:\n" + string.Join(",\n", chatAttachmentFileUris) : "";
84+
messageList.Add(long.Parse(message.SequenceId), $"{userPrefix}{strippedMessage}\n{chatAttachments}");
85+
}
86+
}
87+
88+
```
89+
90+
Specifically, for each file attachment, we get the `previewUrl` and construct a list of URLs in the `for loop`. Then we embed the string along with the chat message content.
91+
92+
## Handle image attachments
93+
94+
You need to handle image attachments differently than standard `file` attachments. Image attachments have the `ChatAttachmentType` of `image`, which requires the communication token to retrieve either the preview or full-size images.
95+
96+
Before continuing, complete the [Enabling inline image support](../meeting-interop-features-inline-image.md) tutorial. To identity image attachments, we need to find out if the message content contains the same image ID from the attachments.
97+
98+
```csharp
99+
bool isImageAttachment = message.Content.Message.Contains(x.Id);
100+
```
101+
102+
If this flag is true, then we should apply inline image logic to render it:
103+
104+
```csharp
105+
IEnumerable<ChatAttachment> imageAttachments = message.Content.Attachments.Where(x => x.AttachmentType == ChatAttachmentType.Image);
106+
// Fetch image and render
107+
var chatAttachmentImageUris = new List<Uri>();
108+
foreach (ChatAttachment imageAttachment in imageAttachments)
109+
{
110+
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", communicationTokenCredential.GetToken().Token);
111+
var response = await client.GetAsync(imageAttachment.PreviewUri);
112+
var randomAccessStream = await response.Content.ReadAsStreamAsync();
113+
await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
114+
{
115+
var bitmapImage = new BitmapImage();
116+
await bitmapImage.SetSourceAsync(randomAccessStream.AsRandomAccessStream());
117+
InlineImage.Source = bitmapImage;
118+
});
119+
chatAttachmentImageUris.Add(imageAttachment.PreviewUri);
120+
}
121+
```
122+
123+
Now your app supports image attachments.

0 commit comments

Comments
 (0)