Data archiving

更新时间:
复制 MD 格式

Archive conversation data from Real-time Conversational AI sessions as text, audio, or recordings for compliance, analytics, and LLM fine-tuning.

Overview

Data archiving captures conversations between users and AI agents as structured text for storage and later retrieval via API. Audio and video data can also be stored in Object Storage Service (OSS) or ApsaraVideo VOD.

Archive conversation data

Real-time Conversational AI provides three archiving methods. Use one or more depending on the data your application needs:

Method

Data captured

Best for

Text chat records

Full conversation transcript with timestamps

Audit trails, analytics, LLM fine-tuning

Sentence-by-sentence audio callback

Per-sentence audio files and transcript via webhook

Real-time processing, low-latency access

ARTC cloud recording

Full call audio/video recording stored in OSS

Compliance, playback

Text chat records

After a session ends, call the DescribeAIAgentInstance API and read the CallLogUrl field from the response. The URL points to a JSON file containing the full conversation transcript.

Code example

import os
import sys
from typing import List
from alibabacloud_ice20201109.client import Client as ICE20201109Client
from alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_ice20201109 import models as ice20201109_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_console.client import Client as ConsoleClient
from alibabacloud_tea_util.client import Client as UtilClient

class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> ICE20201109Client:
        """
        Initialize the client using credentials.
        To configure credentials, see https://help.aliyun.com/document_detail/378659.html.
        """
        # Use credential-free authentication in production environments.
        credential = CredentialClient()
        config = open_api_models.Config(
            credential=credential
        )
        # For the endpoint, see https://api.aliyun.com/product/ICE
        config.endpoint = f'ice.us-west-1.aliyuncs.com'
        return ICE20201109Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        describe_aiagent_instance_request = ice20201109_models.DescribeAIAgentInstanceRequest(
            instance_id='YOUR_INSTANCE_ID'
        )
        runtime = util_models.RuntimeOptions()
        try:
            resp = client.describe_aiagent_instance_with_options(describe_aiagent_instance_request, runtime)
            ConsoleClient.log(UtilClient.to_jsonstring(resp))
            ConsoleClient.log(UtilClient.to_jsonstring(resp.body.instance.call_log_url))
        except Exception as error:
            print(error.message)
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

if __name__ == '__main__':
    Sample.main(sys.argv[1:])

CallLogUrl structure example

The CallLogUrl file is a JSON document. All dialog entries are ordered by begin (seconds from session start). Each entry has the following fields: id, begin, role (agent or user), type (greeting or normal), and text.

{
    "instanceid": "b9566********************3c5eb2",
    "startTime": 1755138072.2456193,
    "agentUserId": "AGENT_USER1b7**************fac945",
    "remoteUserId": "210413545",
    "dialog": [
        {
            "id": 1,
            "begin": 4.45,
            "role": "agent",
            "type": "greeting",
            "text": "Hello. I am Xiaoyun from Alibaba Video Cloud. Let's chat."
        },
        {
            "id": 2,
            "begin": 5.383,
            "role": "user",
            "type": "normal",
            "text": "Tell me an interesting children's story."
        },
        {
            "id": 3,
            "begin": 53.951,
            "role": "agent",
            "type": "normal",
            "text": "Once upon a time, in a magical forest, there lived a little fox named Qiaoqiao. Qiaoqiao loved collecting colorful leaves, and each one was her treasure. One day, she found a magic leaf that produced a small surprise every day. One day it was delicious honey, another time a beautiful rainbow umbrella, and all the animals in the forest were very envious.\n\nQiaoqiao decided to share this joy. She invited her friends to play together and share the surprises from the magic leaf. From then on, happiness and friendship in the forest grew, and they spent many unforgettable moments together. This is the story of Qiaoqiao and her magic leaf. Listening to this story every night, children would sweetly fall into their dreams."
        },
        {
            "id": 4,
            "begin": 54.922,
            "role": "user",
            "type": "normal",
            "text": "Tell me a different story."
        },
        {
            "id": 5,
            "begin": 81.97,
            "role": "agent",
            "type": "normal",
            "text": "A long, long time ago, there was a space explorer named Stardust who had a key made of stars. Whenever he encountered a problem, the key would light up and guide him to a solution. His friends loved him because he always returned from his adventures with new stories and a lot of courage. Exploring the unknown universe with Stardust became the adventure that children longed for the most."
        },
        {
            "id": 6,
            "begin": 84.78,
            "role": "user",
            "type": "normal",
            "text": "Tell me another story."
        },
        {
            "id": 7,
            "begin": 88.561,
            "role": "user",
            "type": "normal",
            "text": "I... um..."
        }
    ]
}

Sentence-by-sentence audio callback

In the console, enable real-time chat record callback and sentence-by-sentence user and AI agent audio callback. For configuration details, see agent callback.

When configuring callbacks, provide the callback URL and authentication token. For the sentence-by-sentence user and AI agent audio callback, also select an OSS storage location. Use HTTPS for the callback URL.

ARTC cloud recording

Use the cloud recording feature of Alibaba Real-Time Communication (ARTC) to record calls. For details, see Cloud recording.

Note

This method applies only to ARTC, not to outbound or inbound phone calls.