Interaction (RTP)
Introduction
A SIP call-control Lua script using LhoSipIncallLuaService or LhoSipOutcallLuaAgent may request that the A-Leg be connected to a locally generated RTP stream for the purpose of playing announcements with optional digit collection.
This requires that an RtpApp instance is running locally, and that RtpApp is configured
as a known resource for the LhoSipApp which is controlling the call. The controlling LhoSipApp will
perform the relevant A-Leg SIP messaging necessary to connect to the RTP stream, using one of:
- SIP INVITE Final Response with code
200 OK - SIP INVITE Provisional Response with code
183 Session Progress - SIP re-INVITE Request
Here is the overall flow for an interaction using the SIP INVITE Final Response mechanism to connect to a locally generated RTP stream:

Service logic processing will suspend until:
- The A-Party abandons the call, or
- The announcement for an interaction that does not require digit collection completes playing, or
- The A-Party meets the digit collection requirements (potentially including end character), or
- An internal interaction timer (guard, first digit, inter-digit) reaches the maximum allowed duration, or
- An internal processing error occurs.
The LhoSipIncallLuaService Interaction API (Internal/RTP)
.rtp_interaction [Asynchronous]
This method provides full access to the Interaction mechanism for the Internal RTP resource.
This method takes the following arguments:
| Argument | Type | Description |
|---|---|---|
announcement
|
Table |
A table specifying the parameters for the interaction which is to be performed. (Default = open the RTP connection but do not perform any interaction). |
.message_id
|
Integer |
A single message ID to play. This ID must be configured within the RtpApp database or file-based configuration.The definition of this ID may depend on the specified language, and may include a mixture of audio files and variable parts. Specify exactly one of .message_id or .message_ids or .files.
|
.message_ids
|
Table of Integer |
A table of one or more message IDs to play in sequence. Each ID listed here must be configured within the RtpApp database or file-based configuration.The definition of each ID may depend on the specified language, and may include a mixture of audio files and variable parts. Each ID listed here may contain variable parts. The supplied variable parts list must contain sufficient variable parts for all message IDs. Specify exactly one of .message_id or .message_ids or .files.
|
.files
|
Table of String |
A table of one or more filenames to play in sequence. Specifying this parameter will bypass the message ID translation process in RtpApp
and allows the service logic to explicitly control the audio file fragments to be played.All filenames must be associated with the announcement language. It is not possible to override the language per-file. Filenames must not include the audio file type suffix part e.g. must not contain the .ul, or .amr.Each filename must include the subdirectory announcements or variable_parts.The directory name "a" is a supported abbreviation for "announcements". The directory names "vp" and "v" are supported abbreviations for "variable_parts". Example: { 'a/You_Entered', 'v/1', 'vp/4' }.Specify exactly one of .message_id or .message_ids or .files.
|
.language
|
String |
The name of a language to use instead of the language specified by the most recent invocation of
.set_language or the default language configured on the RtpApp.The RtpApp will use this when translating message ID/IDs and variable parts into a file list.This language name must be configured within the RtpApp database or file-based configuration.Refer to the RtpApp configuration documentation. (Default = use the language specified by the most recent invocation of .set_language or the default configured on the RtpApp).
|
.repetition
|
Positive Integer |
The number of times to play the announcement. (Default = 1, play the announcement only once).
|
.duration
|
Positive Integer |
The total permitted duration of the interaction including repetitions and any silence. (Default = use the default_pa_wait_secs or default_pacui_wait_secs configured on the LhoSipOutcallLuaAgent or LhoSipIncallLuaService).
|
.variables
|
Table of Tables |
A table containing the values to substitute into pre-defined placeholders in the message structure. Each entry in the table is a table which specifies exactly one of the attributes as follows. (Default = no variables). |
.integer
|
Integer |
An integer value to speak as a variable part. Construction rules for the chosen/default langage will be used. |
.number_digits
|
(+)Hex String |
A hexadecimal numeric string to speak as a variable part. Each digit will be spoken individually. Construction rules for the chosen/default langage will be used. |
.time_hhmm
|
<HHMM> |
An integer hour and minute to speak as a variable part. Value must be in the range 0000 to 2400.Construction rules for the chosen/default langage will be used. |
.date_yymmdd
|
<YYMMDD> |
A 6-digit integer year/month/day to speak as a variable part. Construction rules for the chosen/default langage will be used. |
.date_yyyymmdd
|
<YYYYMMDD> |
An 8-digit integer year/month/day to speak as a variable part. Construction rules for the chosen/default langage will be used. |
.price_digits
|
Integer |
An integer value of "cents" to speak as a variable part. Construction rules for the chosen/default langage will be used. |
.collect
|
Table |
A container for parameters related to digit collection. Digit collection will be performed if and only if this parameter is present. (Default = do not collect digits). |
.min_num_digits
|
1 - 32
|
[Required] The minimum number of digits to collect. This value must be less than or equal to max_num_digits.
|
.max_num_digits
|
1 - 32
|
[Required] The maximum number of digits to collect. This value must be greater than or equal to min_num_digits.
|
.end_digit
|
#*A-D0-9
|
A digit which the caller can use to indicate End of Input. (Default = use the internal_end_digit configured on the LhoSipApp).
|
.cancel_digit
|
#*A-D0-9
|
A digit which the caller can use to clear all previous input. (Default = use the internal_cancel_digit configured on the LhoSipApp).
|
.first_digit_timeout
|
Positive Integer |
The number of seconds allowed for the caller to enter the first digit after the announcement completes playing. (Default = use the default_first_digit_timeout configured on the RtpApp).
|
.inter_digit_timeout
|
Positive Integer |
The number of seconds allowed for the caller to enter a subsequent digit after entering at least one digit. (Default = use the default_inter_digit_timeout configured on the RtpApp).
|
.interruptable
|
Boolean |
When true, the first digit entered by the caller will interrupt the playing of the announcement.When false, the announcement will play in full, even if digit collection is completed before the end of the announcement.(Default = use the default_interruptable configured on the RtpApp).
|
.private_digits
|
Boolean |
When true, the collected digits are considered private, and will not be logged to LhoSipApp EDRs.(Default = use the default_private_digits configured on the LhoSipApp).
|
aleg_headers
|
Table |
Additional user headers to include in the SIP INVITE Response or SIP re-INVITE Request sent to the A-Leg when the Internal RTP resource is connected. The table keys are header names. The table values are tables of header values. (Default = do not add extra user headers). |
The rtp_interaction method returns a Lua table with the following attributes.
| Attribute | Type | Description |
|---|---|---|
.controlled
|
Boolean |
[Required] Is this call still controlled right now? This value being true indicates that (at least some) telephony API actions can be performed by service logic.Note that in some cases the available control actions may be limited. |
.proceed_ok
|
Boolean |
[Required] Can the service logic still use the .proceeding method?This value will be true when .controlled is true,
we have not yet sent a Final Response, and an SDP Offer would not be required to proceed.
|
.decline_ok
|
Boolean |
[Required] Can the service logic still use the .decline method?This value will be true when .controlled is true and
we have not yet sent a Final Response.
|
.reason
|
Abandoned
|
The reason for loss of call control during interaction. This value is present only when .controlled is false.(Default = not present, .controlled is true).
|
.error
|
String |
A description of the first error that occurred in connection with the interaction. This value is present only when .controlled is true and an error occurred.One of .digits or .error will be present when .controlled is
true and .collect was specified.If this value is defined, the service logic should assume that the intended audio was not played in full to the caller, and/or that digit collection was not completed successfully. This value may be defined when e.g. the RTP application is at capacity or could not be reached, some audio files were missing, some interaction parameters were invalid, etc. (Default = not present, .controlled is false or an error did not occur).
|
.digits
|
#*A-D0-9
|
Digits collected from the caller. This value is present only when .controlled is true, .error is not present, and .collect was specified.One of .digits or .error will be present when .controlled is
true and .collect was specified.This value will be present but empty if insufficient digits were collected from the caller. (Default = not present, .controlled is false or .collect was not specified or an error occurred).
|
Example (simple announcement):
local n2svcd = require "n2.n2svcd"
local incall_api = require "n2.n2svcd.sip_incall_service"
local scc = ...
local WELCOME_ID = 4022
incall_api.rtp_interaction ({ message_id = WELCOME_ID })
return
Example (one integer variable part):
local n2svcd = require "n2.n2svcd"
local incall_api = require "n2.n2svcd.sip_incall_service"
local scc = ...
local NUM_DAYS_ID = 1020
incall_api.rtp_interaction ({ message_id = NUM_DAYS_ID, variables = { integer = 356 } })
return
Example (collect 4 digit PIN):
local n2svcd = require "n2.n2svcd"
local incall_api = require "n2.n2svcd.sip_incall_service"
local scc = ...
local ENTER_PIN_ID = 1044
incall_api.rtp_interaction ({ message_id = ENTER_PIN_ID, collect = { min_num_digits = 4, max_num_digits = 4, private_digits = true }})
return
Example (play specific files with limited duration):
local n2svcd = require "n2.n2svcd"
local incall_api = require "n2.n2svcd.sip_incall_service"
local scc = ...
incall_api.rtp_interaction ({ duration = 4, files = { 'a/Goodbye', 'announcements/Goodbye', 'v/1', 'a/Welcome_To_Demonstration', 'a/Welcome_To_Demonstration' } })
return
.set_language [Pure Lua]
The set_language method sets the default language for all subsequent interactions.
Note: this method affects interactions with both the Internal RTP resource and External INAP-controlled SRFs.
This method takes a single argument:
| Argument | Type | Description |
|---|---|---|
language
|
String |
The new default language for all subsequent interactions. Specify nil to use the default language configured on the RtpApp.
(Default = nil, use the default language configured on the RtpApp).
|
The set_language method returns true.
.set_early_media [Pure Lua]
The set_early_media method sets the Early Media preference for all subsequent SIP incall Internal RTP resource interactions.
Note: Early Media does not apply to interactions associated with SIP outcalls or External INAP-controlled SRFs.
This method takes a single argument:
| Argument | Type | Description |
|---|---|---|
early_media
|
String |
The new default Early Media preference for all subsequent Internal RTP resource interactions. This preference will always be honoured when establishing a new connection between the A-Leg and the Internal RTP resource. When the A-Leg is already connected to the internal RTP resource, a subsequent interaction will cause an Early Media connection to be "upgraded" to a 200 OK connection if the new preference is never.
Otherwise the existing connection will be used without change, regardless of the new preference.Possible values are:
nil, use the early_media_policy configured on the LhoSipApp).
|
The set_early_media method returns true.
The following relevant constants are defined on the sip_incall_service object:
sip_incall_service.EARLY_MEDIA_REQUIRE = "require"
sip_incall_service.EARLY_MEDIA_PREFER = "prefer"
sip_incall_service.EARLY_MEDIA_ALLOW = "allow"
sip_incall_service.EARLY_MEDIA_NEVER = "never"