VonageClient is the main entry point for the Vonage Client SDK.

Hierarchy

  • CombinedClientJS
    • VonageClient

Methods

  • Clear all callbacks for an event.

    Type Parameters

    • T extends "mute" | "conversationEvent" | "callHangup" | "callMediaDisconnect" | "legStatusUpdate" | "rtcStatsUpdate" | "callInvite" | "callInviteCancel" | "sessionError" | "callMediaError" | "callTransfer" | "earmuff" | "dtmf" | "callMediaReconnecting" | "callMediaReconnection" | "reconnecting" | "reconnection"

    Parameters

    • event: T

      the event to unregister from (e.g. 'legStatusUpdate')

    Returns void

    void

    Example

    [[include: snippet_ClearCallbacks.txt]]
    

    Remarks

    This is useful for cleaning up callbacks when you no longer need them.

  • Create a session with a token and optional sessionId If no sessionId is provided, a new one will be generated and returned. If a sessionId is provided, it will be used to resume an existing session.

    Parameters

    • token: string
    • Optional sessionId: null | string

      optional sessionId to use

    Returns Promise<string>

    the sessionId of the session

    Example

    [[include: snippet_SessionCreate.txt]]
    
  • Get a Conversation

    Parameters

    • conversationIdOrName: string

      the Conversation's id or conversation name

    Returns Promise<Conversation>

    the Conversation

    Example

    [[include: snippet_GetConversation.txt]]
    
  • Unregister a callback for an event.

    Type Parameters

    • T extends "mute" | "conversationEvent" | "callHangup" | "callMediaDisconnect" | "legStatusUpdate" | "rtcStatsUpdate" | "callInvite" | "callInviteCancel" | "sessionError" | "callMediaError" | "callTransfer" | "earmuff" | "dtmf" | "callMediaReconnecting" | "callMediaReconnection" | "reconnecting" | "reconnection"

    Parameters

    • event: T

      the event to register for (e.g. 'legStatusUpdate')

    • callbackSymbol: symbol

      the callback symbol to unregister

    Returns boolean

    true if the callback was unregistered, false otherwise

    Example

    [[include: snippet_UnregisterListener.txt]]
    

    Remarks

    We recommend deregistering callbacks when you no longer need them.

  • Register a callback for an event.

    Type Parameters

    • T extends "mute" | "conversationEvent" | "callHangup" | "callMediaDisconnect" | "legStatusUpdate" | "rtcStatsUpdate" | "callInvite" | "callInviteCancel" | "sessionError" | "callMediaError" | "callTransfer" | "earmuff" | "dtmf" | "callMediaReconnecting" | "callMediaReconnection" | "reconnecting" | "reconnection"

    • P extends ((event) => void) | ((callId, callQuality, reason) => void) | ((callId, reason) => void) | ((callId, legId, legStatus) => void) | ((stats, callId) => void) | ((callId, reason) => void) | ((callId, from, channelType) => void) | ((reason) => void) | ((callId, error) => void) | ((callId, legId, isMuted) => void) | ((callId, conversationId) => void) | ((callId, legId, earmuffStatus) => void) | ((callId, legId, digits) => void) | ((callId) => void) | ((callId) => void) | (() => void) | (() => void)

    Parameters

    • event: T

      the event to register for (e.g. 'legStatusUpdate')

    • callback: P

      the callback to register for the event

    Returns symbol

    a symbol that can be used to unregister the callback

    Example

    [[include: snippet_OnConversationEventListener.txt]]
    

    Remarks

    Be sure to store the symbol returned by this method so you can unregister the callback later. We recommend unregistering callbacks when you no longer need them. See off.

  • Set a configuration for the client SDK

    Parameters

    Returns void

    void

    Example

    [[include: snippet_SetClientConfig.txt]]
    
  • Updates a conversation object identified by its unique conversation ID.

    This method overrides the conversation properties to the provided parameters and rest remains as it is.

    Parameters

    • conversationId: string

      the Conversation's id.

    • parameters: UpdateConversationParameters

      The properties of the conversation. These will replace existing values to the provided ones, rest will remain as they are.

    Returns Promise<Conversation>

    conversation, this object will contain the updated conversation properties if the update is successful.

    Example

    [[include: snippet_UpdateConversation.txt]]
    

