This is the main class to interact with the Unblu embedded web component after initialization is done.

An instance of the UnbluEmbeddedApi is returned by calling UnbluEmbeddedAppElement.initialize or listening to the UnbluEmbeddedAppElement.READY event.

Note: After deinitialization an instance of UnbluEmbeddedApi is no longer usable and will throw errors on API calls. In order to access the API again, it is required to initialize Unblu again.

Hierarchy

  • UnbluEmbeddedApi

Implements

  • InitializedUnbluApi

Methods

  • Adds the label with the given labelName to the current visitor. This only adds the label as long as it exists, can be set on visitors and the visitor is allowed to set the label.

    Parameters

    • labelName: string

    Returns Promise<void>

    A promise that resolves empty when the operation is done or is rejected if it failed.

  • Deinitializes the Unblu Embedded Web Component. This means that both API is no longer usable but also the UI is completely destroyed.

    Returns Promise<void>

  • Returns the currently active conversation or null if no conversation is active.

    NOTE: calling this method twice while the same conversation is active, will result in two individual conversation API instances being returned. destroying one of them will not cause the other one to also be destroyed. If however the active conversation is closed, all returned Conversation instances will be destroyed.

    Returns Promise<Conversation>

    A promise that either resolves to the currently active conversation or null if no conversation is open.

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

    See

    ACTIVE_CONVERSATION_CHANGE for the event whenever the active conversation changes

  • All conversations accessible to the current user. If no conversation is present, an empty array is returned.

    Returns Promise<ConversationInfo[]>

    A promise that resolves to a list of all conversations accessible to the current user.

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Returns the number of unread messages.

    Returns Promise<number>

    A promise that resolves with the number of unread messages

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Returns the information about the current person.

    Returns Promise<PersonInfo>

    A promise that resolves with the current person information

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Returns the view mode of the embedded app element.

    Returns Promise<ViewMode>

    A promise that resolves with the current view mode

    Default

    {@link ViewMode.AUTO}
    

    See

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Returns true if an agent is available for the current named area and language. False otherwise.

    Returns Promise<boolean>

    A promise that resolves with true if an agent is available, false otherwise

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Checks if the current visitor is authenticated.

    Returns Promise<boolean>

    A promise that resolves to a boolean if the visitor is authenticated

  • Returns true if this instance of the API is deinitialized, false otherwise.

    Returns Boolean

  • Returns true if the UI is currently displayed in fullscreen, false otherwise.

    Returns Promise<boolean>

    A promise that resolves with true if the UI is in fullscreen mode, false otherwise

    Default

    false
    

    See

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Joins an existing conversation with a given PIN.

    Parameters

    • pin: string

      The PIN retrieved from the Unblu Agent Desk.

    • Optional visitorName: string

      The name the local visitor should have. This is only taken into account if the visitor is not already authenticated.

    Returns Promise<Conversation>

    A promise that resolves to the conversation which was joined

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Logs the current visitor in with the access token provided. Depending on the configuration, existing conversation may will be transferred to the authenticated user.

    Parameters

    • accessToken: string

      The access token (JWT) to authenticate the visitor with

    Returns Promise<void>

    A promise that resolves empty if the login succeeds or is rejected if it fails

  • Logs the visitor out. The user will not have access to conversations from the authenticated visitor he was before anymore. He needs to be authenticated again for that.

    Returns Promise<void>

    A promise that resolves empty when the logout succeeds or is rejected if it fails

  • Removes a previously registered listener

    Parameters

    • event: EmbeddedMetaEventType | AgentAvailabilityEventType | GeneralEventType

      The event to unregister from.

    • listener: ((data?) => void)

      The listener to remove.

        • (data?): void
        • Parameters

          • Optional data: any

          Returns void

    Returns Promise<void>

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Opens the conversation for the given conversation ID.

    If the conversation doesn't exist or the user doesn't have the right to access it, a dialog will be displayed with the respective error message. Be aware that in such a case the promise will still resolve successfully as the UI switched into the conversation view showing the error dialog. - The active conversation property will however be set to null.

    Parameters

    • conversationId: string

      The id of the conversation to open. Using null will close the current conversation and open the overview of conversations

    Returns Promise<Conversation>

    A promise that resolves with the opened conversation instance, null if the overview was opened, or it is rejected with an error if it did not work.

    See

    UnbluEmbeddedAppElement.ATTR_CONVERSATION_ID to set this as attribute

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Removes the label with the given labelName from the current visitor. This only removes the label as long as the visitor has the label applied to themselves and the visitor is allowed to remove the label.

    Parameters

    • labelName: string

    Returns Promise<void>

    A promise that resolves empty when the operation is done or is rejected if it failed.

  • When this attribute is set to true, the embedded app element will ignore the position and size set to its element and will used fixed positioning to display itself to cover the whole website.

    Note: The user itself can also toggle this inside the UI.

    Parameters

    • fullscreen: boolean

      True to enable fullscreen, false otherwise.

    Returns Promise<void>

    A promise that resolves as soon as the value has been applied

    Default

    false
    

    See

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Sets a custom interceptor which will be triggered when a new conversation is started (initiated from UI or JavaScript).

    Parameters

    Returns Promise<void>

    A promise that resolves as soon as the new interceptor has been applied

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Sets the nickname of the current user.

    This is only respected for anonymous visitors.

    Parameters

    • nickname: string

    Returns Promise<void>

    A promise that resolves as soon as the value has been applied

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Sets the view mode of the embedded app element.

    Depending on the view mode the UI is displayed the following way:

    • ViewMode.SPLIT: The UI will be divided into two parts. The list of conversations is displayed on the left and the active conversation on the right side.

    • ViewMode.SINGLE: Both the conversation list and the active conversation will be displayed in the same view using UI navigation to switch between them.

    • ViewMode.AUTO: The UI will automatically switch back and forth between the two other modes depending on the available width. The trigger point when to switch between the two modes can be configured on the Unblu collaboration server.

    Parameters

    • viewMode: ViewMode

      The new view mode to use

    Returns Promise<void>

    A promise that resolves as soon as the value has been applied

    Default

    {@link ViewMode.AUTO}
    

    See

    Throws

    UnbluApiError with type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized.

  • Starts a new conversation and places it into the inbound conversation queue.

    Starting a new conversation involves an agent availability check. For ConversationType.OFFLINE_CHAT_REQUEST conversations, the check proceeds as follows:

    • If an agent is available, the conversation type will be changed to ConversationType.CHAT_REQUEST.
    • If no agents are available, it will start an offline conversation provided offline chat requests are enabled in the Unblu server's configuration.
    • if offline chat requests aren't enabled, the request will be rejected.

    For all online conversation types, the check works as follows:

    • If an agent is available, the conversation will be started.
    • If no agents are available, the request will be rejected.

    You should therefore always check agent availability before starting a new conversation. If no agents are available, only start conversations of the type ConversationType.OFFLINE_CHAT_REQUEST.

    Parameters

    • type: ConversationType

      The type of the conversation

    • Optional visitorName: string

      The name of the visitor. This is only respected for anonymous visitors

    • Optional visitorData: string

      Custom visitor data that will be stored on the conversation and can be accessed through the Web API later on. This data won't be displayed anywhere and is for API usage only.

    • Optional recipient: NewConversationRecipient

      The team or agent recipient of the conversation. This will overwrite any named area that might be set for this web page.

    Returns Promise<Conversation>

    A promise that resolves to the conversation which was started

    Throws

    UnbluApiError of type UnbluErrorType.ILLEGAL_STATE when the API instance is deinitialized or if the conversation type may not be started.

