Unblu Branch Client App Component API
    Preparing search index...

    Class UnbluBranchClientApi

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

    An instance of the UnbluBranchClientApi is returned by calling UnbluBranchClientAppElement.initialize or listening to the UnbluBranchClientAppElement.READY event.

    Note: After deinitialization an instance of UnbluBranchClientApi 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.

    Implements

    • InitializedUnbluApi
    Index

    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.

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

      ACTIVE_CONVERSATION_CHANGE for the event whenever the active conversation changes

    • Get the available languages.

      Returns Promise<Language[]>

      A promise that resolves with an array of the available Languages.

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

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

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

    • Get the current locale.

      Returns Promise<string>

      A promise that resolves with the language tag representation of the current locale

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

    • Get the current named area.

      Returns Promise<string>

      A promise that resolves with the site id of the current named area

      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

      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

      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

      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

      false
      

      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.

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

      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: BranchClientMetaEventType | AgentAvailabilityEventType | GeneralEventType

        The event to unregister from.

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

        The listener to remove.

      Returns Promise<void>

      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.

      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

      false
      

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

    • Change the current locale. The locale is changed dynamically for the current session. This ensures that, in new conversations, the concierge speaks the language selected. System messages in new conversations also appear in the selected language, and new conversations are assigned to the queue of that language.

      Calling this method does NOT change the language of the Unblu UI. That would require reinitialization.

      Parameters

      • languageTag: string

        Representation of the locale as a BCP 47 language tag

      Returns Promise<void>

      A promise that resolves when the language changes

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

    • Change the current named area. The named area is changed dynamically for the current session. This ensures that new conversations are based on the conversation template for the named area selected, and that the named area selected is the recipient of new conversations.

      Calling this method does NOT reinitialize the UI, nor does it load the configuration of the new named area. That would require reinitialization.

      Parameters

      • namedAreaSiteId: string

        new named area

      Returns Promise<void>

      A promise that resolves when the named area changes

      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

      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

      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

      • OptionalvisitorName: string

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

      • OptionalvisitorData: 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.

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

      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

    AGENT_AVAILABILITY_CHANGE: "availabilityChange" = 'availabilityChange'

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

    availabilityChange

    AGENT_AVAILABLE_CHANGE: "availableChange" = 'availableChange'

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

    availableChange

    AVAILABLE_LANGUAGES_CHANGE: "availableLanguagesChange" = 'availableLanguagesChange'

    Event emitted every time the available languages change.

    availableLanguagesChange

    AVAILABLE_NAMED_AREAS_CHANGE: "availableNamedAreasChange" = 'availableNamedAreasChange'

    Event emitted every time the available named areas change. Besides the named area information, the agent availability is provided for the given named areas.

    availableNamedAreasChange

    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

    DEINITIALIZED: "deinitialized" = 'deinitialized'

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

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

    deinitialized

    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

    FULLSCREEN_CHANGE: "fullscreenChange" = 'fullscreenChange'

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

    fullscreenChange

    LOCALE_CHANGE: "localeChange" = 'localeChange'

    Event emitted every time the locale changes.

    localeChange

    NAMED_AREA_CHANGE: "namedAreaChange" = 'namedAreaChange'

    Event emitted every time the named area changes.

    namedAreaChange

    NOTIFICATION_COUNT_CHANGE: "notificationCountChange" = 'notificationCountChange'

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

    notificationCountChange

    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

    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