From Bright Pattern Documentation
• 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
|
Parameters
Parameter | Parameter Values | Data Type | Optional/Required | Description |
state | String | Required | The agent’s state, can be any of the following:
| |
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)