Unblu Agent Embedded JS API
    Preparing search index...

    Class Conversation

    This class gives API access to a connected conversation.

    As long as a conversation is connected, one can register and receive the events provided by this class and call the methods. Once the conversation is disconnected this API object will be destroyed and no more event callbacks will be called. Any subsequent function calls will fail.

    Use the UnbluConversationConnectionsApi.CONVERSATION_DISCONNECTED event to deinitialize all code associated with this conversation. The DISCONNECT event can also be used, but it may not be triggered in all situations.

    Index

    Methods

    • Destroys this Conversation API instance.

      Calling destroy unregisters all event listeners and prohibits any further calls to this object. Once the Conversation is destroyed, any subsequent calls reject the returned promise with UnbluErrorType.ILLEGAL_STATE as the reason.

      Destroying a Conversation API instance does NOT:

      • disconnect the conversation
      • end the conversation
      • leave the conversation
      • destroy other instances of the same Conversation

      A conversation that's still connected but whose Conversation API instance has been destroyed can be accessed again using getActiveConversation.

      Returns void

    • Disconnects this conversation locally. Calling the method closes the connection to the conversation.

      If a web component displayed the conversation it will close the conversation there as well and will navigate back to the default UI route.

      • Disconnecting does NOT end the conversation.
      • The person does NOT leave the conversation.
      • All Conversation API instances for the conversation are destroyed.

      The agent can rejoin the conversation either via the UI or using connectConversation.

      Returns Promise<void>

      Empty once the conversation has been disconnected

      UnbluApiError if the call fails

    • Ends the conversation.

      Returns Promise<void>

      Empty once the conversation has been ended

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person doesn't have permission to end the conversation

      UnbluApiError if the call fails

    • Forwards the conversation to another agent. Once the forwarding is accepted, the target agent becomes the assigned agent of the conversation, and the current assigned agent leaves the conversation.

      Parameters

      Returns Promise<void>

      Empty once the conversation has been forwarded

      UnbluApiError if the call fails

    • Forwards the conversation back to the queue for a specific named area. Once the forwarding is accepted, the current assigned agent leaves the conversation.

      Parameters

      Returns Promise<void>

      Empty once the conversation has been forwarded

      UnbluApiError if the call fails

    • Forwards the conversation to a team. Any agent of the team can accept the forwarding. Once the forwarding is accepted, the accepting agent becomes the assigned agent of the conversation, and the current assigned agent leaves the conversation.

      Parameters

      Returns Promise<void>

      Empty once the conversation has been forwarded

      UnbluApiError if the call fails

    • Gets the conversation's call state for the local participant. Refer to CallState for possible states.

      Returns Promise<CallState>

      The current call state of the local participant

      CALL_STATE_CHANGE if you need to listen to changes

    • Returns an immutable snapshot of all the collaboration layers currently present in the conversation, independent of their state. As a conversation unfolds, its collaboration layers can change based on participants and configuration. Subsequent calls to the method may therefore return a different collection.

      Returns Promise<CollaborationLayer[]>

      The collaboration layers of the conversation

      COLLABORATION_LAYERS_CHANGE if you need to listen to changes.

      UnbluApiError if the call fails

    • Returns the conversation's current connection state.

      If the connection is lost, the conversation automatically tries to reconnect using an exponential back-off strategy.

      If a fatal error is detected, the conversation's connection state changes to ConnectionState.ERROR. When this happens, the conversation is in its terminal state. A dialog or other UI is displayed to the user with details of the failure.

      The conversation is not automatically closed after a fatal error. It may be closed through either manual action by the agent (confirming the error) or the API.

      Returns Promise<ConnectionState>

      The current connection state of the conversation

      CONNECTION_STATE_CHANGE if you need to listen to changes.

      UnbluApiError if the call fails

    • Returns the ID of the conversation

      Returns string

    • Returns a list of links to open the conversation in different Unblu UIs

      Returns Promise<ConversationLink>

      The list of links to open the conversation

      UnbluApiError if the call fails

    • Returns the current conversation state.

      Returns Promise<ConversationState>

      The current state of the conversation

      UnbluApiError if the call fails

    • Retrieves all custom conversation actions currently available in the conversation for the user

      Returns Promise<CustomAction[]>

      The custom conversation actions

    • Retrieves all custom person actions currently available in the conversation for the user

      Returns Promise<CustomAction[]>

      The custom person actions

    • Gets the currently displayed collaboration layer. The returned value is null if no layer is displayed.

      Returns Promise<CollaborationLayer>

      The currently displayed collaboration layer of the conversation, or null if no layer is displayed

      DISPLAYED_COLLABORATION_LAYER_CHANGE if you need to listen to changes.

      UnbluApiError if the call fails

    • Gets the metadata of the conversation. Metadata access must be allowed in the conversation's configuration.

      Returns Promise<Metadata>

      The metadata of the conversation

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if accessing the metadata is not permitted

      UnbluApiError if the call fails

    • Returns the list of current participants in the conversation. As participants can join and leave a conversation, subsequent calls may return a different collection.

      Returns Promise<CurrentConversationParticipant[]>

      The list of the conversation's current participants

      PARTICIPANTS_CHANGE if you need to listen to changes.

      UnbluApiError if the call fails

    • Gets the custom visitor data of the conversation.

      Returns Promise<string>

      The custom visitor data of the conversation

      UnbluApiError if the call fails

    • Invites a team to the conversation. Any agent of the team can accept the invitation and join the conversation.

      Parameters

      Returns Promise<void>

      Empty once the team has been invited

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person isn't allowed to invite teams

      UnbluApiError if the call fails

    • Invites a visitor to the conversation by email. The visitor receives an email with a link to the conversation.

      Parameters

      Returns Promise<void>

      Empty once the invitation email has been sent

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person isn't allowed to invite visitors by email

      UnbluApiError if the call fails

    • Creates a link which can be transmitted to a visitor to invite or add them to the conversation.

      Parameters

      Returns Promise<string>

      The link to invite the visitor

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person isn't allowed to create invitation links

      UnbluApiError if the call fails

    • Creates a PIN which can be transmitted to a visitor to invite or add them to the conversation.

      Parameters

      Returns Promise<string>

      The PIN to invite the visitor

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person isn't allowed to invite with PIN

      UnbluApiError if the call fails

    • Returns whether this Conversation API instance is destroyed or not.

      Conversation API instances are destroyed if destroy is called or the conversation is disconnected. This usually happens when the user navigates back to an overview or into another conversation.

      Returns boolean

      Whether this Conversation is destroyed or not.

    • Leaves and disconnects the conversation.

      By leaving, the agent is removed from the active participant list of the conversation. Once an agent leaves a conversation, they can't reconnect to it, and it isn't visible in their conversation history.

      Returns Promise<void>

      Empty once the conversation has been left

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person doesn't have permission to leave the conversation

      UnbluApiError if the call fails

    • Removes a previously registered listener.

      Parameters

      • event: ConversationEventType

        The event to unregister from.

      • listener: Listener

        The listener to remove.

      Returns boolean

    • Removes the given person from the conversation. The person will go through the "User removed" offboarding flow.

      Parameters

      • personId: string

        The ID of the person to remove

      Returns Promise<void>

      Empty once the person has been removed

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person isn't allowed to remove the person

      UnbluApiError if the call fails

    • Sets a new assigned agent for the conversation. The current assigned agent remains in the conversation as a secondary agent.

      Parameters

      Returns Promise<void>

      Empty once the assigned agent has been set

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person isn't allowed to set the assigned agent

      UnbluApiError if the call fails

    • Starts a video call in the conversation. The call is ignored if there's already an active call.

      Returns Promise<void>

      Empty once the call has been started

      CALL_STATE_CHANGE If you need to listen to changes.

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person isn't allowed to start a video call

      UnbluApiError if the call fails

    • Starts an audio call in this conversation. The call is ignored if there's already an active call.

      Returns Promise<void>

      Empty once the call has been started

      CALL_STATE_CHANGE If you need to listen to changes.

      UnbluApiError with type UnbluErrorType.ACTION_NOT_GRANTED if the local person isn't allowed to start a voice call

      UnbluApiError if the call fails

    • Triggers the given custom conversation action in the conversation

      Parameters

      • customConversationActionId: string

        The ID of the custom conversation action to trigger

      Returns Promise<void>

      Empty once the trigger has been sent. It doesn't mean the custom action was executed anywhere yet.

      UnbluApiError if the trigger fails

    • Triggers the given custom person action in the conversation

      Parameters

      • customPersonActionId: string

        The ID of the custom person action to trigger

      • personId: string

        The ID of the person for whom the action should be triggered

      Returns Promise<void>

      Empty once the trigger has been sent. It doesn't mean the custom action was executed anywhere yet.

      UnbluApiError if the trigger fails

    Events

    CALL_CONNECTION_STATE_CHANGE: "callConnectionStateChange" = ...

    Event emitted when the CallConnectionState of the conversation changes callConnectionStateChange

    on for listener registration

    CALL_STATE_CHANGE: "callStateChange" = ...

    Event emitted when the CallState of this conversation changes. callStateChange

    on for listener registration

    CONNECTION_STATE_CHANGE: "connectionStateChange" = ...

    Event emitted when the ConnectionState of this conversation changes. connectionStateChange

    on for listener registration

    CONVERSATION_STATE_CHANGE: "conversationStateChange" = ...

    Event emitted when the ConversationState of this conversation changes. conversationStateChange

    on for listener registration

    CUSTOM_ACTION_INVOCATION: "customActionInvocation" = ...

    Event emitted every time a custom action was invoked and is executed on the current integration

    customActionInvocation

    CUSTOM_CONVERSATION_ACTIONS_CHANGED: "customConversationActionsChanged" = ...

    Event emitted every time the custom conversation actions in the conversation change

    customConversationActionsChanged

    CUSTOM_PERSON_ACTIONS_CHANGED: "customPersonActionsChanged" = ...

    Event emitted every time the custom person actions in the conversation change *

    • customPersonActionsChanged
    • on for listener registration
    DISCONNECT: "disconnect" = ...

    Event emitted when the conversation is disconnected.

    This may happen due to a UI-navigation or an API-call.

    Note: The event isn't triggered if the conversation is disconnected by the server.

    disconnect

    on for listener registration

    DISPLAYED_COLLABORATION_LAYER_CHANGE: "displayedCollaborationLayerChange" = ...

    Event emitted when the displayed CollaborationLayer of the conversation changes displayedCollaborationLayerChange

    on for listener registration

    PARTICIPANTS_CHANGE: "participantsChange" = ...

    Event emitted when the CurrentConversationParticipants of the conversation change, that is, when:

    • A participant is added to or removed from the conversation
    • Any participant's data changes collaborationLayersChange

    on for listener registration