Lua Services
Introduction
A Lua service is the inbound point which triggers the execution of a Lua script within the LogicApp application, in response to a new inbound transaction initiated by some external entity.
The Lua Service is responsible for the setup and tear-down of a LogicApp script instance:
- Choosing which Lua script to execute.
- Supplying arguments to the Lua script when it begins.
- Handling the final result returned by the Lua script.
- Optionally providing additional service-related actions to the script.
Since the service implements all of the underlying infrastructure, the Lua script needs only to perform the business logic:
- Process the arguments which are provided to it.
- Return some final result.
- Call supplementary Lua Service actions (if required).
- Call other Lua Agent functions (if required).
This Technical Guide describes the core Lua Services provided as part of the base n2svcd
package. Other protocol-specific Services are delivered by other packages, e.g. Services
related to SIP functionality are delivered by the n2sip
package.
Supplementary Service Actions
Every service library must provide the base input/output features.
The service may also offer actions that the script can use to interact with the external entity during Lua script execution (rather than waiting until the end of the Lua script processing).
For example:
- A Lua script initiated by a received REST request may use a service action to reply with an early REST response.
- A Lua script initiated by a MAP ProcessedUSSDRequest may perform USSD Menu interactions to the handset.
- A Lua script initiated by an inbound SIP call may perform RTP Audio interactions with the caller.
Agent Actions
In addition to the actions provided by a services, the Lua script may freely call upon Lua Agents to perform its work.
Any actions supplied by agents are independent from the actions provided by the script’s Service.