Represents an AGI Channel

Hierarchy

  • EventEmitter
    • Channel

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): 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 ie. agi://127.0.0.1:3000/test This value would return 'test'

    Returns 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(): ChannelDriver
  • The originating channel type (e.g. “SIP” or “ZAP”)

    Returns ChannelDriver

  • get uniqueid(): string
  • A unique ID for the call

    Returns string

  • get version(): string
  • The version of Asterisk

    Returns string

Methods

  • Adds a SIP header to the outbound call

    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>

  • Returns status of the connected channel.

    Parameters

    • Optional channel: string

    Returns Promise<ChannelState>

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

    Parameters

    • filename: string
    • escapeDigits: string = ''
    • Optional skipms: number
    • Optional fastForwardCharacter: string
    • Optional rewindCharacter: string
    • Optional pauseCharacter: string

    Returns Promise<{
        digit: string;
        playbackOffset: number;
        playbackStatus: PlaybackStatus;
    }>

  • 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
    • Optional keyTree: 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;
        status: DialStatus;
    }>

  • Executes application with given options

    Parameters

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

    Returns Promise<number>

  • Stream the given file, and receive DTMF data.

    Parameters

    • soundFile: string
    • timeout: number = 5
    • Optional maxDigits: number

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

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

    Parameters

    • key: string
    • Optional channel: string

    Returns Promise<string>

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

    Parameters

    • key: string
    • Optional channel: string

    Returns Promise<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

    Returns Promise<string>

  • Cause the channel to execute the specified dialplan subroutine.

    Parameters

    • context: string
    • extension: string
    • priority: number
    • Optional argument: string

    Returns Promise<void>

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

    Parameters

    • Optional channel: 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) => void)
        • (error): void
        • Parameters

          • error: any

          Returns void

    Returns this

  • Event that is emitted when the underlying socket is closed

    Parameters

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

    Returns this

  • Event that emitted when the underlying socket times out

    Parameters

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

    Returns this

  • Event that is emitted when the channel is ready

    Parameters

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

    Returns this

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

    Parameters

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

          • response: string

          Returns void

    Returns this

  • Event that emitted when the channel is hung up

    Parameters

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

    Returns this

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

    Parameters

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

          Returns void

    Returns this

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

    Parameters

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

          • data: string

          Returns void

    Returns this

  • 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
    • Optional beep: boolean
    • Optional silence: number
    • Optional offsetSamples: number

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

  • Allows you to remove headers which were previously added with PJSIPAddHeader(). If no parameter is supplied, all previously added headers will be removed. If a parameter is supplied, only the matching headers will be removed

    Parameters

    • Optional key: string
    • wildcard: boolean = false

    Returns Promise<void>

  • 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 = '#'
    • Optional dateFormat: string
    • Optional timezone: 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
    • Optional callerName: 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
    • Optional musicClass: 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<IResponse>

  • Parameters

    • engine: string

    Returns Promise<IResponse>

  • Parameters

    • grammar: string

    Returns Promise<IResponse>

  • Parameters

    • grammar: string
    • path: string

    Returns Promise<IResponse>

  • Parameters

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

    Returns Promise<IResponse>

  • Parameters

    • key: string
    • value: string

    Returns Promise<IResponse>

  • Parameters

    • grammar: string

    Returns Promise<IResponse>

  • Sends audio file on channel.

    Parameters

    • filename: string
    • escapeDigits: string = '#'
    • Optional offset: 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
    • Optional level: number

    Returns Promise<void>

  • Waits for a digit to be pressed.

    Parameters

    • timeout: number = 5

    Returns Promise<string>