@gibme/asterisk-gateway-interface
    Preparing search index...

    Class Channel

    Represents an AGI Channel

    Hierarchy

    • EventEmitter
      • Channel
    Index

    Constructors

    • Creates a new instance of a channel object

      Parameters

      • connection: Socket

        the AGI socket connection

      Returns Channel

    Accessors

    • get accountcode(): string

      Account code of the origin channel

      Returns string

    • get autoCloseOnHangup(): boolean

      Gets the value of the close on hangup setting

      Returns boolean

    • set autoCloseOnHangup(value: boolean): void

      Gets the value of the close on hangup setting

      Parameters

      • value: boolean

      Returns void

    • get callerid(): string

      The caller ID number (or “unknown”)

      Returns string

    • get calleridname(): string

      The caller ID name (or “unknown”)

      Returns string

    • get callingani2(): string

      The number which is defined in ANI2 see Asterisk Detailed Variable List (only for PRI Channels)

      Returns string

    • get callingpres(): string

      The presentation for the callerid in a ZAP channel

      Returns string

    • get callingtns(): string

      An optional 4-digit number (Transit Network Selector) used in PRI Channels see Asterisk Detailed Variable List

      Returns string

    • get callington(): string

      The type of number used in PRI Channels see Asterisk Detailed Variable List

      Returns string

    • get channel(): string

      The originating channel (your phone)

      Returns string

    • get context(): string

      Origin context in extensions.conf

      Returns string

    • get dnid(): string

      The dialed number id (or “unknown”)

      Returns string

    • get enhanced(): string

      The flag value is 1.0 if started as an EAGI script, 0.0 otherwise

      Returns string

    • get extension(): string

      The called number

      Returns string

    • get language(): string

      The language code (e.g. “en”)

      Returns string

    • get network(): boolean

      Whether this AGI request is over the network

      Returns boolean

    • get network_script(): string

      The network path included in the AGI request e.g. agi://127.0.0.1:3000/test This value would return 'test'

      Returns string

    • get outgoingHeaders(): Record<string, string>

      Headers that have been set for outgoing requests

      Returns Record<string, string>

    • get priority(): string

      The priority it was executed as in the dial plan

      Returns string

    • get rdnis(): string

      The referring DNIS number (or “unknown”)

      Returns string

    • get remoteIP(): string

      Gets the IP address of the Asterisk Server that initiated the channel

      Returns string

    • get request(): string

      The filename of your script ie. agi

      Returns string

    • get threadid(): string

      Thread ID of the AGI script

      Returns string

    • get type(): Driver

      The originating channel type (e.g. “SIP” or “ZAP”)

      Returns Driver

    • get uniqueid(): string

      A unique ID for the call

      Returns string

    • get version(): string

      The version of Asterisk

      Returns string

    Methods

    • Adds a header to the outgoing request

      Parameters

      • key: string
      • value: string

      Returns Promise<void>

    • Answers channel if not already in answer state.

      Returns Promise<void>

    • Interrupts expected flow of Async AGI commands and returns control to previous source (typically, the PBX dialplan).

      Returns Promise<void>

    • Indicates busy to the calling channel

      Parameters

      • Optionaltimeout: number

        if specified, the calling channel will be hung up after the specified number of seconds. Otherwise, this application will wait until the calling channel hangs up

      Returns Promise<number>

    • Returns status of the connected channel.

      Parameters

      • Optionalchannel: string

      Returns Promise<State>

    • Indicates congestion to the calling channel

      Parameters

      • Optionaltimeout: number

        if specified, the calling channel will be hung up after the specified number of seconds. Otherwise, this application will wait until the calling channel hangs up

      Returns Promise<number>

    • Sends audio file on channel and allows the listener to control the stream.

      Parameters

      • filename: string
      • escapeDigits: string = ''
      • Optionalskipms: number
      • OptionalfastForwardCharacter: string
      • OptionalrewindCharacter: string
      • OptionalpauseCharacter: string

      Returns Promise<
          {
              digit: string;
              playbackOffset: number;
              playbackStatus: Channel.Playback.Status;
          },
      >

    • Deletes an entry in the Asterisk database for a given family and key.

      Parameters

      • family: string
      • key: string

      Returns Promise<void>

    • Deletes a family or specific keytree within a family in the Asterisk database.

      Parameters

      • family: string
      • OptionalkeyTree: string

      Returns Promise<boolean>

    • Retrieves an entry in the Asterisk database for a given family and key.

      Parameters

      • family: string
      • key: string

      Returns Promise<string>

    • Adds or updates an entry in the Asterisk database for a given family, key, and value.

      Parameters

      • family: string
      • key: string
      • value: string

      Returns Promise<string>

    • Attempts to establish a new outgoing connection on a channel, and then link it to the calling input channel.

      Parameters

      • target: string
      • options: Partial<{ hangupOnComplete: boolean; params: string; timeout: number }> = {}

      Returns Promise<
          {
              answered_time: number;
              dialed_time: number;
              peer_name: string;
              peer_number: string;
              progress_time: number;
              ring_time: number;
              status: Channel.Dial.Status;
          },
      >

    • Executes application with given options

      Parameters

      • application: string
      • ...args: string[]

      Returns Promise<number>

    • Stream the given file, and receive DTMF data.

      Parameters

      • soundFile: string
      • timeout: number = 5
      • OptionalmaxDigits: number

      Returns Promise<{ digits: string; timeout: boolean }>

    • Evaluates a channel expression Understands complex variable names and builtin variables, unlike GET VARIABLE.

      Parameters

      • key: string
      • Optionalchannel: string
      • keyToUpper: boolean = true

      Returns Promise<string>

    • Evaluates a channel expression Understands complex variable names and builtin variables, unlike GET VARIABLE.

      Parameters

      • key: string
      • Optionalchannel: string

      Returns Promise<string>

    • Attempts to retrieve the inbound header specified from the channel

      Note: This method can only read headers on the incoming request. It can not read headers set on an outbound SIP request.

      Parameters

      • key: string

      Returns Promise<undefined | string>

    • Stream file, prompt for DTMF, with timeout. Behaves similar to STREAM FILE but used with a timeout option.

      Parameters

      • soundFile: string
      • escapeDigits: string = '#'
      • timeout: number = 5

      Returns Promise<{ digit: string; endpos: number }>

    • Gets a channel variable.

      Parameters

      • key: string
      • keyToUpper: boolean = true

        whether to force the key to uppercase

      Returns Promise<string>

    • Cause the channel to execute the specified dialplan subroutine.

      Parameters

      • context: string
      • extension: string
      • priority: number
      • Optionalargument: string

      Returns Promise<void>

    • Hangs up the specified channel. If no channel name is given, hangs up the current channel

      Parameters

      • Optionalchannel: string

      Returns Promise<void>

    • Does nothing

      Returns Promise<void>

    • Event that is emitted when the underlying socket encounters an error

      Parameters

      • event: "error"
      • listener: (error: any) => void

      Returns this

    • Event that is emitted when the underlying socket is closed

      Parameters

      • event: "close"
      • listener: () => void

      Returns this

    • Event that emitted when the underlying socket times out

      Parameters

      • event: "timeout"
      • listener: () => void

      Returns this

    • Event that is emitted when the channel is ready

      Parameters

      • event: "ready"
      • listener: () => void

      Returns this

    • Event that is emitted when a response is received from the Asterisk server

      Parameters

      • event: "recv"
      • listener: (response: string) => void

      Returns this

    • Event that emitted when the channel is hung up

      Parameters

      • event: "hangup"
      • listener: () => void

      Returns this

    • Event that emitted when the response from the Asterisk server is processed into a structured response

      Parameters

      • event: "response"
      • listener: (response: Response) => void

      Returns this

    • Event that is emitted when data is sent to the Asterisk server

      Parameters

      • event: "send"
      • listener: (data: string) => void

      Returns this

    • Requests that in-band progress information be provided to the calling channel

      Returns Promise<number>

    • Receives one character from channels supporting it.

      Parameters

      • timeout: number = 5

      Returns Promise<{ char: string; timeout: boolean }>

    • Receives text from channels supporting it.

      Parameters

      • timeout: number = 5

      Returns Promise<string>

    • Records to a given file.

      Parameters

      • filename: string
      • fileFormat: string = 'gsm'
      • escapeDigits: string = '#'
      • timeout: number = 10
      • Optionalbeep: boolean
      • Optionalsilence: number
      • OptionaloffsetSamples: number

      Returns Promise<{ digit: string; endpos: number; timeout: boolean }>

    • Allows you to remove a header from the outgoing request as long as you have added it via the addHeader() method.

      Parameters

      • key: string

      Returns Promise<void>

    • Requests that the channel indicate a ringing tone to the user

      Returns Promise<number>

    • Says a given character string.

      Parameters

      • value: string
      • escapeDigits: string = '#'

      Returns Promise<string>

    • Says a given date.

      Parameters

      • value: number | Date
      • escapeDigits: string = '#'

      Returns Promise<string>

    • Says a given time as specified by the format given.

      Parameters

      • value: number | Date
      • escapeDigits: string = '#'
      • OptionaldateFormat: string
      • Optionaltimezone: string

      Returns Promise<string>

    • Says a given digit string.

      Parameters

      • value: string
      • escapeDigits: string = '#'

      Returns Promise<string>

    • Says a given number.

      Parameters

      • value: number
      • escapeDigits: string = '#'

      Returns Promise<string>

    • Says a given character string with phonetics.

      Parameters

      • value: string
      • escapeDigits: string = '#'

      Returns Promise<string>

    • Says a given time.

      Parameters

      • value: number | Date
      • escapeDigits: string = '#'

      Returns Promise<string>

    • Sends images to channels supporting it.

      Parameters

      • image: string

      Returns Promise<void>

    • Sends text to channels supporting it.

      Parameters

      • text: string

      Returns Promise<void>

    • Autohangup channel in some time.

      Parameters

      • timeout: number = 60

      Returns Promise<void>

    • Sets callerid for the current channel.

      Parameters

      • callerNumber: number
      • OptionalcallerName: string

      Returns Promise<void>

    • Sets channel context.

      Parameters

      • context: string

      Returns Promise<void>

    • Changes channel extension.

      Parameters

      • extension: string

      Returns Promise<void>

    • Enable/Disable Music on hold generator

      Parameters

      • status: boolean = true
      • OptionalmusicClass: string

      Returns Promise<void>

    • Set channel dialplan priority.

      Parameters

      • priority: number

      Returns Promise<void>

    • Set channel dialplan priority.

      Parameters

      • key: string
      • value: string

      Returns Promise<void>

    • Parameters

      • grammar: string

      Returns Promise<Response>

    • Parameters

      • engine: string

      Returns Promise<Response>

    • Parameters

      • grammar: string

      Returns Promise<Response>

    • Parameters

      • grammar: string
      • path: string

      Returns Promise<Response>

    • Parameters

      • soundFile: string
      • timeout: number = 5
      • offset: number

      Returns Promise<Response>

    • Parameters

      • key: string
      • value: string

      Returns Promise<Response>

    • Parameters

      • grammar: string

      Returns Promise<Response>

    • Sends audio file on channel.

      Parameters

      • filename: string
      • escapeDigits: string = '#'
      • Optionaloffset: number

      Returns Promise<{ digit: string; endpos: number }>

    • Toggles TDD mode (for the deaf).

      Parameters

      • status: boolean

      Returns Promise<void>

    • Logs a message to the asterisk verbose log.

      Parameters

      • message: string
      • Optionallevel: number

      Returns Promise<void>

    • Waits for a digit to be pressed.

      Parameters

      • timeout: number = 5

      Returns Promise<string>