How to Use MySipSwitch

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

Post by TheFug » Thu Jan 31, 2008 4:49 pm

I guess Tpad, and Sipgate, are doing the same ? they also do not register on my GXP-2000 IP phone anymore, FWD same story ? but FWD does register on my MySIPSwitch account, maybe some new equipment is used ? which has another NAT or port forwarding "mechanism" ?
Thanks, The Fug.

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

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

Post by gbonnet » Mon Feb 18, 2008 1:16 pm

Hi all,

After the last update the help page https://www.mysipswitch.com/help.aspx (accessible once you are logged in) was completely out of date. I've redone it completely.

Let us know if you are finding issues with it or if you think some info is missing (or that there is too much) ...

Thanks
G.
Blueface [url=http://www.blueface.ie/]Phone[/url] Service

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

Post by TheFug » Mon Feb 18, 2008 5:12 pm

Great ! makes things even easier !
The only thing is, how should now, the CallerID info be inserted ?
in the "Auth Username" field of the form, or added in the dialplan ?Maybe you can exlpain that, or add a example ? to be honest i did not try it yet, but i'm going to set my dialplan into the new syntax, it has a better overview that way, and one has not to set username/password each time into the dialplan, this is a great improvement !
Thanks, The Fug.

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

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

Post by gbonnet » Mon Feb 18, 2008 5:51 pm

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
Blueface [url=http://www.blueface.ie/]Phone[/url] Service

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

Post by TheFug » Mon Feb 18, 2008 6:10 pm

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
Does the From Header also need provider info ? if not, should the format be always international, like: 003123xxx..., +3123xxx..
or is also possible, to leave 0031,+31 out ? this could be done in the "old" situation... would be nice to know, since this is a new syntax, i guess both syntaxes can be used, but not both in one rule line i guess ? these questions pop into my mind, you could call these "fool proof" situations :)
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 » Sat May 03, 2008 9:52 pm

I guess we should forget the old dialplan syntax, and use the new one always ? guess 'll delete the old stuff...
Thanks, The Fug.

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

emoci
Posts: 127
Joined: Mon Aug 20, 2007 11:27 pm

The Old Dial Plan

Post by emoci » Fri Jul 11, 2008 8:58 pm

The Old Dial Plans (Here for those interested, still fully supported)

Making Calls

a) Basic Dial Plan: Let one provider handle all your calls (no *1, *2 etc. required)

exten => _X.,1,Switch(user,pass,${EXTEN}@providerproxy1.com)

Whatever number you dial will be routed with Provider1

b) Use Multiple Providers and choose among them using *1, *2 etc, :

exten => _*1X.,1,Switch(user,pass,${EXTEN:2}@providerproxy1.com)
exten => _*2X.,1,Switch(user,pass,${EXTEN:2}@providerproxy2.com)

So if I wanted to call 14161112222 via provider 1, I would dial *114161112222

If I wanted to dial 14161112222 via provider 2, I would dial *214161112222

c) Use Multiple Providers and choose which provider to use based on the destionation called:

If I wanted to route all North American numbers dialed in 1-xxx-xxx-xxxx format via one provider and long distance numbers via another provider:
exten => _1X.,1,Switch(user,pass,${EXTEN}@NorthAmericalProvider.com)
exten => _011X.,1,Switch(user,pass,${EXTEN}@LongDistance.com)

d) Adjust for local dialing
If I wanted to be able to dial all North American numbers without dialing the 1 (just xxx-xxx-xxxx) while leaving long distance dialing intact:
exten => _011X.,1,Switch(user,pass,${EXTEN}@LongDistance.com)
exten => _X.,1,Switch(user,pass,1${EXTEN}@NorthAmericalProvider.com)
Note the order of Dial Rules


Understanding the Dial Plan expression (Only read if interested, not required for basic outgoing call setup)

The general format for the dial plan has been designed to be somewhat familiar to Asterisk users.

