From Bright Pattern Documentation
Jump to: navigation, search
• 5.19


onAgentStateChange

This handler will be invoked when the state of the agent changes.

Request

Syntax

on('ON_AGENT_STATE_CHANGE', handler: OnAgentStateChangeHandler): void


type OnAgentStateChangeHandler = (state: AgentState, notReadyReason?: string) => void


type AgentState = "ready" | "not_ready" | "busy" | "after_call_work"

Parameters

Parameter Parameter Values Data Type Optional/Required Description
state String Required The agent’s state, can be any of the following:
  • "ready"
  • "not_ready"
  • "busy"
  • "after_call_work"
notReadyReason String Optional The reason why the agent is "not_ready" now. Note that this parameter is present only when the state is not_ready

Example

let currentAgentState: AgentState | undefined = undefined;

let currentAgentNotReadyReason: string | undefined = undefined;

function agentStateChangeCallback(newState: AgentState, notReadyReason?: string) {

console.log("Agent state has been changed!");

currentAgentState = newState;

currentAgentNotReadyReason = notReadyReason;

}

adApi.on("ON_AGENT_STATE_CHANGE", agentStateChangeCallback);

Return Value

(None)

< Previous | Next >