Chat

  • Create a conversation

    Parameters

    Returns Promise<string>

    the cid of the conversation

    Example

    [[include: snippet_CreateConversation.txt]]
    
  • Delete a Conversation

    Parameters

    • id: string

      the Conversation's id

    Returns Promise<void>

    void

    Example

    [[include: snippet_DeleteConversation.txt]]
    
  • Delete an Event in a Conversation

    Parameters

    • id: number

      the id for the Event to be deleted

    • conversationId: string

      the id for the conversation, the event belongs to.

    Returns Promise<void>

    void

    Example

    [[include:snippet_DeleteEvent.txt]]
    
  • Get a Member of a Conversation

    Parameters

    • cid: string

      the Conversation's id

    • mid: string

      the Member's id

    Returns Promise<Member>

    the Member

    Example

    [[include: snippet_GetConversationMember.txt]]
    
  • Get a Conversation's Members

    Parameters

    Returns Promise<MembersPage>

    a MembersPage containing the members

    Example

    [[include: snippet_GetConversationMembers.txt]]
    
  • Get a list of Conversations for the user.

    Parameters

    Returns Promise<ConversationsPage>

    a ConversationsPage containing the conversations

    Example

    [[include: snippet_GetConversations.txt]]
    
  • Invite a user to a Conversation by user's name

    Parameters

    • id: string

      the Conversation's id

    • name: string

      the name of the user to invite

    Returns Promise<string>

    the memberId of the member

    Example

    [[include: snippet_InviteToConversation.txt]]
    
  • Join a Conversation

    Parameters

    • id: string

      the Conversation's id

    Returns Promise<string>

    the memberId of the member

    Example

    [[include: snippet_JoinConversation.txt]]
    
  • Leave a Conversation

    Parameters

    • id: string

      the Conversation's id

    Returns Promise<void>

    void

    Example

    [[include: snippet_LeaveConversation.txt]]
    
  • Send a Custom event to a Conversation

    Parameters

    • id: string

      the Conversation's id

    • eventType: string
    • customData: CustomData

      the body of the event

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendCustomEvent.txt]]
    
  • Send an ephemeral event to a Conversation

    Parameters

    • id: string

      the Conversation's id

    • customData: CustomData

      the body of the event

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendEphemeralEvent.txt]]
    
  • Send a audio message to a Conversation.

    Parameters

    • id: string

      the Conversation's id

    • audioUrl: URL

      the url of the audio resource.

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendAudioMessage.txt]]
    
  • Send a custom message to a Conversation

    Parameters

    • id: string

      the Conversation's id

    • customData: CustomData

      the body of the message

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendCustomMessage.txt]]
    
  • Send a file message to a Conversation.

    Parameters

    • id: string

      the Conversation's id

    • fileUrl: URL

      the url of the file resource.

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendFileMessage.txt]]
    
  • Send a Image message to a Conversation.

    Parameters

    • id: string

      the Conversation's id

    • imageUrl: URL

      the url of the image resource.

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendImageMessage.txt]]
    
  • Send a Location message to a Conversation.

    Parameters

    • id: string

      the Conversation's id

    • location: Location

      the description of the location.

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendLocationMessage.txt]]
    
  • Send a message seen event to a Conversation

    Parameters

    • id: number

      the event id

    • conversationId: string

      the conversation id

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendMessageSeenEvent.txt]]
    
  • Send a template message to a Conversation.

    Parameters

    • id: string

      the Conversation's id

    • templateObject: Template

      the description(name and paramters) of the template.

    • whatsappObject: Whatsapp

      the description(locale and policies of business account) of the location.

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendTemplateMessage.txt]]
    
  • Send a text message to a Conversation

    Parameters

    • id: string

      the Conversation's id

    • text: string

      the Body of the message

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendTextMessage.txt]]
    
  • Send a vcard message to a Conversation.

    Parameters

    • id: string

      the Conversation's id

    • vCardUrl: URL

      the url of the vCardUrl resource.

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendVcardMessage.txt]]
    
  • Send a Vidoe message to a Conversation.

    Parameters

    • id: string

      the Conversation's id

    • videoUrl: URL

      the url of the video resource.

    Returns Promise<string>

    the timestamp of the message

    Example

    [[include: snippet_SendVideoMessage.txt]]
    

