My "One for All" Ruby plan ** Updated 08-Oct-08
Hi Aaron,
being illiterate in this field, I need your expert advice. Is there any situation where I'd need to use "User@sip.mysipswitch.com:port" instead of "User@sip.mysipswitch.com"? If yes, I will convert "User@local:port" into ""User@sip.mysipswitch.com:port", otherwise I'll just remove the "port" part from URI string.
As to calling local users when they are not online, could you please try to duplicate my experiment? Here it is, step-by-step:
1. telnet sip.mysipswitch.com 11005 and enter offline user's account credentials. Hit <Enter> on filter prompt.
2. Try calling that user from your account. You can use either my or Myatus' dialplan (or write a 1-line script of your own). Essential part is that you need to invoke sys.Dial(""User@sip.mysipswitch.com").
In my experiment, I didn't get anything on telnet screen.
3. Login that (offline user's) ATA. You'll get corresponding records via telnet.
4. Repeat #2 above and you'll see normal dialplan processing output.
That's how it worked in my case and that's why I suspected you taking a shortcut ("if this user isn't here, report it right away).
Sincerely,
Mike
being illiterate in this field, I need your expert advice. Is there any situation where I'd need to use "User@sip.mysipswitch.com:port" instead of "User@sip.mysipswitch.com"? If yes, I will convert "User@local:port" into ""User@sip.mysipswitch.com:port", otherwise I'll just remove the "port" part from URI string.
As to calling local users when they are not online, could you please try to duplicate my experiment? Here it is, step-by-step:
1. telnet sip.mysipswitch.com 11005 and enter offline user's account credentials. Hit <Enter> on filter prompt.
2. Try calling that user from your account. You can use either my or Myatus' dialplan (or write a 1-line script of your own). Essential part is that you need to invoke sys.Dial(""User@sip.mysipswitch.com").
In my experiment, I didn't get anything on telnet screen.
3. Login that (offline user's) ATA. You'll get corresponding records via telnet.
4. Repeat #2 above and you'll see normal dialplan processing output.
That's how it worked in my case and that's why I suspected you taking a shortcut ("if this user isn't here, report it right away).
Sincerely,
Mike
No there's not. If mss recognises the Host portion of the URI (which includes the port number) as a domain it hosts then it goes away and tries to lookup the bindings for the account/extension indicated by the User portion of the URI.MikeTelis wrote:Hi Aaron,
being illiterate in this field, I need your expert advice. Is there any situation where I'd need to use "User@sip.mysipswitch.com:port" instead of "User@sip.mysipswitch.com"? If yes, I will convert "User@local:port" into ""User@sip.mysipswitch.com:port", otherwise I'll just remove the "port" part from URI string.
The full list of hostname that the mss recognises as belonging to it are:
sip.mysipswitch.com
sip.mysipswitch.com:2060
sip.mysipswitch.com:5060
sip.mysipswitch.com:8091
213.200.94.182
213.200.94.182:2060
213.200.94.182:5060
213.200.94.182:8091
77.67.57.195:80
77.67.57.195:5060
77.67.57.195
local
I can't think why you'd ever need to worry about which Host was used to get the call to mss (except for the people with multiple hosted domains but thats another thing altogether). I would recommend sticking to using sys.Dial("user@local") in your dialplan to keep it more readable but you could feasibly use whichever Host from the baove list that took your fancy.
I'll take a look at the incoming call routing issue as well.
Regards,
Aaron
Regards
Hi Mike,MikeTelis wrote:As to calling local users when they are not online, could you please try to duplicate my experiment? Here it is, step-by-step:
1. telnet sip.mysipswitch.com 11005 and enter offline user's account credentials. Hit <Enter> on filter prompt.
2. Try calling that user from your account. You can use either my or Myatus' dialplan (or write a 1-line script of your own). Essential part is that you need to invoke sys.Dial(""User@sip.mysipswitch.com").
In my experiment, I didn't get anything on telnet screen.
3. Login that (offline user's) ATA. You'll get corresponding records via telnet.
4. Repeat #2 above and you'll see normal dialplan processing output.
That's how it worked in my case and that's why I suspected you taking a shortcut ("if this user isn't here, report it right away)
I've twigged what this one is now. I automatically assumed the call was coming from outside when I saw @sip.mysipswitch.com but re-reading shows you are calling the user from within your dialplan.
You are correct that the if you call an mss user from within your dialplan an attempt will be made to send the call directly to the registered bindings for that account. That's not a bug or a shortcut but a design decision (and I can assure you it's the right one as I have been there done that with the whole SIP account addressing).
What you actually want is an extension. Unlike a SIP account when a call arrives on an extension its owner is looked up and then the call is dropped into their dialplan.
The key point is that SIP accounts have to have simple way to be directly addressed and that's what the sys.Dial("user@local") is. You can always rely on the fact that that command is going to try and send the call directly to the SIP account bindings for that user, no ifs no buts. If the mechanism to reach a SIP account becomes complicated you can end up causing a lot of pain for users. The use of extensions is the compromise.
Regards,
Aaron
I was finaly trying to write my own #ruby dialscript
because I don't need all the features that the script has from myatus
and I am going the right way but I only have one question
is it possible to detect if a username exists on the mysipswitch so you can redircet him internally
Here is my dialplan :
#Ruby
Landnummer = "31"
sys.Log("call from #{req.Header.From.FromURI.ToString()} to #{req.URI.User}.")
if sys.In then
# Do your incoming and forwarding call processing here.
sys.Dial("#{sys.Username}@sip.huizenwireless.nl")
else
# Do your outgoing call processing customisations here. (PhoneBook)
case req.URI.User
when /^612$/ then sys.Dial("612@fwd.pulver.com") # Speaking Clock
when /^613$/ then sys.Dial("613@fwd.pulver.com") # Echo Test
# Call 0800 Numers in the netherlands trough poivy. (this is free)
when /^08/ then sys.Dial("${EXTEN}@poivy-#{sys.Username}")
# Call local (Huizen Wireless) e164.org internet Numbers.
when /^88299007689/ then
req.Header.From.FromName = "#{sys.Username}"
sys.Dial("#{req.URI.User}@sip.huizenwireless.nl")
# Do ENUMLookup for 88299 e164.org internet numbers.
when /^88299/ then
enumURI = "" unless enumURI = sys.ENUMLookup("+#{req.URI.User.to_str[1..-1]}.e164.org").to_s
if enumURI.empty?
# If no ENUMLookup found for 88299 e164.org internet numbers call default outgoing line.
sys.Dial("${dst}@intervoip-#{sys.Username}")
else
# If ENUMLookup for 88299 e164.org internet number found call ENUM Uri.
sys.Dial("#{enumURI}")
end
# Call voipcheap/backup line for freedays or backup with *1
when /^\*1/ then sys.Dial("${dst:2}@voipcheap-#{sys.Username}")
# Force ENUMLookup for normal numbers with *9
when /^\*9/ then
enumURI = "" unless enumURI = sys.ENUMLookup("+#{req.URI.User.to_str[2..-1]}.e164.org").to_s
if enumURI.empty?
# If no Forced ENUMLookup number found call default outgoing line.
sys.Dial("${dst:2}@intervoip-#{sys.Username}")
else
# If Forced ENUMLookup number found call ENUM Uri.
sys.Dial("#{enumURI}")
end
else
sys.Dial("${EXTEN}@intervoip-#{sys.Username}")
end
end
Thanks in advance
because I don't need all the features that the script has from myatus
and I am going the right way but I only have one question
is it possible to detect if a username exists on the mysipswitch so you can redircet him internally
Here is my dialplan :
#Ruby
Landnummer = "31"
sys.Log("call from #{req.Header.From.FromURI.ToString()} to #{req.URI.User}.")
if sys.In then
# Do your incoming and forwarding call processing here.
sys.Dial("#{sys.Username}@sip.huizenwireless.nl")
else
# Do your outgoing call processing customisations here. (PhoneBook)
case req.URI.User
when /^612$/ then sys.Dial("612@fwd.pulver.com") # Speaking Clock
when /^613$/ then sys.Dial("613@fwd.pulver.com") # Echo Test
# Call 0800 Numers in the netherlands trough poivy. (this is free)
when /^08/ then sys.Dial("${EXTEN}@poivy-#{sys.Username}")
# Call local (Huizen Wireless) e164.org internet Numbers.
when /^88299007689/ then
req.Header.From.FromName = "#{sys.Username}"
sys.Dial("#{req.URI.User}@sip.huizenwireless.nl")
# Do ENUMLookup for 88299 e164.org internet numbers.
when /^88299/ then
enumURI = "" unless enumURI = sys.ENUMLookup("+#{req.URI.User.to_str[1..-1]}.e164.org").to_s
if enumURI.empty?
# If no ENUMLookup found for 88299 e164.org internet numbers call default outgoing line.
sys.Dial("${dst}@intervoip-#{sys.Username}")
else
# If ENUMLookup for 88299 e164.org internet number found call ENUM Uri.
sys.Dial("#{enumURI}")
end
# Call voipcheap/backup line for freedays or backup with *1
when /^\*1/ then sys.Dial("${dst:2}@voipcheap-#{sys.Username}")
# Force ENUMLookup for normal numbers with *9
when /^\*9/ then
enumURI = "" unless enumURI = sys.ENUMLookup("+#{req.URI.User.to_str[2..-1]}.e164.org").to_s
if enumURI.empty?
# If no Forced ENUMLookup number found call default outgoing line.
sys.Dial("${dst:2}@intervoip-#{sys.Username}")
else
# If Forced ENUMLookup number found call ENUM Uri.
sys.Dial("#{enumURI}")
end
else
sys.Dial("${EXTEN}@intervoip-#{sys.Username}")
end
end
Thanks in advance
Aaron,
thank you very much for detailed explanation! I have reworked the code:
And yes, there's no need to check for "local", it works automatically (thanks for your alias!).
As far as calling to local users, you are the boss! If you call it not a bug but a feature... Okay, let's get serious. I think you're right. What we get is yet another option, calling in the "no ifs no buts" manner. Need something else? - call on extension!
Thank you again,
Mike
P.S. I hope that "the other Mike" will notice my snippet and make changes to his dialplan
P.P.S. I have updated my dialplan posted in the other thread.
thank you very much for detailed explanation! I have reworked the code:
Code: Select all
# Serviced domains, must be in lowercase!
Domains = ['sip.mysipswitch.com','213.200.94.182','77.67.57.195']
...
num = req.URI.User.to_s; reqHost = req.URI.Host.to_s # Get User and Host
host = reqHost.downcase.slice(/[^:]+/) # Convert to lowercase and delete optional ":port"
num << '@' << reqHost unless Domains.find {|x| x == host} # URI dialing unless host is on our domain list
As far as calling to local users, you are the boss! If you call it not a bug but a feature... Okay, let's get serious. I think you're right. What we get is yet another option, calling in the "no ifs no buts" manner. Need something else? - call on extension!
Thank you again,
Mike
P.S. I hope that "the other Mike" will notice my snippet and make changes to his dialplan
P.P.S. I have updated my dialplan posted in the other thread.
Last edited by MikeTelis on Sat Oct 11, 2008 7:54 am, edited 1 time in total.
Either areacode, or "dial 9 for outside line".
Personally, I don't like this approach. MSS extension number is 8 or 10 digits long which is very incovenient, by my standards. I'd prefer 2 or 3-digit extension numbers, it's more than enough for everybody's needs.
You can program your extensions in Speeddial hash, like this:
'10' => '12345678@local', # Joe, ext. 10
'11' => '87654321@local', # Jane, ext. 11
I'm not going to implement neither "areacode" nor "dial 9" in my dialplan. I think that "extension programming" is the right answer.
Mike
Personally, I don't like this approach. MSS extension number is 8 or 10 digits long which is very incovenient, by my standards. I'd prefer 2 or 3-digit extension numbers, it's more than enough for everybody's needs.
You can program your extensions in Speeddial hash, like this:
'10' => '12345678@local', # Joe, ext. 10
'11' => '87654321@local', # Jane, ext. 11
I'm not going to implement neither "areacode" nor "dial 9" in my dialplan. I think that "extension programming" is the right answer.
Mike
Hello everyone!
I'll update the dialplan to get some of the few things discussed squared away. I'm a bit preoccupied with other things at this moment Thanks for all the input though!
And yes, either an "area code" or the "dial 9 first" option exists in my dial plan for making local calls. It's just a matter of personal choice while leaving some flexibility for those who don't want to get involved with the coding part. That's what I like so much about MikeTelis' orginal dial plan. If you like its features, copy and paste it, set some options in the tables and you're ready to go!
But you can change my dial plan or copy chunks of code to suit your need, of course! That's the fun part and the beauty of MSS - "Do whatever you want to do"
I'll update the dialplan to get some of the few things discussed squared away. I'm a bit preoccupied with other things at this moment Thanks for all the input though!
And yes, either an "area code" or the "dial 9 first" option exists in my dial plan for making local calls. It's just a matter of personal choice while leaving some flexibility for those who don't want to get involved with the coding part. That's what I like so much about MikeTelis' orginal dial plan. If you like its features, copy and paste it, set some options in the tables and you're ready to go!
But you can change my dial plan or copy chunks of code to suit your need, of course! That's the fun part and the beauty of MSS - "Do whatever you want to do"