From Bright Pattern Documentation
Jump to: navigation, search
This page contains changes which are not marked for translation.
• 5.19

onInteractionStateChange

This handler is called when one of the interactions of the active agent changes its state.

Request

Syntax

on('ON_INTERACTION_STATE_CHANGE', handler: OnInteractionStateChangeHandler): void


type OnInteractionStateChangeHandler = (interaction: InteractionData) => void


type InteractionData = {

    interactionId: string

    state: InteractionState

    type: InteractionType

    subject: string

    associatedObjects: InteractionAssociatedObjectsData

    callParties: CallParty[]

    callMuted: boolean

    callRecording: boolean

    attachedData: AttachedData

    phoneNumber?: string

    email?: string

    callDirection?: CallDirection

    startTime?: number

    endTime?: number

    duration?: number

    description?: string

    disposition?: string

    globalInteractionId?: string

    service?: string

    playbackUrl?: string

    recordingUrl?: string

    DNIS?: string

    ANI?: string

    origination?: InteractionOrigination

}

type InteractionType = "voice" | "chat" | "email"

type InteractionState =

    "unknown" |

    "queued" |

    "ivr" |

    "wrap_up" |

    "wrap_up_hold" |

    "delivered" |

    "delivery_pending" |

    "hold" |

    "completed"

type InteractionOrigination =

    "dialpad" |

    "dialpad-search" |

    "directory" |

    "recent" |

    "favorites" |

    "workitem" |

    "interaction" |

    "contact-profile" |

    "help" |

    "conference" |

    "auto" |

    "integration-api"

type CallDirection = "inbound" | "outbound"

type CallParty = {

  id: string

  name: string

  phone: string

  userId?: string

}

Parameters

Parameter Parameter Values Data Type Optional/Required Description
interaction
type String Required Indicates the interaction type; recognized types are as follows:
  • "voice"
  • "chat"
  • "email"
agentId String Required The agent’s ID
interactionId String Required The interaction’s ID
globalInteractionId String Optional The interaction’s global interaction ID (GIID)
service String Optional The name of the service to which the interaction relates
callParties String Required Provides a list of call parties. Note that this applies to interactions where type is "voice".  Where:
  • id
    • The unique party ID
  • name
    • The party’s display name
  • phone
    • The used phone number
  • userId?
    • (Optional) The unique user ID. That is, it is an ID from the TeamMember list entry from the getTeamMembers method. If the party is not an internal user, the userId will be undefined
callMuted Boolean Required If set to true, the call is muted; if set to false, the call is not muted. Note that non-call interactions are always false.
callRecording Boolean Required If set to true, call recording active; if set to false, call recording is not active. Note that non-call interactions are always set to false.
disposition String Optional The name of the disposition category for the completed interaction
recordingUrl String Optional The URL of the call recording. Note that this applies to interactions where type is "voice".
callDirection String Optional The type of call; recognized directions are as follows:
  • "inbound"
  • "outbound"

Note that this applies to interactions where type is "voice".

DNIS String Optional The Dialed Number Identification Service (DNIS). Note that this applies to interactions where type is "voice".
transferANI ? Optional The automatic number identification (ANI) for a transfer. Note that this applies to interactions where type is "voice".
phoneNumber String Optional The callee’s phone number. Note that this applies to interactions where type is "voice".
startTime Number Optional The interaction’s start date and time
endTime Number Optional The interaction’s end date and time
duration Number Optional The interaction’s duration in seconds
origination String Optional Indicates how the interaction was initiated. There is a list of predefined values.

Example Request

const interactionsList: InteractionData[] = [];

function interactionStateChangeCallback(data: InteractionData) {

const index = interactionsList.findIndex(item => item.interactionId === data.interactionId);

if (index === -1) {

interactionsList.push(data);

} else {

interactionsList[index] = data;

}

}

adApi.on("ON_INTERACTION_STATE_CHANGE", interactionStateChangeCallback);

Return Value

(None)


< Previous | Next >