From Bright Pattern Documentation
Jump to: navigation, search
(Created page with "<translate> =onAgentStateChange= This handler will be invoked when the state of the agent changes. ==Request== ''Syntax'' {| class="wikitable" |on('ON_AGENT_STATE_CHANGE',...")
 
(Updated via BpDeleteTranslateTags script)
 
Line 1: Line 1:
<translate>
+
 
 
=onAgentStateChange=
 
=onAgentStateChange=
  
Line 63: Line 63:
  
 
(None)
 
(None)
 
 
 
</translate>
 

Latest revision as of 04:01, 29 May 2024

• 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 >