This topic describes how to obtain real-time historical chat records of audio and video calls initiated during messaging conversations.
Scenario description
In messaging conversation scenarios, you can integrate chat records between users and audio/video call agents with chat records of messaging conversation agents to create complete chat records between users and different types of agents.
Feature description
In Alibaba Real-Time Communication (ARTC), SessionID is used to identify the conversation relationship between users and agents, ensuring that each interaction can be completely recorded and traced by the system. With this unique identifier, the system can accurately identify and organize multi-round conversations initiated by the same user at different times, forming a coherent and clear chat history. Additionally, you can use SessionID to associate all chat records between users and call-type agents along with conversation-type agents.
Merging messaging conversations with audio/video chat records
Business flow
ARTC uses a unique SessionID
to associate all chat records between users and messaging conversation agents along with audio/video call-type agents (VoiceChat, AvatarChat, VisionChat). When you start an audio/video conversation during a messaging conversation, if you need to integrate chat records generated by messaging conversation agents and audio/video call agents, you need to pass the ChatSyncConfig
field when starting the audio/video call agent, setting the messaging conversation agent ID and SessionID
.
Code implementation
You need to initiate an audio/video call agent through the client-side AICallKit SDK interface, and configure the ARTCAICallChatSyncConfig
parameter in ARTCAICallConfig
. The sample code is as follows:
Android
//Create ARTCAICallConfig, configure ARTCAICallAgentTemplateConfig and ARTCAICallChatSyncConfig parameters
ARTCAICallEngine.ARTCAICallConfig artcaiCallConfig = new ARTCAICallEngine.ARTCAICallConfig();
//Configure ARTCAICallChatSyncConfig parameters
artcaiCallConfig.mAiCallChatSyncConfig.chatBotAgentId = "XXX";//Associated messaging conversation agent ID
artcaiCallConfig.mAiCallChatSyncConfig.sessionId = "XXX";//SessionId passed by the business
artcaiCallConfig.mAiCallChatSyncConfig.receiverId = "XXX";//User ID, the unique identifier ID of the user in the business system
//Configuration of ARTCAICallAgentTemplateConfig parameters and initiation process are omitted
iOS
// Create ARTCAICallChatSyncConfig object and set parameters
let agentId = "xxx" //Associated messaging conversation agent ID
let sessionId = "xxx" //SessionId passed by the business
let receiverId = "xxxx" //User ID, the unique identifier ID of the user in the business system
let chatSyncConfig = ARTCAICallChatSyncConfig(sessionId: sessionId, agentId: agentId, receiverId: receiverId)
// If you use the integration solution with UI, set config.templateConfig when you start a call
let controller = AUIAICallStandardController(userId: userId)
controller.config.chatSyncConfig = chatSyncConfig
...
// If you use the integration solution without UI, convert chatSyncConfig to json string and use it with sessionId as request parameters for starting AI call (StartAIAgentInstance or GenerateAIAgentCall)
let chatSyncConfigJsonString = chatSyncConfig.getConfigString()
let sessionId = chatSyncConfig.sessionId
...
Web
// Create ARTCAICallChatSyncConfig object and set parameters
const sessionId = 'xxx'; //Associated messaging conversation agent ID
const agentId = 'xxx'; //SessionId passed by the business
const receiverId = 'xxxx'; //User ID, the unique identifier ID of the user in the business system
const chatSyncConfig = new AICallChatSyncConfig(sessionId, agentId, receiverId);
// Create AICallTemplateConfig object, set interruptWords parameter
let templateConfig = new AICallTemplateConfig();
templateConfig.chatSyncConfig = chatSyncConfig;
// If you use the integration solution with UI, modify src/runConfig.ts
const runConfig: AICallRunConfig = {
// ...
callTemplateConfig: templateConfig,
// ...
};
// If you use the integration solution without UI, convert chatSyncConfig to json string and use it with sessionId as request parameters for starting AI call (StartAIAgentInstance or GenerateAIAgentCall)
const chatSyncConfigJsonString = chatSyncConfig.getConfigString();
const sessionId = chatSyncConfig.sessionId;
...