Options
Menu

Class Call

A Call represents a media and signaling connection to a TwiML application.

Hierarchy

  • EventEmitter
    • Call

Index

Events

Static acceptEvent

  • acceptEvent(call: Call): void

Static audioEvent

  • Emitted after the HTMLAudioElement for the remote audio is created.

    example

    call.on('audio', handler(remoteAudio))

    Parameters

    Returns void

Static cancelEvent

  • cancelEvent(): void

Static disconnectEvent

  • disconnectEvent(call: Call): void

Static errorEvent

Static messageReceivedEvent

  • messageReceivedEvent(message: Message): void
  • Emitted when a Call receives a message from the backend.

    This feature is currently in Beta.

    Parameters

    • message: Message

      A message object representing the payload that was received from the Twilio backend.

    Returns void

Static messageSentEvent

  • messageSentEvent(message: Message): void
  • Emitted after calling the Call.sendMessage API. This event indicates that Twilio has received the message.

    This feature is currently in Beta.

    Parameters

    • message: Message

      A message object that was sent to the Twilio backend.

    Returns void

Static muteEvent

  • muteEvent(isMuted: boolean, call: Call): void
  • Emitted when the Call is muted or unmuted.

    example

    call.on('mute', (isMuted, call) => { })

    Parameters

    • isMuted: boolean

      Whether the Call is muted.

    • call: Call

      The Call.

    Returns void

Static reconnectedEvent

  • reconnectedEvent(): void
  • Emitted when the Call has regained media connectivity.

    example

    call.on('reconnected', () => { })

    Returns void

Static reconnectingEvent

  • Emitted when the Call has lost media connectivity and is reconnecting.

    example

    call.on('reconnecting', error => { })

    Parameters

    Returns void

Static rejectEvent

  • rejectEvent(): void

Static ringingEvent

  • ringingEvent(hasEarlyMedia: boolean): void
  • Emitted when the Call has entered the ringing state. When using the Dial verb with answerOnBridge=true, the ringing state will begin when the callee has been notified of the call and will transition into open after the callee accepts the call, or closed if the call is rejected or cancelled.

    example

    call.on('ringing', hasEarlyMedia => { })

    Parameters

    • hasEarlyMedia: boolean

      Denotes whether there is early media available from the callee. If true, the Client SDK will automatically play the early media. Sometimes this is ringing, other times it may be an important message about the call. If false, there is no remote media to play, so the application may want to play its own outgoing ringtone sound.

    Returns void

Static sampleEvent

  • Emitted when the Call gets a webrtc sample object. This event is published every second.

    example

    call.on('sample', sample => { })

    Parameters

    Returns void

Static volumeEvent

  • volumeEvent(inputVolume: number, outputVolume: number): void
  • Emitted every 50ms with the current input and output volumes, as a percentage of maximum volume, between -100dB and -30dB. Represented by a floating point number.

    example

    call.on('volume', (inputVolume, outputVolume) => { })

    Parameters

    • inputVolume: number

      A floating point number between 0.0 and 1.0 inclusive.

    • outputVolume: number

      A floating point number between 0.0 and 1.0 inclusive.

    Returns void

Static warningClearedEvent

  • warningClearedEvent(name: string): void
  • Emitted when a call quality metric has returned to normal. You can listen for this event to update the user when a call quality issue has been resolved.

    example

    call.on('warning-cleared', name => { })

    Parameters

    • name: string

      The name of the warning

    Returns void

Static warningEvent

  • warningEvent(name: string, data: any): void
  • Emitted when the SDK detects a drop in call quality or other conditions that may indicate the user is having trouble with the call. You can implement callbacks on these events to alert the user of an issue.

    To alert the user that an issue has been resolved, you can listen for the warning-cleared event, which indicates that a call quality metric has returned to normal.

    For a full list of conditions that will raise a warning event, check the Voice Insights SDK Events Reference page.

    example

    call.on('warning', (name, data) => { })

    Parameters

    • name: string

      The name of the warning

    • data: any

      An object containing data on the warning

    Returns void

Properties

Readonly callerInfo

callerInfo: CallerInfo | null

Returns caller verification information about the caller. If no caller verification information is available this will return null.

Readonly customParameters

customParameters: Map<string, string>

The custom parameters sent to (outgoing) or received by (incoming) the TwiML app.

Optional Readonly outboundConnectionId

outboundConnectionId: undefined | string

The temporary CallSid for this call, if it's outbound.

parameters

parameters: Record<string, string>

Call parameters received from Twilio for an incoming call.

Static defaultMaxListeners

defaultMaxListeners: number

Accessors

codec

  • get codec(): string

direction

Methods

accept

addListener

  • addListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

disconnect

  • disconnect(): void

emit

  • emit(event: string | symbol, ...args: any[]): boolean
  • Parameters

    • event: string | symbol
    • Rest ...args: any[]

    Returns boolean

eventNames

  • eventNames(): Array<string | symbol>
  • Returns Array<string | symbol>

getLocalStream

  • getLocalStream(): MediaStream | undefined

getMaxListeners

  • getMaxListeners(): number

getRemoteStream

  • getRemoteStream(): MediaStream | undefined

ignore

  • ignore(): void

isMuted

  • isMuted(): boolean

listenerCount

  • listenerCount(type: string | symbol): number
  • Parameters

    • type: string | symbol

    Returns number

listeners

  • listeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

mute

  • mute(shouldMute?: boolean): void
  • Mute incoming audio.

    Parameters

    • Default value shouldMute: boolean = true

      Whether the incoming audio should be muted. Defaults to true.

    Returns void

off

  • off(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

on

  • on(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

once

  • once(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

postFeedback

  • Post an event to Endpoint Analytics indicating that the end user has given call quality feedback. Called without a score, this will report that the customer declined to give feedback.

    Parameters

    • Optional score: FeedbackScore

      The end-user's rating of the call; an integer 1 through 5. Or undefined if the user declined to give feedback.

    • Optional issue: FeedbackIssue

      The primary issue the end user experienced on the call. Can be: ['one-way-audio', 'choppy-audio', 'dropped-call', 'audio-latency', 'noisy-call', 'echo']

    Returns Promise<void>

prependListener

  • prependListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

prependOnceListener

  • prependOnceListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

rawListeners

  • rawListeners(event: string | symbol): Function[]
  • Parameters

    • event: string | symbol

    Returns Function[]

reject

  • reject(): void

removeAllListeners

  • removeAllListeners(event?: string | symbol): this
  • Parameters

    • Optional event: string | symbol

    Returns this

removeListener

  • removeListener(event: string | symbol, listener: function): this
  • Parameters

    • event: string | symbol
    • listener: function
        • (...args: any[]): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    Returns this

sendDigits

  • sendDigits(digits: string): void

sendMessage

  • sendMessage(message: Message): string
  • Send a message to Twilio. Your backend application can listen for these messages to allow communication between your frontend and backend applications.

    This feature is currently in Beta.

    Parameters

    • message: Message

      The message object to send.

    Returns string

    A voice event sid that uniquely identifies the message that was sent.

setMaxListeners

  • setMaxListeners(n: number): this
  • Parameters

    • n: number

    Returns this

status

Static listenerCount

  • listenerCount(emitter: EventEmitter, event: string | symbol): number
  • deprecated

    since v4.0.0

    Parameters

    • emitter: EventEmitter
    • event: string | symbol

    Returns number

Generated using TypeDoc