This topic describes how to use AICallKit SDK to query the status of an intelligent agent.
Usage notes
The following examples show how to implement this feature using the API without the UI.
You must integrate AICallKit SDK in advance. For more information, see Integrate AICallKit SDK for Android, Integrate AICallKit SDK for iOS, and Integrate AICallKit SDK for Web.
Overview
Listening The agent is listening for user input. | Thinking The agent is thinking, and the large language model (LLM) is generating an output. | Speaking The agent is speaking and can be interrupted. |
This feature is included in the integration solution with a UI.
Query the agent status
Possible states
State | Description |
State | Description |
Listening | The agent is listening for user input. If the user is speaking, the volume bar of the user may be displayed in this state. |
Thinking | The agent is thinking and the current LLM is generating an output. The state changes to Listening when interrupted. |
Speaking | The agent is broadcasting the LLM output. The state changes to Listening when interrupted. |
Sample code
// Register a callback for a call engine.
mARTCAICallEngine.setEngineCallback(mCallEngineCallbackWrapper);
// Handle callback events.
ARTCAICallEngine.IARTCAICallEngineCallback mCallEngineCallbackWrapper = new ARTCAICallEngine.IARTCAICallEngineCallback() {
@Override
public void onAICallEngineRobotStateChanged(ARTCAICallEngine.ARTCAICallRobotState oldRobotState, ARTCAICallEngine.ARTCAICallRobotState newRobotState) {
// Use newRobotState to update the status on the UI.
}
@Override
public void onVoiceVolumeChanged(String uid, int volume) {
// If the agent is in the Listening state, the volume bar of the user is displayed.
}
}
// Register a callback for a call engine.
self.engine.delegate = self
func onAgentStateChanged(state: ARTCAICallAgentState) {
// Use state to update the status on the UI when the agent status changes.
}
func onVoiceVolumeChanged(uid: String, volume: Int32) {
// If the agent is in the Listening state, the volume bar of the user is displayed.
}
engine.on('agentStateChange', (state) => {
// Use state to update the status on the UI when the agent status changes.
console.log('AICallAgentStateChange to:', state);
});
engine.on('speakingVolumeChanged', (userId, volume) => {
// The speaking volume of the agent.
// If the userId parameter is an empty string, the volume is the volume of the current user.
console.log('AICallSpeakingVolumeChanged', volume);
});