Ruby Dial Plans

Support zone
User avatar
Aaron
Site Admin
Posts: 4560
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Sun Apr 13, 2008 7:24 am

Hi voipuser,

You can use the sys.Dial command to dail SIP URIs, for example:

Code: Select all

sys.Dial("123@sip.voxalot.com")
However I just noted we didn't handle the case where there is already a "sip:" included in the URI. So the following doesn't work:

Code: Select all

sys.Dial("sip:123@sip.voxalot.com")
It's an easy fix but I'm in the middle of another change so the sipswitch can't be easily updated at the moment. To get around this for ENUM lookups you can trim the "sip:" from the fron of the returned result so:

Code: Select all

enumURI = sys.ENUMLookup("+6112345678.e164.org").to_s[4...100]
sys.Log("enum result=" + enumURI)
sys.Dial(enumURI)
Regards,

Aaron

User avatar
Aaron
Site Admin
Posts: 4560
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Sun Apr 13, 2008 1:24 pm

The problem with dialing URI's begining with "sip:" has now been fixed so ENUM lookups can be done as:

Code: Select all

enumURI = sys.ENUMLookup("+6112345678.e164.org")
sys.Log("enum result=" + enumURI)
sys.Dial(enumURI)
Regards,

Aaron

andreasjonsson
Posts: 1
Joined: Tue Apr 15, 2008 12:44 pm

Calling several destinations at the same time?

Post by andreasjonsson » Tue Apr 15, 2008 1:07 pm

I would like to be able to do something like this:

Code: Select all

#Ruby dialplan
sys.Log("call received uri=#{req.URI.User}")
sys.Dial("voipstunt")    #for outgoing calls
sys.Dial("SSuser@local", "mymobileno@sip.voipstunt.com")   #for incoming calls
Is it possible to send an incoming call to several destinations at the same time with ruby? If so, how?


I know I can to do it like this, but that is not what I want:

Code: Select all

#Ruby dialplan
sys.Log("call received uri=#{req.URI.User}")
sys.Dial("voipstunt")    #for outgoing calls
sys.Dial("SSuser@local", 25)   #for incoming calls
sys.Dial("mymobileno@sip.voipstunt.com")   #for incoming calls

User avatar
Aaron
Site Admin
Posts: 4560
Joined: Thu Jul 12, 2007 12:13 am

Re: Calling several destinations at the same time?

Post by Aaron » Tue Apr 15, 2008 1:41 pm

andreasjonsson wrote:I would like to be able to do something like this:

Code: Select all

#Ruby dialplan
sys.Log("call received uri=#{req.URI.User}")
sys.Dial("voipstunt")    #for outgoing calls
sys.Dial("SSuser@local", "mymobileno@sip.voipstunt.com")   #for incoming calls
Is it possible to send an incoming call to several destinations at the same time with ruby? If so, how?
Hi andreasjonsson,

You can do it like this:

Code: Select all

#Ruby dialplan
sys.Log("call received uri=#{req.URI.User}")
sys.Dial("voipstunt")    #for outgoing calls
sys.Dial("SSuser@local&mymobileno@voipstunt")   #for incoming calls

Regards,

Aaron

gbonnet
Site Admin
Posts: 680
Joined: Wed Jul 11, 2007 2:58 pm
Location: Bologna
Contact:

Post by gbonnet » Wed May 21, 2008 6:46 pm

Hi all,

I've just release an article about inbound call management with My SIP Switch. It's only an introduction and that aims at giving some ideas to newcomers:

Inbound call management with Ruby Dial Plan

let me know if you notice mistakes or notice any important thing missing.

Cheers
Guillaume
Blueface [url=http://www.blueface.ie/]Phone[/url] Service

captainpp
Posts: 23
Joined: Tue Mar 04, 2008 10:04 am

Post by captainpp » Wed May 28, 2008 8:49 am

How can I test whether a call is busy, and do something appropriate. For example I have:

sys.Dial("local", 20)

Is there something like

if sys.Dial("local", 20).response == busy

that I can use?

User avatar
Aaron
Site Admin
Posts: 4560
Joined: Thu Jul 12, 2007 12:13 am

Post by Aaron » Thu May 29, 2008 9:42 am

Hi captainpp,

Yes you can do that sort of thing but it breaks down a bit when there are multiple call legs involved since if one call leg fails and one returns busy what should be returned? With single call les you can do:

Code: Select all

result = sys.Dial("1@fwd").ToString()
sys.Log("result=#{result}.")
The result will be one of:

Code: Select all

NoAnswer
Failed
ClientCancelled
ProxyCancelled
TimedOut
Error
In the case of a Busy response from your callee "Failed" would be returned.

Regards,

Aaron

Wortelstok
Posts: 13
Joined: Mon Jun 02, 2008 5:22 pm

Forward on outage

Post by Wortelstok » Mon Jun 02, 2008 5:35 pm

Hi there, I like to hobby a little bit with Ruby as a noob.
I am trying to construct a script to forward calls if my internet is down.
It should forward to two phone numbers simultaneously, the second one with a delay (although not stopping the first one as in the blog example).

I got so far:
sys.Log("call from #{req.Header.From.FromURI.ToString()} to #{req.URI.User}.")
if sys.In then
sys.Log(”isavailable=#{sys.IsAvailable().ToString()}.”)
if sys.IsAvailable()
# do nothing, provider is also logged in on the ATA
else
sys.Dial(”0031123456@Voipcheap&003162345678@Voipcheap”)
end
else (.. outbound)
I cannot get passed the "updating, please wait" screen.
Apparantly, the test sys.IsAvailable cannot be interpreted?

Also, I do not know how to build in the delay for the second number (my mobile) over the first number (my wife's number). Maybe I overlooked this.

gbonnet
Site Admin
Posts: 680
Joined: Wed Jul 11, 2007 2:58 pm
Location: Bologna
Contact:

Post by gbonnet » Mon Jun 02, 2008 9:17 pm

hi Wortelstok,

The monitoring screen is temporarily disabled since we are performing some maintenance operations on our databases. It will be re-enabled in the next few days. We'll post an update in the news section.

Regarding multiple forwards with delays here is an example that I took from the blog post:

Code: Select all

sys.Dial("#{sys.Username}@local", 10)
sys.Dial("00390xxxx@blueface", 12)
sys.Dial("00393xxxxx@blueface", 15)
sys.Respond(404, "No forwards answered")
15 seconds is the longest delay available

You can also take a look at our new wizard to create Ruby Dial Plan: http://www.mysipswitch.com/rubyzard.aspx

HTH
Guillaume

PS : I'm locking this topic since 4 pages starts to be too long ... Please create a new topic if needed. Thanks!
Blueface [url=http://www.blueface.ie/]Phone[/url] Service

Locked

Who is online

Users browsing this forum: Bing [Bot] and 1 guest