Basic General Expression:
exten = number,priority,Switch(username,password,${EXTEN}@sip.provider.com)
General Expression with Optional features:
exten = number,priority,Switch(username,password,${EXTEN}@sip.provider.com, FromUser, SendTo)

A basic example is:
exten => _*1X.,1,Switch(user,pass,${EXTEN:2}@sip.blueface.ie)
Meaning: All calls that start with *1 will be dialed via BlueFace after removing the *1 from the front

BreakDown:

exten is the keyword to indicate the start of a new dial plan extension.
Operator: can be =, == or => for an equality match or =~ for a regular expression match.
Number or pattern: (the _*1X. for example) is the value the operator is applied to along with the user part of the user's call into the proxy. Eg.If the number starts with *1 that this rule will apply...

Code: Select all

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)

Code: Select all

Regular Expressions
-collecting info on this feature
Priority: (_*1X.,1,Switch): for the time being this should be left to 1 by default
Switch: is the application command.
Authentication: (user,pass,) is the username and password for the provider you want to use
Replacement pattern: (${EXTEN} or ${dst}) Both can be used interchangeably. They allow you to modify how the number will be sent to your provider.

Code: Select all

${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.
Host: finally at the end @sipproviderhost.com is the host address of the provider you want to use for that specific dial plan


Optional: Sending Caller ID

This will only work if the provider you are using let's you specify your own CID. This is the case with some BetaMax providers which will let you send your own number as CID after you have verified it with them.

General expression:
exten => _X.,1,Switch(user,pass,${EXTEN}@sip.blueface.ie)

Modified:

With Name:
exten => _X.,1,Switch(user,pass,${EXTEN}@sip.blueface.ie, "MyName" <sip:12345@sip.blueface.ie>)
-CID sent will be: MyName 12345

Without Name:
exten => _X.,1,Switch(user,pass,${EXTEN}@sip.blueface.ie, <sip:12345@sip.blueface.ie>)
-CID sent will be: 12345

Discussion: http://www.mysipswitch.com/forum/viewtopic.php?t=122


Optional: Specifying Outbound Proxy

Some providers require an outbound proxy to be specified that's different from the host address for registration.

General Expression:
exten => _X.,1,Switch(user,pass,${EXTEN}@sip.blueface.ie)

Modified:
exten => _X.,1,Switch(user,pass,${EXTEN}@sip.blueface.ie,,sip.outboundproxy.com) note two commas ,,
Modified, including sending CID:
exten => _X.,1,Switch(user,pass,${EXTEN}@sip.blueface.ie, "MyName" <sip:12345@sip.blueface.ie>,sip.outboundproxy.com)

Discussion: http://www.mysipswitch.com/forum/viewtopic.php?t=99


Most of the above info was obtained from https://www.mysipswitch.com/helpinfo/di ... thelp.html


Receiving Calls

Receiving Calls by registering ATA with MySipSwitch

1. Register your ATA with MySipSwitch
2. Register provider in your MySipSwitch account (Config page, under Registrations):

Username: Provider Username
Password: Provider Password
Server: ProviderServer.com or ProviderServer.com:5060 (use actual server as required by your provider)
Domain/Realm [optional] :
Expiry Seconds (60 to 3600) : 3600 (this is the default value, change if required)
Contact: SipSwitchUsername@sip.mysipswitch.com

Add it, and use the Monitoring page to see that everything went fine. Now calls to the third party provider will ring your ATA/SoftPhone registered with MySipSwitch

Receiving Calls in your ATA registered with another provider

-Other provider that will receive the call must support SIP URI calls from third party networks
-This is an example on how to use MySipSwitch to forward calls coming in from certain providers via SIP URI to a different location

-Register provider in your MySipSwitch account (Config page, under Registrations):

Username: Provider Username
Password: Provider Password
Server: ProviderServer.com or ProviderServer.com:5060 (use actual server as required by your provider)
Domain/Realm [optional] :
Expiry Seconds (60 to 3600) : 3600 (this is the default value, change if required)
Contact: username@ReceivingVSP.com (eg. 123456@voxalot.com)

Receiving Calls on an actual PSTN/Telephone number

1. Create a Special DialPlan (preferrably near the end of the list if you have other Dial Plans you are using):

(a)
exten = SipSwitchUsername,1,SwitchCall(user,pass,NumberToCall@OutgoingProvider.com)

Now all calls to SipSwitchUser@sip.mysipswitch.com will ring your regular phone.

(b)
You can also create a Dial Plan to apply to only a specific instance:

exten = anything.SipSwitchUsername,1,SwitchCall(user,pass,NumberToCall@OutgoingProvider.com)

Where I wrote anything, you can literally put in anything that you like, but try to keep it short and hopefully make it descriptive, like cell.MySipSwitchUsername

Now all calls to anything.SipSwitchUsername@sip.mysipswitch.com will ring your regular phone, but calls to SipSwitchUsername@sip.mysipswitch.com will continue to ring your ATA if you've got one registered.

Using this pattern you can assing multiple SIP URIs to ring multiple phones.

2. Register provider in your MySipSwitch account (Config page, under Registrations) and point to ring your PSTN phone.

Username: Provider Username
Password: Provider Password
Server: ProviderServer.com or ProviderServer.com:5060 (use actual server as required by your provider)
Domain/Realm [optional] :
Expiry Seconds (60 to 3600) : 3600 (this is the default value, change if required)
Contact: anything.SipSwitchUsername@sip.mysipswitch.com

Now calls to any providers which have been pointed to anyhting.SipSwitchUsername@sip.mysipswitch.com, or SIP URI calls to anything.SipSwitchUsername@sip.mysipswitch.com will ring the Phone Number you setup.

Optional: Capturing and Passing Caller ID

When someone calls a DID that's been pointed to anything.SipSwitchUsername@sip.mysipswitch.com, your phone will ring but you may not receive the CID of the caller. To ensure MySipSwitch is passing through CID, set your Dial Plan from Step 1 as:

exten = anything.SipSwitchUsername,1,SwitchCall(user,pass,NumberToCall@OutgoingProvider.com,${fromname} <sip:${fromuriuser}@sip.mysipswitch.com>)

Discussion:
http://www.mysipswitch.com/forum/viewtopic.php?t=154
http://www.mysipswitch.com/forum/viewtopic.php?t=230


Troubleshooting

If any of the outgoing calls are having a problem, or the forwarding to your PSTN number is having an issue, one way to start troubleshooting is by getting a trace for the call.

Adjust any of your dial plan lines for which need a trace as follows:

Without any of the other optional features:
exten => _X.,1,SwitchCall(user,pass,${EXTEN}@sip.blueface.ie,,, True)
or
Including the other optional features
exten => _X.,1,SwitchCall(user,pass,${EXTEN}@sip.blueface.ie,From User, OutboundProxy, True)

By setting the last parameter as True a trace of the call will be recorded and emailed to the sipswitch owner of the call after it's complete. Providing a trace of a problematic call makes it a lot easier to troubleshoot

emoci
Posts: 127
Joined: Mon Aug 20, 2007 11:27 pm

Post by emoci » Fri Jul 11, 2008 9:50 pm

Added some much needed updates, and re-organized things...

Still to come:
-A quick overview of the new Dial Plan Syntax
-A WalkThrough for Ruby Dial Plans

emoci
Posts: 127
Joined: Mon Aug 20, 2007 11:27 pm

Ruby Dial Plan

Post by emoci » Mon Jul 14, 2008 12:06 am

1. Ruby Dial Plan Example

To put this dial plan example into context, I have the following providers:

Provider1: Outgoing Calls only, mostly North America
Provider2: Outgoing Calls only, mostly International
Provider3: Incoming DID calls (Contact field for registration set as sip:provider3.mssusername@sip.mysipswitch.com)
Provider4: Incoming DID calls (Contact field for registration set as sip:provider4.mssusername@sip.mysipswitch.com)
Provider 5: Incoming DID calls (Contact field for registration set as sip:provider5.mssusername@sip.mysipswitch.com)
SipBroker: Set up as a provider with anon username and no password
PhoneGnome: For calls to PG users
VoXalot: Default provider


The entire following Ruby script is what I am using, however I have divided in in parts to make it easier to understand how to accomplish each part.

Note that except #Ruby, everything else after a # is a comment and does not affect the program but simply is there for guidance

The whole script is one large If-else statement with more if and case statements embedded.

By dividing it into parts, it also helps for you to see a scaffold. For example, if you do not require the "#****Route Calls based on Caller ID Only****" section, simply do not use it, as long as you remember to remove the end statement corresponding to the case statement in that section:

Code: Select all

#Ruby 
sys.log("***Starting New Call Event***")
#********Incoming Calls********

Code: Select all

#****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} ***")

Code: Select all

#****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)

Code: Select all

else

Code: Select all

#****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") 



Code: Select all

else

Code: Select all

#****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")

Code: Select all

else 

Code: Select all


#****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 

Code: Select all

#****End Statements****

end #cid+trunk rule 1
end #cid+trunk rule 2

end #case trunk
end #case cid

Code: Select all

else

#********Outgoing Calls********

Code: Select all

sys.log("***Outgoing Call Starting***")
number_called = req.URI.User

Code: Select all

#****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")

Code: Select all

else 

Code: Select all

#****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") 

Code: Select all

else 

Code: Select all

#****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") 

Code: Select all

else 

Code: Select all

#****If there is no other match****

sys.Log("No Dial Plan Match: Trying Default Rule") 
sys.Dial("VoXalot") 

Code: Select all

#****End Statements****

end  # case for outgoing dialplans
end  # case for number length
end  # case for blocked numbers
end
2. Regular Expression examples for Ruby

This is to further help as you write your own Ruby plan:

Example 1

Regular Syntax:
exten => _*1X.,1,Switch(${EXTEN:2}@provider)

Can be written in Ruby within a case statement as:

Code: Select all

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") 
or within an if statement as:

Code: Select all

if req.URI.User.StartsWith("*1") then 
sys.Dial("${dst:2}@provider") 
end
Example 2

Regular Syntax:
exten => _11X.,1,Switch(${EXTEN:2}@provider)

Can be written in Ruby within a case statement as:

Code: Select all

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") 
or within an if statement as:

Code: Select all

if req.URI.User.StartsWith("11") then 
sys.Dial("${dst:2}@provider") 
end
Example 3

Regular Syntax:
exten => _12,1,Switch(12@provider)

can be written in Ruby as:

Code: Select all

when /^12$/ then sys.Dial("12@provider")
See https://www.mysipswitch.com/forum/viewtopic.php?t=579

Example 4

Regular Syntax:
exten => _13.,1,Switch(${EXTEN:2}@provider)

Can be written in Ruby as:
when /^13.*$/ then sys.Dial("${dst:2}@provider")


Regular Syntax
exten => _13x.,1,Switch(${EXTEN:2}@provider)

Can be written in Ruby as:
when /^13.+$/ then sys.Dial("${dst:2}@provider")


Regular Syntax
exten => _13xxxx,1,Switch(${EXTEN:2}@provider)

Can be written in Ruby as:
when /^13.{4}$/ then sys.Dial("${dst:2}@provider")

See https://www.mysipswitch.com/forum/viewtopic.php?t=598

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

Post by gbonnet » Mon Jul 14, 2008 7:18 am

Thanks a lot for that Emoci !
Blueface [url=http://www.blueface.ie/]Phone[/url] Service

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest