Flexible table-controlled dialplan, optimized for US, GV

Catalog of dial plans
siwuxie
Posts: 7
Joined: Tue Jun 22, 2010 4:43 am

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by siwuxie » Tue Jun 22, 2010 5:06 am

Hi MikeTelis,

I need your help please. I have a 3rd party VOIP provider which is freephoneline.ca, and I use it (1416xxxyyyy)as the google voice forward number. What I want is to use Google Voice + freephoneline + sipsorcery.com = Free Inbound/outbound Calling. In this case, what dialplan I should use. Also, when I dial out, how to make the receiver's phone indicate my freephoneline number (1416xxxyyyy) instead of my google voice nubmer.

Thanks a lot!

reraikes
Posts: 237
Joined: Thu Aug 13, 2009 10:15 pm

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by reraikes » Tue Jun 22, 2010 6:25 am

siwuxie wrote:Also, when I dial out, how to make the receiver's phone indicate my freephoneline number (1416xxxyyyy) instead of my google voice nubmer.
You would have to convince Google to change the CallerID on your Google Voice account to your freephoneline number. While that's technically doable... Good luck!

siwuxie
Posts: 7
Joined: Tue Jun 22, 2010 4:43 am

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by siwuxie » Wed Jun 23, 2010 5:58 am

Hi Mike,

I need you help to setup my dial plan please.

Here is my situation:

1. I added four SIP providers (Freephoneline, Gizmo, Raketu, localphone) under sipsorcery.com

2. I have Google Voice account, I added my Gizmo sip number(1747xxxyyyy) as forwarding number under google voice and I want to use this Gizmo sip number(1747xxxyyyy) to setup GoogleVoiceCall too.

3. I want to use Freephoneline as the default provider. When I dial North America number (zzzxxxyyyy), also including Toll-free number (such as 800, 866, 877, 888, etc) , use it first, if it failed then let the system switch to GoogleVoiceCall automatically.

4. When I dial any numbers with 01186 as prefix (which actully is the prefix for calling China), I want the system to pick up Raketu as provider automatically.

5. I need speed dial entries to setup some numbers like Home, Mum, 911, 411, etc

5. Also, I want to make it possible to choose provider manually by dailing #1, #2, #3 or #4.

That's all I need. Basically, I make most of my calls to North America and China.

Thanks a lot!

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by MikeTelis » Wed Jun 30, 2010 6:58 am

Sorry for the delay, I've been away from my computer for a couple of weeks. The problem with existing dialplan is that it treats Google Voice as a special case; GV can't be handled like a regular provider. Therefore, you can't select it manually (with #n prefix) and you can't failover to GV if your call with Freephoneline failed.

I think the best you can do at the moment is to "convert" GoogleVoice into a regular provider and then use Flexible table-controlled dialplan.

Or, you can treat Freephoneline's failure as a special case and handle it in a patch to dial method, like this:

Code: Select all

  sys.Dial(@num,*args) # Dial
  status()             # We shouldn't be here! Get error code...
  sys.Log("Call failed: code #{@code}, #{@reason}")

# *** workaround for GV begin *** #
  if @num =~ /^1([^@]+)@Freephoneline$/
    sys.Log("Call to #@num with Freephoneline failed with #@code / #@reason, switching to GV")
    @code = nil
    googleVoice
  end
# ***  workaround for GV end  *** #
I'm considering a new version of dialplan which would allow you to treat GV as a regular provider, but this is a long shot.

siwuxie
Posts: 7
Joined: Tue Jun 22, 2010 4:43 am

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by siwuxie » Wed Jun 30, 2010 10:58 pm

Or, you can treat Freephoneline's failure as a special case and handle it in a patch to dial method, like this:

Code: Select all

  sys.Dial(@num,*args) # Dial
  status()             # We shouldn't be here! Get error code...
  sys.Log("Call failed: code #{@code}, #{@reason}")

# *** workaround for GV begin *** #
  if @num =~ /^1([^@]+)@Freephoneline$/
    sys.Log("Call to #@num with Freephoneline failed with #@code / #@reason, switching to GV")
    @code = nil
    googleVoice
  end
# ***  workaround for GV end  *** #
Hi, Mike

