View Source Fastagi.Session (Fastagi v0.1.0)

Link to this section Summary

Functions

Initiate FastAGI session on new connection. Parse AGI input and setup connection socket.

Answers channel if not already in answer state.

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

Cause the channel to automatically hangup at time seconds in the future. Of course it can be hungup before then as well. Setting to 0 will cause the autohangup feature to be disabled on this channel

Returns status of the connected channel. If no channel name is given (empty line) then returns the status of the current channel

Close session connection

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

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

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

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

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

Get AGI environment variable by key

Executes application with given options

Stream the given file, and receive DTMF data. Returns the digits received from the channel at the other end

Evaluates the given expression against the channel specified by channelname, or the current channel if channelname is not provided

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

Gets a channel variable

Cause the channel to execute the specified dialplan subroutine

Hangup a channel

Initiate from new AGI session

Receives one character from channels supporting it

Receives text from channels supporting it

Record to a file until a given dtmf digit in the sequence is received

Says a given character string

Says a given date. date - Is number of seconds elapsed since 00:00:00 on January 1, 1970. Coordinated Universal Time (UTC).

Says a given time as specified by the format given

Say a given digit string, returning early if any of the given DTMF digits are received on the channel

Say a given number, returning early if any of the given DTMF digits are received on the channel

Say a given character string with phonetics, returning early if any of the given DTMF digits are received on the channel

Say a given time, returning early if any of the given DTMF digits are received on the channel

Sends the given image on a channel. Most channels do not support the transmission of images

Sends the given text on a channel. Most channels do not support the transmission of text

Changes the callerid of the current channel

Sets the context for continuation upon exiting the application

Changes the extension for continuation upon exiting the application

Enables/Disables the music on hold generator. If class is not specified, then the default music on hold class will be used

Changes the priority for continuation upon exiting the application. The priority must be a valid priority or label

Sets a variable to the current channel

Send the given file, allowing playback to be interrupted by the given digits, if any

Enable/Disable TDD transmission/reception on a channel

Sends message to the console via verbose message system. level is the verbose level (1-4)

Waits up to timeout milliseconds for channel to receive a DTMF digit

Link to this section Types

@type response() :: {:ok, Fastagi.Response.t()} | {:error, term()} | :hangup
@type t() :: %Fastagi.Session{conn: term(), envs: Map.t()}

Link to this section Functions

Link to this function

%Fastagi.Session{}

View Source (struct)

Initiate FastAGI session on new connection. Parse AGI input and setup connection socket.

Run commands in current session.

@spec answer(sess :: t()) :: response()

Answers channel if not already in answer state.

@spec asyncagi_break(sess :: t()) :: response()

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

@spec autohangup(sess :: t(), time :: integer()) :: response()

Cause the channel to automatically hangup at time seconds in the future. Of course it can be hungup before then as well. Setting to 0 will cause the autohangup feature to be disabled on this channel

Link to this function

channel_status(sess, chan)

View Source
@spec channel_status(sess :: t(), chan :: String.t()) :: response()

Returns status of the connected channel. If no channel name is given (empty line) then returns the status of the current channel

@spec close(sess :: t()) :: :ok

Close session connection

Link to this function

control_stream_file(sess, filename, escape_digits, skip_ms, ff_chr, rew_chr, pause_chr, offset_ms)

View Source
@spec control_stream_file(
  sess :: t(),
  filename :: String.t(),
  escape_digits :: String.t(),
  skip_ms :: integer(),
  ff_chr :: String.t(),
  rew_chr :: String.t(),
  pause_chr :: String.t(),
  offset_ms :: integer()
) :: response()

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

Link to this function

database_del(sess, family, key)

View Source
@spec database_del(sess :: t(), family :: String.t(), key :: String.t()) :: response()

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

Link to this function

database_deltree(sess, family, key)

View Source
@spec database_deltree(sess :: t(), family :: String.t(), keytree :: String.t()) ::
  response()

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

Link to this function

database_get(sess, family, key)

View Source
@spec database_get(sess :: t(), family :: String.t(), key :: String.t()) :: response()

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

Link to this function

database_put(sess, family, key, value)

View Source
@spec database_put(
  sess :: t(),
  family :: String.t(),
  key :: String.t(),
  value :: String.t()
) ::
  response()

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

@spec env(sess :: t(), name :: String.t()) :: {:ok, String.t()} | :error

Get AGI environment variable by key

Link to this function

exec(sess, application, options)

View Source
@spec exec(sess :: t(), application :: String.t(), options :: String.t()) ::
  response()

Executes application with given options

Link to this function

get_data(sess, file, timeout, maxdigits)

View Source
@spec get_data(
  sess :: t(),
  file :: String.t(),
  timeout :: integer(),
  maxdigits :: integer()
) ::
  response()

Stream the given file, and receive DTMF data. Returns the digits received from the channel at the other end

Link to this function

get_full_variable(sess, name, chan_name)

View Source
@spec get_full_variable(sess :: t(), name :: String.t(), chan_name :: String.t()) ::
  response()

Evaluates the given expression against the channel specified by channelname, or the current channel if channelname is not provided

Link to this function

get_option(sess, filename, escape_digits, timeout)

View Source
@spec get_option(
  sess :: t(),
  filename :: String.t(),
  escape_digits :: String.t(),
  timeout :: integer()
) :: response()

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

Link to this function

get_variable(sess, name)