Events

ACTIVE_CONVERSATION_CHANGE: "activeConversationChange" = 'activeConversationChange'

Event emitted every time the active conversation changes.

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

activeConversationChange

See

  • on for listener registration
  • ConversationChangeListener
AGENT_AVAILABILITY_CHANGE: "availabilityChange" = 'availabilityChange'

Event emitted every time the agent availability state changes for the current named area and locale.

availabilityChange

See

AGENT_AVAILABLE_CHANGE: "availableChange" = 'availableChange'

Event emitted every time the agent availability changes for the current named area and locale.

availableChange

See

CONVERSATIONS_CHANGE: "conversationsChange" = 'conversationsChange'

Event emitted every time one of the conversations accessible to the current user changes or one is added or removed.

conversationsChanged

See

DEINITIALIZED: "deinitialized" = 'deinitialized'

Event emitted when this instance got de-initialized and has to be initialized again.

Note: After this event, the instance of UnbluEmbeddedApi is no longer usable.

deinitialized

See

DEINITIALIZING: "deinitializing" = 'deinitializing'

Event emitted when this instance gets de-initialized and is not usable at the time until it fully got de-initialized.

deinitializing

See

FULLSCREEN_CHANGE: "fullscreenChange" = 'fullscreenChange'

Event emitted every time the embedded app switches to fullscreen mode or back.

fullscreenChange

See

NOTIFICATION_COUNT_CHANGE: "notificationCountChange" = 'notificationCountChange'

Event emitted every time the notification count (unread messages) changes.

notificationCountChange

See

PERSON_ACTIVITY: "personActivity" = 'personActivity'

Event emitted every time the local person has some activity inside Unblu. This may be i.e. an interaction with the chat, a call, opening a conversation or interacting with a co-browsing layer.

The event can be used to reset the logout timer inside an authenticated area, for example.

The configuration property com.unblu.conversation.activity.activityCategoriesToTrack specifies which categories of activity trigger the event.

personActivity

See

PERSON_CHANGE: "personChange" = 'personChange'

Event emitted every time the local person changes. This may be i.e. due to the person setting its name.

personChange

See

VIEW_MODE_CHANGE: "viewModeChange" = 'viewModeChange'

Event emitted every time the view mode changes.

viewModeChange

See