From Bright Pattern Documentation
removeFromChatConference
Remove another agent from the chat. If interactionId isn't specified, it will work with active interaction.
Request
Syntax
| removeFromChatConference(partyId: string, interactionId?: string): Promise<OperationResult<null>> |
Parameters
| Parameter | Parameter Values | Data Type | Optional/Required | Description |
| partyId | String | Required | ID of the chat party you intend to remove from the chat. This ID is not the same ID used to add users with method "inviteToChatConference". The correct ID can be obtained from interaction property chatParties, which you should get with subscription to events related to interactions (such as ON_INTERACTION_STATE_CHANGE). | |
| interactionId | String | Optional | ID of the chat interaction from which you want to remove a party. If not specified, the active interaction will be used. |
Example Request
const interactionsMap = {};
let activeInteractionId = null;
adApi.on("ON_NEW_INTERACTION", interaction => {
interactionsMap[interaction.id] = interaction
})
adApi.on("ON_INTERACTION_STATE_CHANGE", interaction => {
interactionsMap[interaction.id] = interaction
})
adApi.on("ON_INTERACTION_REMOVED", interaction => {
delete interactionsMap[interaction.id]
})
adApi.on('ON_ACTIVE_INTERACTION_SWITCHED', interactionId => {
activeInteractionId = interactionId
})
function removeLastChatParty() {
const activeChatParties = interactionsMap[activeInteractionId].chatParties
const lastChatParty = activeChatParties[activeChatParties.length - 1]
adApi.removeFromChatConference(lastChatParty.id, activeInteractionId)
}
Return Value
null