View Source
@spec get_variable(sess :: t(), name :: String.t()) :: response()

Gets a channel variable

Link to this function

gosub(sess, context, exten, priority, args)

View Source
@spec gosub(
  sess :: t(),
  context :: String.t(),
  exten :: String.t(),
  priority :: String.t(),
  args :: String.t()
) :: response()

Cause the channel to execute the specified dialplan subroutine

@spec hangup(sess :: t()) :: response()

Hangup a channel

@spec hangup(sess :: t(), chan :: String.t()) :: response()
@spec init(data :: String.t()) :: {:ok, t()} | {:error, term()}

Initiate from new AGI session

Link to this function

receive_char(sess, timeout \\ 0)

View Source
@spec receive_char(sess :: t(), timeout :: integer()) :: response()

Receives one character from channels supporting it

Link to this function

receive_text(sess, timeout \\ 0)

View Source
@spec receive_text(sess :: t(), timeout :: integer()) :: response()

Receives text from channels supporting it

Link to this function

record_file(sess, fname, fmt, escdig, timeout, offset, beep, silence)

View Source
@spec record_file(
  sess :: t(),
  filename :: String.t(),
  format :: String.t(),
  escape_digits :: String.t(),
  timeout :: integer(),
  offset :: integer(),
  beep :: boolean(),
  silence :: integer()
) :: response()

Record to a file until a given dtmf digit in the sequence is received

Link to this function

say_alpha(sess, number, escape_digits)

View Source
@spec say_alpha(sess :: t(), number :: String.t(), escape_digits :: String.t()) ::
  response()

Says a given character string

Link to this function

say_date(sess, date, escape_digits)

View Source
@spec say_date(sess :: t(), date :: integer(), escape_digits :: String.t()) ::
  response()

Says a given date. date - Is number of seconds elapsed since 00:00:00 on January 1, 1970. Coordinated Universal Time (UTC).

Link to this function

say_datetime(sess, time, escape_digits, format, timezone)

View Source
@spec say_datetime(
  sess :: t(),
  time :: integer(),
  escape_digits :: String.t(),
  format :: String.t(),
  timezone :: String.t()
) :: response()

Says a given time as specified by the format given

Link to this function

say_digits(sess, number, escape_digits)

View Source
@spec say_digits(sess :: t(), number :: String.t(), escape_digits :: String.t()) ::
  response()

Say a given digit string, returning early if any of the given DTMF digits are received on the channel

Link to this function

say_number(sess, number, escape_digits, gender)

View Source
@spec say_number(
  sess :: t(),
  number :: String.t(),
  escape_digits :: String.t(),
  gender :: String.t()
) :: response()

Say a given number, returning early if any of the given DTMF digits are received on the channel

Link to this function

say_phonetic(sess, string, escape_digits)

View Source
@spec say_phonetic(sess :: t(), string :: String.t(), escape_digits :: String.t()) ::
  response()

Say a given character string with phonetics, returning early if any of the given DTMF digits are received on the channel

Link to this function

say_time(sess, time, escape_digits)

View Source
@spec say_time(sess :: t(), time :: integer(), escape_digits :: String.t()) ::
  response()

Say a given time, returning early if any of the given DTMF digits are received on the channel

@spec send_image(sess :: t(), image :: String.t()) :: response()

Sends the given image on a channel. Most channels do not support the transmission of images

@spec send_text(sess :: t(), text :: String.t()) :: response()

Sends the given text on a channel. Most channels do not support the transmission of text

Link to this function

set_callerid(sess, number)

View Source
@spec set_callerid(sess :: t(), number :: String.t()) :: response()

Changes the callerid of the current channel

Link to this function

set_context(sess, context)

View Source
@spec set_context(sess :: t(), context :: String.t()) :: response()

Sets the context for continuation upon exiting the application

Link to this function

set_extension(sess, exten)

View Source
@spec set_extension(sess :: t(), exten :: String.t()) :: response()

Changes the extension for continuation upon exiting the application

Link to this function

set_music(sess, enable, class \\ "default")

View Source
@spec set_music(sess :: t(), enable :: boolean(), class :: String.t()) :: response()

Enables/Disables the music on hold generator. If class is not specified, then the default music on hold class will be used

Link to this function

set_priority(sess, priority)

View Source
@spec set_priority(sess :: t(), priority :: String.t()) :: response()

Changes the priority for continuation upon exiting the application. The priority must be a valid priority or label

Link to this function

set_variable(sess, name, value)

View Source
@spec set_variable(sess :: t(), name :: String.t(), value :: String.t()) :: response()

Sets a variable to the current channel

Link to this function

stream_file(sess, file, escape_digits, offset)

View Source
@spec stream_file(
  sess :: t(),
  file :: String.t(),
  escape_digits :: String.t(),
  offset :: integer()
) :: response()

Send the given file, allowing playback to be interrupted by the given digits, if any

@spec tdd_mode(sess :: t(), enable :: boolean()) :: response()

Enable/Disable TDD transmission/reception on a channel

Link to this function

verbose(sess, msg, level \\ 1)

View Source
@spec verbose(sess :: t(), msg :: String.t(), level :: integer()) :: response()

Sends message to the console via verbose message system. level is the verbose level (1-4)

Link to this function

wait_for_digit(sess, timeout)

View Source
@spec wait_for_digit(sess :: t(), timeout :: integer()) :: response()

Waits up to timeout milliseconds for channel to receive a DTMF digit