My Ruby dialplan

Catalog of dial plans
Post Reply
User avatar
TheFug
Posts: 914
Joined: Sat Oct 06, 2007 8:23 am
Location: The Netherlands, North-Holland

My Ruby dialplan

Post by TheFug » Tue Aug 12, 2008 8:43 pm

Well, i said "My"but the work was done by Aaron, and added some minor additions myself...

Code: Select all

#Ruby

#sys.Trace=true # Remove hash in front sys.Trace to get trace reports

sys.Log("call received on #{req.URI.ToString()} from #{req.Header.From.FromURI.ToString()} at #{Time.now}.")

if sys.Out then
 sys.Log("Outgoing call from user domain=#{sys.FromDomain}.")
   
 case req.URI.User
 
when /^(1800|1866|1877)/ then sys.Dial("*${dst}@SIPHAPPENS") # detects US toll free numbers
when /^00498/ then sys.Dial("275498${dst:5}@BRUJULA") # for testing german toll free number via SipBroker (peering)
when /^06/ then sys.Dial("00316${dst:2}@INTERVOIP") # dials all Dutch mobile numbers with Intervoip
when /^1777/ then sys.Dial("CALLCENTRIC") # detects and dials other Callcentric users 
when /^\*75/ then sys.Dial("*75${dst:3}@CALLCENTRIC") # detects and dials Callcentric preset numbers

# Following are prefixes to force the use of an certain provider
  when /^\*1/ then sys.Dial("${dst:2}@BRUJULA")
  when /^\*2/ then sys.Dial("${dst:2}@SIPGATE")
  when /^\*3/ then sys.Dial("${dst:2}@ORBTALK")
  when /^\*4/ then sys.Dial("${dst:2}@FWD")
  when /^\*5/ then sys.Dial("${dst:2}@IXCALL")
  when /^\*6/ then sys.Dial("${dst:2}@VOXALOT")
  when /^\*7/ then sys.Dial("${dst:2}@CALLCENTRIC")
  when /^\*8/ then sys.Dial("${dst:2}@SIPBROKER")
    
 end

else
 sys.Log("Incoming call to domain=#{sys.ToDomain} from host #{req.Header.From.FromURI.Host}.")
 if sys.IsAvailable() then
   sys.Log("#{sys.Username} is online.")

# will devert calls when my MSS account is offline, to my cellphone

   sys.Dial("#{sys.Username}@local&00316xxxxxxxx@INTERVOIP")
 else
   sys.Log("#{sys.Username} is not online.")
   sys.Respond(480, "#{sys.Username} Not online")
 end
end
Most of the outgoing part, of the dialplan i doo understand, also, the different syntax, when using numeric value, or when symbol character is used,
sys.Log will send text or values to monitor screen log,
req.header, will read out string values, from incoming call en will be used in the dialplan handling.

I guess sys.Dial("#{sys.Username}@local") and before that: if sys.in
will do also do the trick to receive incoming calls.
I only don't know, how much the callee will see of the sys.Log from my side...

Sometimes i use the sys.Trace=true function to trace the SIP communication, for all dial rules, i miss the "selective" use per dialrule out of the normal dialplan syntax, i guess something like a subroutine function, like you have in Basic, would be nice too in Ruby...

And an interactive function between IP-phone display and dialplan would be nice too.(if that's possible at all)

btw. the first Brujula dial rule was more of a test to peer/dial to a German free info railway phone number.
The first two Callcentric rules are for dialing an other user, and the second one, to dial Callcentric personal preset(s)
Any incoming internet call will also ring my mobile phone, at costs of InterVOIP
Last edited by TheFug on Sun Jun 21, 2009 3:24 pm, edited 3 times in total.
Thanks, The Fug.

gear: my ISP's Zyxel Modem/Router in bridge, Sitecom WL309 Router, Siemens Gigaset 301D

User avatar
TheFug
Posts: 914
Joined: Sat Oct 06, 2007 8:23 am
Location: The Netherlands, North-Holland

Post by TheFug » Wed Aug 13, 2008 7:43 am

I now understand, that the last part, for incoming calls, is also a nice start, or opening, to start a procedure, for when not online, or maybe there to make a plan to putt the call through to a mobile phone provider from there.
(still learning here)
Thanks, The Fug.

gear: my ISP's Zyxel Modem/Router in bridge, Sitecom WL309 Router, Siemens Gigaset 301D

Post Reply