Topik ini menjelaskan cara mengarsipkan data.
Cara kerja
Arsip data mengonversi percakapan antara pengguna dan AI agent menjadi teks untuk disimpan. Bisnis dapat memanggil operasi API untuk mengambil data tersebut. Selain itu, bisnis juga dapat menyimpan data audio dan video dari panggilan antara pengguna dan AI agent di Object Storage Service (OSS) atau platform ApsaraVideo VOD.
Implementasi
Alibaba Cloud menyediakan metode arsip data berikut: catatan chat teks, callback audio per kalimat, dan rekaman panggilan dari ApsaraVideo Real-time Communication (ARTC).
Catatan obrolan teks
Anda dapat memanggil operasi API DescribeAIAgentInstance untuk mengambil URL file teks dari bidang CallLogUrl dan menyimpan catatan chat teks yang dihasilkan.
Contoh pemanggilan
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:
"""
Menginisialisasi klien dengan kredensial.
@return: Client
@throws Exception
"""
# Untuk lingkungan produksi, kami menyarankan Anda menggunakan metode yang lebih aman, seperti RAM roles, untuk mengautentikasi permintaan Anda. Untuk informasi selengkapnya tentang konfigurasi kredensial, lihat https://www.alibabacloud.com/help/document_detail/378659.html.
credential = CredentialClient()
config = open_api_models.Config(
credential=credential
)
# Untuk informasi selengkapnya tentang endpoint, lihat 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:
# Kode berikut hanya untuk demonstrasi. Dalam proyek Anda, tangani exception dengan hati-hati dan jangan abaikan.
# Pesan error
print(error.message)
# Alamat diagnostik
print(error.data.get("Recommend"))
UtilClient.assert_as_string(error.message)
if __name__ == '__main__':
Sample.main(sys.argv[1:])Struktur contoh CallLogUrl
{
"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..."
}
]
}Callback audio per kalimat
Di Konsol, Anda dapat mengonfigurasi Real-time Chat Record Callbacks dan Sentence-by-sentence Audio Callbacks For Users And Agents. Untuk informasi selengkapnya, lihat Agent callbacks.

Rekaman panggilan ARTC
Anda dapat menggunakan fitur cloud recording dari ARTC untuk merekam panggilan. Untuk informasi selengkapnya, lihat Cloud recording.
Metode ini hanya berlaku untuk ARTC dan tidak berlaku untuk panggilan telepon outbound atau inbound.