Thanks for your help. I tried this, but it doesn't work. When I call a number with freephoneline failed, I heard the following messages.
"This call is not covered by your tariff plan" and "This nunber is not available for call return, goodbye"

I know the first message comes from freephoneline when the number dailed is not covered by it. Regarding the 2nd msg, I think it comes from Google Voice.

However, if I did't put your code in, I only heard "This call is not covered by your tariff plan" and then the busy tone. Also, I dialed the same number with googlevoice directly, it went throught.

BTW, my VSP Selection Code is as following. In order to test the special case code you gave me, I added New York area code 646, which is not covered by freephoneline.

Code: Select all

def selectVSP    # VoIP provider selection

  # Reject calls to premium numbers unless VSP was forced

  ExcludedPrefixes.each { |p| p.gsub!(/\s*/,''); sys.Respond(503,"Calls to #{$1}* not allowed") if @num =~ /^(#{p})/ }

  case @num
    when /^1([2-9]\d\d)/                # North America
      case $1                           # check area code
        when /(800|866|877|888|416|647|905|646)/    # Toll-free and Toronto calling
          route(0,"freephoneline")
        else
          googleVoice
          sys.Log("GoogleVoiceCall failed, routing thru F9")
          route(4,"Destination - North America")
        end
    when /^972(5|6)/                    # Israel mobile
      route(3,"Destination - Israel mobile")
    else
      route(0,"freephoneline")
  end
end

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by MikeTelis » Thu Jul 01, 2010 2:33 pm

First off, make sure that Google Voice works. In order to do that, temporarily change selectVSP code as follows:

Code: Select all

  case @num
    when /^1([2-9]\d\d)/                # North America
        googleVoice
If this doesn't work, you need to check your googleVoice settings, especially callback number. BTW, you may want to upgrade to the latest version of my dialplan, there is a link in the end of previous page of this thread.

If it works... something must be wrong with my workaround! Could you post event * Console log of the call?

siwuxie
Posts: 7
Joined: Tue Jun 22, 2010 4:43 am

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by siwuxie » Fri Jul 02, 2010 2:20 am

Mike,

Google Voice works. Here is the event * Console log of the call.

DialPlan 02:18:22:487 sip1: New call from udp:69.172.121.20:5060 successfully authenticated by digest.
DialPlan 02:18:22:519 sip1: Using dialplan default for Out call to sip:6464344619@sipsorcery.com.
NewCall 02:18:22:519 sip1: Executing script dial plan for call to 6464344619.
DialPlan 02:18:22:612 sip1: ** Call from "Tao Chen" <sip:siwuxie@sipsorcery.com>;tag=4d05ed99afe2a75fo1 to 6464344619 **
DialPlan 02:18:22:628 sip1: Local time: 07/01/2010 22:18
DialPlan 02:18:22:644 sip1: Number in ENUM format: 16464344619
DialPlan 02:18:22:644 sip1: freephoneline
DialPlan 02:18:22:644 sip1: Commencing Dial with: 16464344619@freephoneline.
DialPlan 02:18:22:644 sip1: Attempting to locate a provider for call leg: sip:16464344619@freephoneline.
DialPlan 02:18:22:644 sip1: ForkCall commencing call leg to sip:16464344619@voip.freephoneline.ca.
DialPlan 02:18:22:644 sip1: SIPClientUserAgent Call using alternate outbound proxy of udp:69.59.142.213:5060.
DialPlan 02:18:22:644 sip1: Switching to sip:16464344619@voip.freephoneline.ca:5060 via udp:69.59.142.213:5060.
DialPlan 02:18:22:644 sip1: SDP on UAC call had RTP socket mangled from 192.168.1.66:16438 to 69.172.121.20:16438.
DialPlan 02:18:22:722 sip1: Information response 100 trying -- your call is important to us for sip:16464344619@voip.freephoneline.ca.
DialPlan 02:18:22:737 sip1: Response 401 Unauthorized for sip:16464344619@voip.freephoneline.ca.
DialPlan 02:18:22:816 sip1: Information response 100 trying -- your call is important to us for sip:16464344619@voip.freephoneline.ca.
DialPlan 02:18:23:065 sip1: Information response 183 Session Progress for sip:16464344619@voip.freephoneline.ca.
DialPlan 02:18:23:065 sip1: UAS call progressing with SessionProgress.
NATKeepAlive 02:18:24:472 sip1: Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:69.172.121.20:5060.
DialPlan 02:18:26:159 sip1: Response 603 Declined for sip:16464344619@voip.freephoneline.ca.
DialPlan 02:18:26:175 sip1: Call failed: code 603, Declined
DialPlan 02:18:26:175 sip1: Call to 16464344619@freephoneline with freephoneline failed with 603 / Declined, switching to GV
DialPlan 02:18:26:175 sip1: SDP on GoogleVoiceCall call had RTP socket mangled from 192.168.1.66:16438 to 69.172.121.20:16438.
DialPlan 02:18:26:175 sip1: UAS call ignoring progress response with status of 180 as already in Proceeding.
DialPlan 02:18:26:175 sip1: Logging into google.com for ping78@gmail.com.
DialPlan 02:18:26:222 sip1: Google Voice pre-login page loaded successfully.
DialPlan 02:18:26:222 sip1: GALX key uEYY6Tv1490 successfully retrieved.
DialPlan 02:18:27:081 sip1: Google Voice home page loaded successfully.
DialPlan 02:18:27:144 sip1: Call key 3gC7uaxLLT6aFUoGFGKvTGnOhe8= successfully retrieved for ping78@gmail.com, proceeding with callback.
DialPlan 02:18:27:144 sip1: SIP Proxy setting application server for next call to user siwuxie as udp:69.59.142.213:5070.
DialPlan 02:18:27:269 sip1: Google Voice Call to 16464344619@freephoneline forwarding to 17472833628 successfully initiated, callback timeout=30s.
DialPlan 02:18:27:472 sip1: SIP Proxy directing incoming call for user siwuxie to application server udp:69.59.142.213:5070.
DialPlan 02:18:27:487 sip1: Google Voice Call callback received.
DialPlan 02:18:27:503 sip1: Answering client call with a response status of 200.
DialPlan 02:18:27:581 sip1: Google Voice Call was successfully answered in 1.41s.
DialPlan 02:18:27:925 sip1: Dial plan execution completed with normal clearing.
DialPlan 02:18:32:690 sip1: Matching dialogue found for BYE to sip:69.59.142.213:5060 from udp:69.59.142.213:5060.
NATKeepAlive 02:18:34:628 sip1: Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:69.172.121.20:5060.
NATKeepAlive 02:18:44:815 sip1: Requesting NAT keep-alive from proxy socket udp:69.59.142.213:5060 to udp:69.172.121.20:5060.

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by MikeTelis » Fri Jul 02, 2010 3:40 am

Oh, I overlooked that @num is no longer contains dialed number, it's substituted with number + "@freephoneline". You need to use a local variable instead of @num:

Code: Select all

# *******************************  D I A L  ********************************

def dial(*args)
  sys.Log(@l) unless @l.empty?               # for the record :)
  if tpl=VSPtab[@p.to_s]                     # if provider is in our table
    tpl.gsub!(/\s*/,'')                      # Remove spaces
    num = tpl.gsub(/@/,@num+'@')             # Insert number before '@'
  end
  sys.Dial(num,*args)  # Dial
  status()             # We shouldn't be here! Get error code...
  sys.Log("Call failed: code #{@code}, #{@reason}")

# *** workaround for GV begin *** #
  if num =~ /^1([^@]+)@Freephoneline$/
    sys.Log("Call to #@num with Freephoneline failed with #@code / #@reason, switching to GV")
    @code = nil
    googleVoice
  end
# ***  workaround for GV end  *** #

end

siwuxie
Posts: 7
Joined: Tue Jun 22, 2010 4:43 am

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by siwuxie » Sat Jul 03, 2010 1:00 am

Thanks Mike, it works great!

MikeTelis
Posts: 1582
Joined: Wed Jul 30, 2008 6:48 am

Re: Flexible table-controlled dialplan, optimized for US, GV

Post by MikeTelis » Wed Jul 14, 2010 7:48 am

I have released version 2 of this dialplan and you no longer need that ugly workaround :)

Post Reply