Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Conversation

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

Use the CLOSE event to de-init any code connected to this conversation.

Hierarchy

  • Conversation

Index

Events

Static Readonly CALL_STATE_CHANGE

CALL_STATE_CHANGE: "callStateChange" = 'callStateChange'

Event emitted when the CallState of this conversation changes.

see

on for listener registration

Static Readonly CLOSE

CLOSE: "close" = 'close'

Event emitted when the conversation is closed.

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

see

on for listener registration

Static Readonly CONNECTION_STATE_CHANGE

CONNECTION_STATE_CHANGE: "connectionStateChange" = 'connectionStateChange'

Event emitted when the ConnectionState of this conversation changes.

see

on for listener registration

Static Readonly CONVERSATION_STATE_CHANGE

CONVERSATION_STATE_CHANGE: "conversationStateChange" = 'conversationStateChange'

Event emitted when the ConversationState of this conversation changes.

see

on for listener registration

Static Readonly END

END: "end" = 'end'

Event emitted when the conversation ends.

deprecated

The end event is not always available, depending on the configuration. Use instead CONVERSATION_STATE_CHANGE event.

see

on for listener registration

Static Readonly INVITATIONS_CHANGE

INVITATIONS_CHANGE: "invitationsChange" = 'invitationsChange'

Event emitted when an Invitation is added to or removed from this conversation or if an existing one changes. The event emits an array of all visitor invitations created by the local person, all other invitations will not be present.

see

on for listener registration

Methods

closeConversation

  • closeConversation(): Promise<void>
  • Closes this conversation locally.

    When called, the connection to this conversation is closed and the overview is displayed.

    Note that:

    • Closing does NOT end the conversation.
    • The person does NOT leave the conversation.
    • All Conversation api instances for this conversation will be destroyed.

    The conversation can be joined again either via the UI or using UnbluApi.openConversation.

    see

    CLOSE fired after this call.

    see

    endConversation for details on ending a conversation.

    see

    [[leavingConversation]] for details on leaving a conversation.

    see

    destroy for details on destroying a conversation.

    Returns Promise<void>

    A Promise that resolves to null or is rejected with a UnbluApiError if the call fails.

createAnonymousEmailInvitation

  • createAnonymousEmailInvitation(email: String): Promise<Invitation>
  • Creates a new EMail invitation for this conversation.

    see

    INVITATIONS_CHANGE If you need to listen to changes for new invitations on this conversation.

    Parameters

    • email: String

      The email which the invitation should be send. It must be a valid email address.

    Returns Promise<Invitation>

    A promise that resolves to a new Invitation object with all relevant metadata. or is rejected with a UnbluApiError if the call fails.

createAnonymousPinInvitation

  • createAnonymousPinInvitation(): Promise<Invitation>
  • Creates a new PIN invitation for this conversation.

    see

    INVITATIONS_CHANGE If you need to listen to changes for new invitations on this conversation.

    Returns Promise<Invitation>

    A promise that resolves to a new Invitation object with all relevant metadata. or is rejected with a UnbluApiError if the call fails.

destroy

  • destroy(): void
  • Destroys this conversation API instance.

    Calling destroy will unregister all event listeners and prohibit any further calls to this object. Once the conversation is destroyed, any subsequent calls will reject the returned promise with UnbluErrorType.ILLEGAL_STATE as reason.

    Note that:

    • Destroying does NOT close the conversation .
    • Destroying does NOT end the conversation.
    • Destroying does NOT leave the conversation.
    • Other instances of the same Conversation will NOT be destroyed.

    This call simply destroys this local API instance to the conversation.

    A destroyed but still open conversation can be accessed again using UnbluApi.getActiveConversation.

    see

    isDestroyed

    see

    closeConversation for details on how to close a conversation

    see

    endConversation for details on how to end a conversation

    Returns void

endConversation

  • endConversation(): Promise<void>
  • Ends and closes this conversation.

    If the local person doesn't have the right to end the conversation, the returned promise will be rejected with the unblu error type UnbluErrorType.ACTION_NOT_GRANTED.

    see

    END fired after this call.

    see

    closeConversation for details on closing a conversation.

    Returns Promise<void>

    A Promise that resolves to null or is rejected with a UnbluApiError if the call fails.

getCallState

  • see

    CALL_STATE_CHANGE If you need to listen to changes.

    Returns Promise<CallState>

    A promise that resolves to the current call state of the local user or is rejected with a UnbluApiError if the call fails.

getConnectionState

  • Returns the current connection state the conversation is in.

    If the connection is lost, the conversation will automatically try to reconnect using an exponential back-off strategy. If a fatal error is detected, the state will change to ConnectionState.ERROR.

    If this happens, the conversation is in it's terminal state. A dialog or other UI will be displayed to the user with details on the failure. The conversation is not automatically closed in this case. It may either be closed through a manual action by the visitor (confirming the error) or via the API.

    see

    CONNECTION_STATE_CHANGE If you need to listen to changes.

    Returns Promise<ConnectionState>

    A promise that resolves to the current connection state of the conversation or is rejected with a UnbluApiError if the call fails.

