This topic describes how to use AICallKit SDK to enable intercom mode.
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
Enable intercom mode Switches from natural conversation mode to intercom mode. | Start speaking Presses and holds the Speak button to start communicating with the agent. |
This feature is included in the integration solution with a UI.
How it works
In intercom mode, each input from a user and each response from the intelligent agent are treated as independent events, similar to how traditional intercoms work. This mode makes the interaction between the users and intelligent agent more structured and orderly. In intercom mode, users can communicate with the intelligent agent in a more efficient and organized manner.
API details
API operation | Description |
API operation | Description |
enablePushToTalk | Enables or disables intercom mode. The status is indicated by the |
startPushToTalk | Presses and holds to start speaking. This call is valid only after intercom mode is enabled. During this period, the agent will remain in the listening state, and what the user says will be displayed in real time. We recommend that you call this API operation in the press event, and not in the release event. |
finishPushToTalk | Releases to finish speaking. The intelligent agent enters the thinking state, and soon broadcasts the results. |
cancelPushToTalk | Releases to cancel speaking. The intelligent agent does nothing and immediately returns to the waiting state of holding down to start speaking. |
Sample code
// By default, intercom mode is disabled. In this example, true is passed to enable intercom mode.
mARTCAICallEngine.enablePushToTalk(enable: true)
// Press and hold to start speaking.
mARTCAICallEngine.startPushToTalk()
// Release to finish speaking.
mARTCAICallEngine.finishPushToTalk()
// Release to cancel speaking.
mARTCAICallEngine.cancelPushToTalk()
// Handle callback events.
ARTCAICallEngine.IARTCAICallEngineCallback mCallEngineCallbackWrapper = new ARTCAICallEngine.IARTCAICallEngineCallback() {
@Override
public void onPushToTalk(boolean enable) {
// Indicate whether the onPushToTalk callback is configured for the current call.
// The onPushToTalk callback will tell you if intercom mode has been enabled or disabled.
}
}
// By default, intercom mode is disabled. In this example, true is passed to enable intercom mode.
engine.enablePushToTalk(enable);
// Press and hold to start speaking.
engine.startPushToTalk();
// Release to finish speaking.
engine.finishPushToTalk();
// Release to cancel speaking.
engine.cancelPushToTalk();
engine.on('pushToTalkChanged', (enable) => {
// Indicate whether the onPushToTalk callback is configured for the current call.
// The onPushToTalk callback will tell you if intercom mode has been enabled or disabled.
console.log('AICallPushToTalk', enable);
});