Export Chat of a Session
You can programmatically retrieve all chat messages of a Dyte session in the following ways:
This guide walks you through the steps involved in exporting chat dump of a session using Chat Replay API.
Once Chat Replay API is enabled, do the following:
- Get the
chat_download_urlusing Chat Replay API.
- Download the chat dump CSV file.
To get the
chat_download_url, make a
HTTP GET request to
Chat Replay API. The API returns the
chat_download_urlis a URL that allows you to download the entire chat dump of a session in CSV format from AWS S3.
chat_download_url_expiryindicates the expiry timestamp of the
chat_download_url. If the
chat_download_urlgets expired, simply call this endpoint again to obtain a new download URL.
Download the chat dump file
You can download the chat dump file in CSV format by making
HTTP GET request
chat_download_url that you obtained in the previous step.
Download on the client
To download at client side, do the following:
- Make a GET request to the
- Convert response to blob.
- Create an invisible
<a>HTML element with download attribute and add the above blob to it's
- Programmatically click on the
<a>element so that the browser automatically starts downloading and then remove the
Download on the server
Node.js streams to download files on the server, so the steps are as
- Create a writable stream for a local file.
- Make a GET request to
- Get a readable stream using
res.bodyand pipe to the writable stream created in the first step.
Example: CSV chat dump file
This CSV file contains all the chat messages along with the participant's name and some other metadata. It includes the following column headings:
id: Unique chat message ID
participantId: ID of the participant who sent the message
sessionId: The session ID from which the chat message was sent
meetingId: The ID of the meeting to which this session belongs
displayName: Display name of the participant who sent this message
pinned: A boolean that indicates if the current message was pinned or not
isEdited: A boolean that indicates if the current message was edited or not
payloadType: An ENUM that indicates the type of payload sent in the chat message. It can be one of TEXT_MESSAGE, IMAGE_MESSAGE, FILE_MESSAGE
payload: The actual payload sent in the chat message
createdAt: Timestamp when this chat message was sent
For more information on downloading the file, refer to How to Fetch Chat History of a Dyte Session blog.