Record agent conversations
Updated
Record conversations with an agent using Cloud Recording, without interrupting the audio.
Preview documentation
This guide explains how to record conversations with a Conversational AI Platform agent using Agora Cloud Recording, and how to avoid audio interruptions when recording starts.
Why this needs special handling
When an agent and Cloud Recording are in the same channel, recording startup can briefly interrupt the audio. The issue is usually caused by the agent's audio scenario falling back to a default mode when Cloud Recording joins the channel.
To keep the audio stable, set the agent's audio scenario to chorus when you start the session.
Start the session with the chorus audio scenario
When you start a session, set its audio scenario to chorus. The SDK examples use the saved agent from Create an agent and start a session.
session = saved_agent.create_session(
channel="<your_channel_name>",
token="<your_rtc_token>",
agent_uid="1002",
remote_uids=["1001"],
values={"customer_name": "Ada"},
audio_scenario="chorus",
)
session_id = session.start()const session = savedAgent.createSession({
channel: '<your_channel_name>',
token: '<your_rtc_token>',
agentUid: '1002',
remoteUids: ['1001'],
values: { customer_name: 'Ada' },
audioScenario: 'chorus',
});
const sessionId = await session.start();session := savedAgent.CreateSession(agentkit.CreateSessionOptions{
Channel: "<your_channel_name>",
Token: "<your_rtc_token>",
AgentUID: "1002",
RemoteUIDs: []string{"1001"},
Values: map[string]any{"customer_name": "Ada"},
AudioScenario: "chorus",
})
sessionID, err := session.Start(ctx)
if err != nil {
log.Fatal(err)
}In the request to Start a session, set transport.audio_scenario:
curl --request POST \
--url https://preview.ai.agora.io/conversational-ai/v1/projects/<your_app_id>/sessions \
--header 'Authorization: Basic <your_base64_encoded_credentials>' \
--header 'Content-Type: application/json' \
--data '
{
"agent_id": "3f6c2a9e-8d1b-4e7a-9c55-0b2f7d1e4a10",
"values": {
"customer_name": "Ada"
},
"transport": {
"type": "rtc",
"channel": "<your_channel_name>",
"token": "<your_rtc_token>",
"uid": "1002",
"subscribe_uids": ["1001"],
"audio_scenario": "chorus"
}
}'The audio scenario is a session setting, not part of the agent. Set it only for the sessions you record. Other sessions keep the default, aiserver. For details, see Optimize audio quality.
Start recording
After the session is running, call the Start Cloud Recording API to begin recording. Use a recording UID that's different from the agent's and the user's UIDs.
The following example shows a Cloud Recording request body:
{
"cname": "<your_channel_name>",
"uid": "<your_recording_uid>",
"clientRequest": {
"token": "<your_recording_token>",
"recordingConfig": {
"maxIdleTime": 120,
"streamTypes": 0,
"audioProfile": 1,
"channelType": 1
},
"recordingFileConfig": {
"avFileType": [
"hls",
"mp4"
]
},
"storageConfig": {
"vendor": "<your_storage_vendor>",
"region": "<your_storage_region>",
"bucket": "<your_bucket>",
"accessKey": "<your_access_key>",
"secretKey": "<your_secret_key>"
}
}
}Reference
For more information, see the following pages:
