creating a simple call forward table dial plan

Catalog of dial plans
Post Reply
vivek_watwani
Posts: 2
Joined: Tue Sep 14, 2010 12:20 am

creating a simple call forward table dial plan

Post by vivek_watwani » Tue Sep 14, 2010 12:32 am

Hi Guys,

I am new to ruby language also new to sip sorcery. i am trying to create a simple dial plan where if i get a call from sip account x it should forward my call to x1, if a call from sip account y it should forward my call to y1.. and so on. I have already registered two incoming sip accounts and one sip provider for outgoing calls. Here's my dial plan I am working on. I want to know how to recognize from which sip account am I getting the call.

# SIP tracing : true or false
sys.Trace = false

sys.Log("call from #{req.Header.From.FromURI.ToString()} to #{req.URI.User}.")

if sys.In then
# Do your INCOMING call processing customisations here.

#expression to read incoming sip account name.
incomingSipAccountName = ???????????

if (incomingSipAccountName == "SipAccountX") then num = '00xxxxxxxxxx' end
if (incomingSipAccountName == "SipAccountY") then num = '00yyyyyyyyyyy' end

sys.Dial("#{num}@OutgoingSipProviderZ",30)

#sys.Respond(480, "#{sys.Username} Not available")

else
# Do your OUTGOING call processing customisations here.
sys.Dial("OutgoingSipAccountZ")

end

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: creating a simple call forward table dial plan

Post by Aaron » Tue Sep 14, 2010 12:56 am

There are a few different ways you could do it but probably the easiest way is to look at the domain on the From header using req.Header.From.FromURI.Host it should hold the domain name of your SIP provider. Of course this is no good if you have multiple numbers on the same provider and in that case an alternative mechanism would need to be used.

Code: Select all

incomingSipAccountName = req.Header.From.FromURI.Host

if (incomingSipAccountName == "provider1.com") then num = '00xxxxxxxxxx' end
if (incomingSipAccountName == "provider2.com") then num = '00yyyyyyyyyyy' end

vivek_watwani
Posts: 2
Joined: Tue Sep 14, 2010 12:20 am

Re: creating a simple call forward table dial plan

Post by vivek_watwani » Tue Sep 14, 2010 8:58 pm

I have multiple accounts with the same sip provider. Is there any other way?

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: creating a simple call forward table dial plan

Post by Aaron » Tue Sep 14, 2010 10:38 pm

Again there are a few options but two of the easier ones are:

1. When you register with each provider use a registration contact of line1.yourusername@sipsorcery.com, line2.yourusername@sipsorcery.com where "yourusername" is your sipsorcery username,

2. Create a new SIP account for each provider and use different SIP account names in your provider registration contacts.

Then in your dialplan instead of using the From header you can use the request URI:

Code: Select all

incomingSipAccountName = req.URI.User

if (incomingSipAccountName == "provider1.com") then num = '00xxxxxxxxxx' end
if (incomingSipAccountName == "provider2.com") then num = '00yyyyyyyyyyy' end

Post Reply