getConversationId

  • getConversationId(): string
  • Returns the ID of this conversation.

    Returns string

getConversationState

  • Returns the current state the conversation is in.

    Returns Promise<ConversationState>

    A promise that resolves to the current state of the conversation or is rejected with a UnbluApiError if the call fails.

getInvitations

  • Get all visitor invitations created by the local person for this conversation.

    Returns Promise<Invitation[]>

    A promise that resolves to a new Invitation array with all relevant metadata. or is rejected with a UnbluApiError if the call fails.

isDestroyed

  • isDestroyed(): boolean
  • Returns weather this conversation is destroyed or not.

    Conversations are either destroyed if destroy is called or the conversation is closed. This usually happens when the user navigates back to an overview or into an other conversation.

    see

    destroy

    see

    CLOSE

    Returns boolean

    Weather this conversation is destroyed or not.

leaveConversation

  • leaveConversation(): Promise<void>
  • Leaves and closes this conversation.

    By leaving, the visitor is removed from the active participant list of the conversation. Once a conversation is left, the visitor can not re-open it. It will not be visible in the conversation history either.

    If the local person doesn't have the right to leave the conversation, the returned promise will be rejected with the unblu error type UnbluErrorType.ACTION_NOT_GRANTED.

    see

    CLOSE fired after this call.

    see

    closeConversation for details on closing a conversation without leaving.

    Returns Promise<void>

    A Promise that resolves to null or is rejected with a UnbluApiError if the call fails.

off

  • off(event: ConversationEventType, listener: Listener): boolean
  • Removes a previously registered listener.

    Parameters

    • event: ConversationEventType

      The event to unregister from.

    • listener: Listener

      The listener to remove.

    Returns boolean

on

  • Registers an event listener for the given event.

    see

    CONNECTION_STATE_CHANGE

    Parameters

    • event: "connectionStateChange"

      The call state change event.

    • listener: ConnectionStateListener

      The listener to be called.

    Returns void

  • Registers an event listener for the given event.

    see

    CONVERSATION_STATE_CHANGE

    Parameters

    • event: "conversationStateChange"

      The conversation state change event.

    • listener: ConversationStateListener

      The listener to be called.

    Returns void

  • Registers an event listener for the given event.

    see

    CALL_STATE_CHANGE

    Parameters

    • event: "callStateChange"

      The call state change event.

    • listener: CallStateListener

      The listener to be called.

    Returns void

  • Registers an event listener for the given event.

    deprecated

    The end event is not always available, depending on the configuration. Use instead CONVERSATION_STATE_CHANGE event.

    see

    END

    Parameters

    • event: "end"

      The end event.

    • listener: () => void

      The listener to be called.

        • (): void
        • Returns void

    Returns void

  • Registers an event listener for the given event.

    see

    CLOSE

    Parameters

    • event: "close"

      The close event.

    • listener: () => void

      The listener to be called.

        • (): void
        • Returns void

    Returns void

  • Registers an event listener for the given event.

    see

    INVITATIONS_CHANGE

    Parameters

    • event: "invitationsChange"

      The invitations change event.

    • listener: InvitationsListener

      The listener to be called.

    Returns void

renewInvitationPin

  • renewInvitationPin(invitationId: String): Promise<Invitation>
  • Renews an invitation PIN if the invitation is expired.

    Parameters

    • invitationId: String

      The invitation id.

    Returns Promise<Invitation>

    A promise that resolves to a new Invitation object with all relevant metadata.

revokeInvitation

  • revokeInvitation(invitationId: String): Promise<void>
  • Revoke an invitation.

    Parameters

    • invitationId: String

      The invitation id.

    Returns Promise<void>

    A Promise that resolves to null or is rejected with a UnbluApiError if the call fails.

setVisitorData

  • setVisitorData(visitorData: String): Promise<void>
  • Set custom visitor data on the conversation.

    Parameters

    • visitorData: String

      Custom data for the visitor in any format.

    Returns Promise<void>

startAudioCall

  • startAudioCall(): Promise<void>
  • Starts a voice call in this conversation.

    • If a call is already active, this call will be ignored.
    • If the local person doesn't have the right to start a voice call, the returned promise will be rejected with the unblu error type UnbluErrorType.ACTION_NOT_GRANTED.
    see

    CALL_STATE_CHANGE If you need to listen to changes.

    Returns Promise<void>

    A Promise that resolves to null or is rejected with a UnbluApiError if the call fails.

startVideoCall

  • startVideoCall(): Promise<void>
  • Starts a video call in this conversation.

    • If a call is already active, this call will be ignored.
    • If the local person doesn't have the right to start a video call, the returned promise will be rejected with the unblu error type UnbluErrorType.ACTION_NOT_GRANTED.
    see

    CALL_STATE_CHANGE If you need to listen to changes.

    Returns Promise<void>

    A Promise that resolves to null or is rejected with a UnbluApiError if the call fails.