Skip to content

Commit d41776e

Browse files
authored
Merge pull request #232081 from kperla97/patch-8
archive chat threads or messages
2 parents 25706e9 + be87e64 commit d41776e

File tree

3 files changed

+92
-0
lines changed

3 files changed

+92
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: Archive your chat threads
3+
titleSuffix: An Azure Communication Services tutorial
4+
description: Learn how to archive chat threads and messages with your own storage.
5+
author: kperla97
6+
manager: sundraman
7+
services: Azure Communication Services
8+
9+
ms.author: kaperla
10+
ms.date: 03/24/2023
11+
ms.topic: tutorial
12+
ms.service: azure-communication-services
13+
ms.subservice: chat
14+
---
15+
16+
# Archiving chat threads into your preferred storage solution
17+
18+
In this guide, learn how to move chat messages into your own storage in real-time or chat threads once conversations are complete. Developers are able to maintain an archive of chat threads or messages for compliance reasons or to integrate with Azure OpenAI or both.
19+
20+
## Prerequisites
21+
22+
- An Azure account with an active subscription.
23+
- An active Communication Services resource and connection string. [Create a Communication Services resource](../../quickstarts/create-communication-resource.md).
24+
- A storage account, in this guide we take an example of Azure Blob Storage. You can use the portal to set up an [account](../../../event-grid/blob-event-quickstart-portal.md). You can use any other storage option that you prefer.
25+
- If you would like to archive messages in near real time, enable Azure Event Grid, which is a paid service (this prerequisite is only for option 2).
26+
27+
## About Event Grid
28+
29+
[Event Grid](../../../event-grid/overview.md) is a cloud-based eventing service. You need to subscribe to [communication service events](../../../event-grid/event-schema-communication-services.md), and trigger an event in order to archive the messages in near real time. Typically, you send events to an endpoint that processes the event data and takes actions.
30+
31+
## Set up the environment
32+
33+
To set up the environment that you use to generate and receive events, take the steps in the following sections.
34+
35+
### Register an Event Grid resource provider
36+
37+
If you haven't previously used Event Grid in your Azure subscription, you might need to register your Event Grid resource provider. To register the provider, follow these steps:
38+
39+
1. Go to the Azure portal.
40+
1. On the left menu, select **Subscriptions**.
41+
1. Select the subscription that you use for Event Grid.
42+
1. On the left menu, under **Settings**, select **Resource providers**.
43+
1. Find **Microsoft.EventGrid**.
44+
1. If your resource provider isn't registered, select **Register**.
45+
46+
It might take a moment for the registration to finish. Select **Refresh** to update the status. When **Registered** appears under **Status**, you're ready to continue.
47+
48+
### Deploy the Event Grid viewer
49+
50+
You need to use an Event Grid viewer to view events in near-real time. The viewer provides the user with the experience of a real-time feed.
51+
52+
There are two methods for archiving chat threads. You can choose to archive messages when the thread is inactive or in near real time.
53+
54+
## Option 1: Archiving inactive conversations using a back end application
55+
56+
This option is suited when your chat volume is high and multiple parties are involved.
57+
58+
Create a backend application to perform jobs to move chat threads into your own storage, we recommend archiving when the thread is no longer active, i.e the conversation with the customer is complete.
59+
60+
The backend application would run a job to do the following steps:
61+
62+
1. [List](../../quickstarts/chat/get-started.md?tabs=windows&pivots=platform-azcli#list-chat-messages-in-a-chat-thread) the messages in the chat thread you wish to archive
63+
2. Write the chat thread in the desired format you wish to store it in i.e JSON, CSV
64+
3. Copy the thread in the format as a blob into Azure Blob storage
65+
66+
## Option 2: Archiving chat messages in real-time
67+
68+
This option is suited if the chat volume is low as conversations are happening in real time.
69+
70+
:::image type="content" source="../../media/storage-work-flow.jpg" alt-text="Architecture diagram showing how you can use events and archive messages to your own storage account.":::
71+
72+
Follow these steps for archiving messages:
73+
74+
- Subscribe to Event Grid events which come with Azure Event Grid through web hooks. Azure Communications Chat service supports the following [events](../../concepts/chat/concepts.md#real-time-notifications) for real-time notifications. The following events are recommended: Message Received [event](../../../event-grid/communication-services-chat-events.md#microsoftcommunicationchatmessagereceived-event), Message Edited [event](../../../event-grid/communication-services-chat-events.md#microsoftcommunicationchatmessageedited-event), and Message Deleted [event](../../../event-grid/communication-services-chat-events.md#microsoftcommunicationchatmessagedeleted-event).
75+
- Validate the [events](../../how-tos/event-grid/view-events-request-bin.md) by configuring your resource to receive these events
76+
- Test your Event Grid handler [locally](../../how-tos/event-grid/local-testing-event-grid.md) to ensure that you are receiving events that you need for archiving.
77+
78+
> [!Note]
79+
> You would have to pay for [events](https://azure.microsoft.com/pricing/details/event-grid/).
80+
81+
## Next steps
82+
83+
* For an introduction to Azure Event Grid Concepts, see [Concepts in Event Grid](../../../event-grid/concepts.md)
84+
* Service [Limits](../../concepts/service-limits.md)
85+
* [Troubleshooting](../../concepts/troubleshooting-info.md)
86+
* Help and support [options](../../support.md)
87+
88+
89+
90+
18.3 KB
Loading

articles/communication-services/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,8 @@ items:
596596
href: concepts/chat/concepts.md
597597
- name: SDK features
598598
href: concepts/chat/sdk-features.md
599+
- name: Archiving Chats
600+
href: how-tos/chat-sdk/archive-chat-threads.md
599601
- name: Pricing
600602
href: https://azure.microsoft.com/pricing/details/communication-services/
601603
- name: Events

0 commit comments

Comments
 (0)