Options
All
  • Public
  • Public/Protected
  • All
Menu

Class UnbluApi

There is only ever one instance of this api which can be retrieved via unblu.api.initialize(), see UnbluStaticApi for more details on configuring and initializing the UnbluApi.

The API connects to the integrated version of Unblu. All actions performed via the UnbluApi are executed in the name of and with the rights of current visitor and may have direct effect on the displayed Unblu UI.

For example if a conversation is started from the UnbluApi, the Unblu UI will navigate to it. If a conversation is closed via the API, it will also be closed on the Unblu UI of the visitor. For more information on UI side effects please check the documentation for each method call.

For programmatic administrator access and configuration of Unblu please use the Unblu WebAPI.

Hierarchy

  • UnbluApi

Index

Events

Static ACTIVE_CONVERSATION_CHANGE

ACTIVE_CONVERSATION_CHANGE: "activeConversationChange" = "activeConversationChange"

Event emitted every time the active conversation changed.

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

see

on for listener registration

see

ConversationChangeListener

Static AGENT_AVAILABILITY_CHANGE

AGENT_AVAILABILITY_CHANGE: "availabilityChange" = "availabilityChange"

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

see

on for listener registration

see

AgentAvailabilityChangeListener

Static CONVERSATIONS_CHANGE

CONVERSATIONS_CHANGE: "conversationsChange" = "conversationsChange"

Event emitted every time when a conversation is changed, added or removed.

see

on for listener registration

see

ConversationsChangeListener

Static NOTIFICATION_COUNT_CHANGE

NOTIFICATION_COUNT_CHANGE: "notificationCountChange" = "notificationCountChange"

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

see

on for listener registration

see

NotificationCountChangeListener

Static PERSON_CHANGE

PERSON_CHANGE: "personChange" = "personChange"

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

see

on for listener registration

see

PersonChangeListener

Properties

ui

Access the UI functionality over the UI property.

Methods

getActiveConversation

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

    see

    ACTIVE_CONVERSATION_CHANGE

    Returns Promise<Conversation>

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

getAgentAvailabilityState

  • Returns the current availability state for the current named area and language.

    see

    isAgentAvailable for a simpler check.

    Returns Promise<AgentAvailabilityState>

    Promise that resolves to the current availability state.

getConversations

  • Returns all conversations of the current visitor. If no conversation is present, an empty array is returned.

    Returns Promise<ConversationInfo[]>

    A promise that resolves to an array of ConversationInfo.

getNotificationCount

  • getNotificationCount(): Promise<number>
  • Returns the number of unread messages.

    Returns Promise<number>

    A promise that resolves to the current number of unread messages.

getPersonInfo

  • Returns information about the visitor.

    Returns Promise<PersonInfo>

    A promise that resolves to the current visitors person info.

isAgentAvailable

  • isAgentAvailable(): Promise<boolean>
  • Checks if an agent is available for the current named area and language.

    see

    getAgentAvailabilityState for a more detailed check.

    Returns Promise<boolean>

    Promise that resolves to true if the availability state is AVAILABLE or BUSY, false otherwise.

joinConversation

  • joinConversation(pin: string, visitorName?: string): Promise<Conversation>
  • Joins an existing conversation with a given PIN.

    NOTE: calling this method will NOT automatically open the Unblu UI if it is collapsed. Use ui.openIndividualUi() if this is needed.

    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 object giving API access to the joined conversation.

off

  • off(event: GeneralEventType | AgentAvailabilityEventType, listener: Listener): boolean
  • Removes a previously registered listener

    Parameters

    • event: GeneralEventType | AgentAvailabilityEventType

      The event to unregister from.

    • listener: Listener

      The listener to remove.

    Returns boolean

on

  • Registers an event listener for the given event.

    see

    ACTIVE_CONVERSATION_CHANGE

    Parameters

    • event: "activeConversationChange"

      The activeConversationChange event.

    • listener: ConversationChangeListener

      The listener to be called.

    Returns void

  • Registers an event listener for the given event.

    see

    CONVERSATIONS_CHANGE

    Parameters

    Returns void

  • Registers an event listener for the given event.

    see

    NOTIFICATION_COUNT_CHANGE

    Parameters

    Returns void

  • Registers an event listener for the given event.

    see

    PERSON_CHANGE

    Parameters

    • event: "personChange"

      The personChange event.

    • listener: PersonChangeListener

      The listener to be called.

    Returns void

  • Registers an event listener for the given event.

    see

    PERSON_CHANGE

    Parameters

    Returns void

openConversation

  • openConversation(conversationId: string): Promise<Conversation>
  • Opens the existing conversation with the given conversation ID.

    NOTE: calling this method will NOT automatically open the Unblu UI if it is collapsed. Use ui.openIndividualUi() if this is needed.

    Parameters

    • conversationId: string

      The id of the conversation to be opened.

    Returns Promise<Conversation>

    A promise that resolves to the conversation object giving API access to the opened conversation.

setNewConversationInterceptor

  • Set 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 when the interceptor is successfully applied and active.

setPersonNickname

  • setPersonNickname(nickname: string): Promise<void>
  • Set the nickname of the current visitor. This could be set before or during a conversation.

    Parameters

    • nickname: string

    Returns Promise<void>

    A empty promise when operation is done.

startConversation

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

    NOTE: calling this method will NOT automatically open the Unblu UI if it is collapsed. Use ui.openIndividualUi() if this is needed.

    Parameters

    • type: ConversationType

      The conversation type that shall be started.

    • Optional visitorName: string

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

    • Optional visitorData: string

      Custom data for the visitor in any format. NOTE: The data which is passed here could be used in NewConversationCallback

    Returns Promise<Conversation>

    A promise that resolves to the conversation object giving API access to the started conversation.