Dial Plan Variables
Along with the methods that are exposed in the SIPSorcery Ruby dial plans there are also a number of variables
that can be accessed as properties of the sys object.
- Username: A string that contains the username of the dial plan owner. This is the same username that is used to login on the SIPSorcery
web portals.
- Out: A boolean that is set to True if the call originates from an authenticated SIPSorcery SIP account which indicates a SIPSorcery
user attempting to place a call.
- In: A boolean that is set to True if the call is not from an authenticated SIPSorcery SIP account which indicates a call that
has been received from an external SIP user agent.
- DialPlanName: A string that contains the name of the currently executing dial plan.
- Trace: A boolean that controls whether an email trace of the dial plan execution will be generated. Setting it to True
will cause an email trace to be generated provided there is an email address associated with the dial plan.
- LastDialled: A list of SIPTransaction objects that contain the result of the lasy sys.Dial command that was executed.
sys.Log("The currently executing dial plan name is #{sys.DialPlanName}.")
sys.Log("last failure status=#{sys.LastDialled[0].TransactionFinalResponse.Status}.")
As well as the sys object properties the SIP request object that initated the dial plan execution is stored in a special object called req.
Everything to do with the incoming SIP request is accessible through the req object. The main properties of a SIP request are the SIP URI, the SIP headers and the SIP body.
sys.Log("Call request received with SIP URI #{req.URI.ToString()}.")
sys.Log("The From header on the call request is #{req.Header.From.ToString()}.")
sys.Log("The body for the current call request is #{req.Body}.")
The code sample below demonstrates how to access the custom SIP headers from the INVITE request that initiated a dial plan.
Thanks to bobpaul for the sample.