All Products
Search
Document Center

Intelligent Media Services:Data archiving

Last Updated:Dec 02, 2025

This topic describes how to archive data.

How it works

Data archiving converts conversations between users and AI agents into text for storage. Businesses can call API operations to retrieve this data. Additionally, businesses can store audio and video data from calls between users and AI agents in Object Storage Service (OSS) or the ApsaraVideo VOD platform.

Implementation

Alibaba Cloud provides the following data archiving methods: text chat records, sentence-by-sentence audio callbacks, and call recordings from ApsaraVideo Real-time Communication (ARTC).

Text chat records

You can call the DescribeAIAgentInstance API operation to retrieve the text file URL from the CallLogUrl field and store the generated text chat records.

Sample call

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:
        """
        Initializes the client with credentials.
        @return: Client
        @throws Exception
        """
        # For production environments, we recommend that you use a more secure method, such as RAM roles, to authenticate your requests. For more information about credential configuration, see https://www.alibabacloud.com/help/document_detail/378659.html.
        credential = CredentialClient()
        config = open_api_models.Config(
            credential=credential
        )
        # For more information about endpoints, 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:
            # The following code is for demonstration only. In your projects, handle exceptions with care and do not ignore them.
            # Error message
            print(error.message)
            # Diagnostic address
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

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

Sample CallLogUrl structure

{
    "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'm Xiaoyun from ApsaraVideo. 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, there was a little fox named Qiaoqiao who lived in a magical forest. Qiaoqiao loved to collect colorful leaves, and each leaf was its treasure. One day, it found a magic leaf that produced a small surprise every day. One day it was delicious honey, another time a beautiful rainbow umbrella. The animals in the forest were very envious.\n\nQiaoqiao decided to share this joy. It invited its friends to play games and share the surprises from the magic leaf. From then on, happiness and friendship grew in the forest, and they all spent many unforgettable moments together. This is the story of Qiaoqiao and her magic leaf. Every night, listening to this story helps children drift sweetly into their dreams."
        },
        {
            "id": 4,
            "begin": 54.922,
            "role": "user",
            "type": "normal",
            "text": "Tell me another 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 faced a problem, the key would light up and guide him to the solution. His friends loved him very much because every time he returned from an adventure, he brought back new stories and great courage. Exploring the unknown universe with Stardust became the adventure that children longed for 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... uh..."
        }
    ]
}

Sentence-by-sentence audio callbacks

In the console, you can configure Real-time Chat Record Callbacks and Sentence-by-sentence Audio Callbacks For Users And Agents. For more information, see Agent callbacks.

image

ARTC call recording

You can use the cloud recording feature of ARTC to record calls. For more information, see Cloud recording.

Note

This method applies only to ARTC. It does not apply to outbound or inbound phone calls.