|
|
本帖最后由 Test 于 2011-11-17 09:39 编辑
Introduction
SIP Sorcery dial plans are what control how calls are processed. A dial plan is required for outgoing calls to be processed, without it the SIP Sorcery server would not know how you wanted your calls to be forwarded. A dial plan is optional for incoming calls. If a SIP account does not have an incoming dial plan specified then the default behaviour is to forward the call to all registered bindings for that account.
The SIP Sorcery dial plans are written as Ruby scripts. The SIP Sorcery application server exposes a wide range of functions that can be called in dial plan scripts to place calls, send emails, send instant messages, retrive and set values from a database and many more.
sys.Dial
Usage:
DialPlanAppResult sys.Dial(string dialString)
DialPlanAppResult sys.Dial(string dialString, int ringTimeout)
DialPlanAppResult sys.Dial(string dialString, int ringTimeout, int answeredCallLimit)
Description:
The most important dial plan function. Initiates a call to one or more SIP end points and when the first call is answered will bridge it with the SIP user agent that initiated the application. The Dial command takes a dial string as a parameter and it controls the order, delay and other types of behaviours for the forwarded call requests. The syntax of the dial string is best demonstrated by an example:
- # sys.Dial example.
- sys.Dial("123@provider1&456@provider2[dt=5]|789@provider3")
复制代码
- A call will be placed to 123@provider1,
- After a 5 second delay a call will be placed to 456@provider2,
- If both calls fail a call will be placed to 789@provider3.
If at any point one of the forwards answered all other forwards are cancelled and the dialplan execution terminates. The additional options that can be used on each call leg are:
- # sys.Dial example.
- sys.Dial("123@provider1[rm=a,cd=3600]&456@provider2[dt=5,rm=a,cd=600]")
复制代码
- dt: Delay call start in seconds,
- cd: Answered call duration in seconds,
- rm: Redirect mode, n=Process redirects in a new instance of the same dial plan.
- ma: Whether to mangle the SDP, true or false (default is true so use this to specify no mangling on a call leg).
- fd: Sets a custom From header display name for this call leg,
- fu: Sets a custom From header URI username for this call leg,
- fh: Sets a custom From header URI host for this call leg,
- tr: Determines whether transfers (REFER requests) will be accepted: n=Not permitted, p=Pass thru (default), c=Place call (be careful!)
sys.Log
Usage:
sys.Log(string logMessage)
Description:
Logs a message that will be displayed on the console and email traces. This is an essential function to provide troubleshooting or general information about the state of a dial plan as it processes a call.
?
1
2
| # sys.Log example.
sys.Log("Log message from the SIP Sorcery dial plan.")</div>
|
sys.GoogleVoiceCall Usage:
sys.GoogleVoiceCall(string emailAddress, string password, string forwardingNumber, string destinationNumber, string fromUserToMatch, int phoneType, int callbackTimeout)
Description:
A popular dial plan function that can be used to initiate calls using Google's Google Voice service. The application works by sending a HTTP request to Google Voice that in turn initiates a callback. The incoming call leg must reach the same SIP Sorcery account that the Google Voice call is being placed for. Once the incoming callback is received it will be matched to the SIP call leg that initiated it.
?
1
2
| # sys.GoogleVoice example.
sys.GoogleVoice("user@gmail.com", "password", "12345670000", "76543210000", ".*", 1, 30)
|
- The emailAddress and password are the credentials used to login to the Google Voice portal.
- The forwardingNumber is the number to request the Google Voice callback on. Whatever this number is it needs to get the call to SIPSorcery.
- The destinationNumber is the number that will be passed to the callback as the outgoing leg and is the external number that will be called.
- The fromUserToMatch is used to match the incoming callback to the SIP call that initiated the dial plan execution. By specifying this field sipsorcery will look at the From URI user, in a SIP From header of From: "Joe Bloggs" <sip:12345678@somehost.com> the From URI user is 12345678, to match the calls.
- The phone type used by GoogleVoice. If not specified defaults to (Mobile=2):
- 1 - Home
- 2 - Mobile
- 3 - Work
- The callback timeout in seconds which is the amount of time the sipsorcery dialplan will wait for the GoogleVoice callback before giving up and continuing with the next dialplan command. The timeout must be between 5 and 60s and if not specified a default value of 30s is used.
|
|