gbonnet wrote:use the From Header, as you did before but this time, all the info is within the 'provider' registration. That makes the dial plan a lot clearer
I suppose we need to update the threads explaining how to set up the callerID
Asterisk compatible patterns must begin with an underscore _
-X matches any digit from 0-9
-Z matches any digit from 1-9
-N matches any digit from 2-9
-[ ] matches any digits in the brackets.
eg
[25] will match 2 or 5, but will not match 0,1,3,4 etc.
[2-5] will match 2, 3, 4, 5, but will not match 0,1,6,7 etc.
[02-5] will match 0,2,3,4,5 but will not match 1,6,7 etc.
- . wildcard (full stop), matches one or more characters
Here are some examples
_9XXXXXXX matches 98175555 etc
_9817XXXX matches 98175555 but not 92595555 etc
_13ZXX. matches 131241 but not 1300 123 456 (because the Z excludes 0 as an option)
Regular Expressions
-collecting info on this feature
${EXTEN:2} or ${dst:2} means the first 2 characters will be removed from any number you dialed before being sent to the provider for calling.
1${EXTEN} or 1${dst} means a 1 will be added to any number you dial before being sent to the provider for calling
1${EXTEN:2} means the first two characters of whatever you dial will be removed and a 1 will be added in front of what'sleft before sending the number to the provider for calling.
#Ruby
sys.log("***Starting New Call Event***")
#****This Part collects call information for the log****
if sys.In then
sys.log("***Incoming Call Starting***")
sys.log("Incoming Call From #{req.Header.From.FromName} at #{req.Header.From.FromURI.User}@#{req.Header.From.FromURI.Host}")
sys.log("Call is for #{req.URI.User}")
cid = req.Header.From.FromURI.User
trunk = req.URI.User
sys.log("*** CID: #{cid} | Trunk: #{trunk} ***")
#****Route Calls based on Caller ID + Trunk****
if sys.RegexMatch(trunk, "provider3.mssuser") and sys.RegexMatch(cid, "4169391212") then
sys.log("Routing CallBack for 4169391212")
sys.Callback("14169391212@Provider1" , "*774914166239612@SipBroker" , 15)
else
if sys.RegexMatch(trunk, "provider3.mssuser") and sys.RegexMatch(cid, "6478959191") then
sys.log("Routing CallBack for 6478959191")
sys.Callback("16478959191@Provider1" , "*774914166239612@SipBroker" , 15)
else
#****Route Calls based on Caller ID Only****
case cid
when /^4168882222/ then
sys.log("Rejecting call from #{req.Header.From.FromURI.User}")
sys.Respond(488, "Your call is not welcome")
when /^8883334545/ then
sys.Log("Rejecting call from #{req.Header.From.FromURI.User}")
sys.Respond(488, "Your call is not welcome")
when /^4162223333/ then
sys.Log("Forwarding call from #{req.Header.From.FromURI.User} to Mobile")
sys.Dial("14169392323@Provider1")
else
#****Route calls based on Trunk Only****
case trunk
when /provider3.mssuser/ then
sys.Log("Initiating Call Forward-1")
sys.dial("**466@PhoneGnome")
when /provider5.mssuser/ then
sys.Log("Initiating Call Forward-2")
sys.dial("14169392424@Provider1")
else
#****Have Calls Ring ATA or Forward if Offline****
sys.Log("Accepting Call")
if sys.IsAvailable() then
sys.Log("The ATA is online.")
sys.Dial("local")
else
sys.Log("The ATA is off-line.")
sys.Dial("165528@us.voxalot.com")
end
#****End Statements****
end #cid+trunk rule 1
end #cid+trunk rule 2
end #case trunk
end #case cid
else
sys.log("***Outgoing Call Starting***")
number_called = req.URI.User
#****Block Calls to certain numbers****
case number_called
when /^1900/
sys.Log("Call to #{req.URI.User} not allowed")
sys.Respond(488, "Call not allowed")
when /^900/
sys.Log("Call to #{req.URI.User} not allowed")
sys.Respond(488, "Call not allowed")
else
#****Adjust for 7 digit and 10 digit Dialing****
number_length = req.URI.User.Length.to_s
sys.log("Number is #{number_length} digits long")
case number_length
when /^7/
sys.Log("Local Call to 416#{req.URI.User}")
sys.Dial("1416${dst}@Provider1")
when /^10/
sys.Log("National Call to 1#{req.URI.User}")
sys.Dial("1${dst}@Provider1")
else
#****Outgoing Dial Plans****
case number_called
when /^\*1/
sys.Log("Dialing #{req.URI.User} via Provider1.")
sys.Dial("${dst:2}@Provider1")
when /^\*2/ then
sys.Log("Dialing #{req.URI.User} via VoXPG.")
sys.Dial("${dst:2}@Provider2")
when /^\*500/ then
sys.Log("Dialing VoXalot VoiceMail.")
sys.Dial("*010*500@sipbroker.com")
when /^1/ then
sys.Log("Dialing North American Number #{req.URI.User}.")
sys.Dial("Provider1")
when /^011/ then
sys.Log("Dialing International Number #{req.URI.User}.")
sys.Dial("Provider2")
else
#****If there is no other match****
sys.Log("No Dial Plan Match: Trying Default Rule")
sys.Dial("VoXalot")
#****End Statements****
end # case for outgoing dialplans
end # case for number length
end # case for blocked numbers
end
when /^\*1/ then sys.Dial("${dst:2}@provider")
or
when /^\*1.*$/ then sys.Dial("${dst:2}@provider")
or
when /\*1.*/ then sys.Dial("${dst:2}@provider")
if req.URI.User.StartsWith("*1") then
sys.Dial("${dst:2}@provider")
end
when /^11/ then sys.Dial("${dst:2}@provider")
or
when /^11.*$/ then sys.Dial("${dst:2}@provider")
or
when /11.*/ then sys.Dial("${dst:2}@provider")
if req.URI.User.StartsWith("11") then
sys.Dial("${dst:2}@provider")
end
when /^12$/ then sys.Dial("12@provider")
Users browsing this forum: jgionet76 and 2 guests