Voice

  • Answer a call

    Parameters

    • callId: string

      Call ID

    Returns Promise<void>

    void

    Example

    [[include: snippet_AnswerCall.txt]]
    
  • Unearmuff your leg of a call

    Parameters

    • callId: string

      Call ID

    Returns Promise<void>

    void

    Example

    [[include: snippet_DisableEarmuff.txt]]
    
  • Earmuff your leg of a call

    Parameters

    • callId: string

      Call ID

    Returns Promise<void>

    void

    Example

    [[include: snippet_EnableEarmuff.txt]]
    
  • Experimental

    Get the HTML Audio Element for the SDK. It can be used to route output to other devices.

    Returns undefined | HTMLAudioElement

  • Get a Call's Legs

    Parameters

    Returns Promise<LegsPage>

    a LegsPage containing the legs

    Example

    [[include: snippet_GetCallLegs.txt]]
    
  • Get the Leg for a call

    Parameters

    • legId: string

      The Leg Id

    Returns Promise<LegJS>

  • Experimental

    Get the Peer Connection for a call

    Parameters

    • id: string

      The Call Id

    Returns RTCPeerConnection

  • Hangup a call.

    Parameters

    • callId: string

      the callId of the call to hangup

    • Optional reasonText: string

      optional reason text to send to the other party

    • Optional reasonCode: string

      optional reason code to send to the other party

    Returns Promise<void>

    void

    Example

    [[include: snippet_CallHangup.txt]]
    
  • Mute your leg of a call

    Parameters

    • callId: string

      Call ID

    Returns Promise<void>

    void

    Example

    [[include: snippet_Mute.txt]]
    
  • Reconnect a call

    Parameters

    • callId: string

      Call ID

    Returns Promise<void>

    void

    Example

    [[include: snippet_ReconnectCall.txt]]
    
  • Reject a call

    Parameters

    • callId: string

      Call ID

    Returns Promise<void>

    void

    Example

    [[include: snippet_RejectCall.txt]]
    
  • Sends a TTS message to the Call

    Parameters

    • callId: string

      the callId of the call to send the message to

    • text: string

      the text to send

    Returns Promise<void>

    void

  • Sends a TTS message to the Call

    Parameters

    • callId: string

      the callId of the call to send the message to

    • params: CallSayParams

      the CallSayParams to send

    Returns Promise<void>

    void

    Example

    [[include: snippet_Say.txt]]
    
  • Send a string of digits to a call via DTMF

    Parameters

    • callId: string

      Call ID

    • digits: string

      DTMF digits

    Returns Promise<void>

    void

    Example

    [[include: snippet_Dtmf.txt]]
    
  • Make a server call to the Vonage API. This is used to initiate a call using the Voice API and NCCO.

    Parameters

    • Optional context: Json

      the context to send to the server passed as Custom data to the voice answer webhook

    Returns Promise<string>

    the callId of the call

    Example

    [[include: snippet_OutboundCall.txt]]
    
  • Unmute your leg of a call

    Parameters

    • callId: string

      Call ID

    Returns Promise<void>

    void