News:

On Tuesday September 6th the forum will be down for maintenance from 9:30 PM to 11:59 PM PDT

Main Menu

Google Call Back Clarification

Started by Hortoristic, February 13, 2014, 01:23:20 PM

Previous topic - Next topic

Hortoristic

I've seen some posts about how we can make use of our Google number, and it will call back and connect both parties.

Can someone elaborate on how this works, or if I'm even on the right track?

Example:

  • I dial a friends number in California
  • The OBI somehow leverages my GV which connects my Comcast number with my buddy in California but my buddy is seeing my GV number, not my Comcast #

Even if we are using that new small bucket of minutes that Anveo is offering, it uses the smallest increment to initiate the call, but then Google completes connecting both sides, but not using the Anveo outgoing minutes.

Is this really how GV call back can work and if so - is there a good article you can point me to; to set it up?

drgeoff

AIUI the only GV "callback" method is when the call is initiated by inputting call details on a webpage at google.com/voice.  GV then calls you on the phone you have specified on that webpage.  When you answer GV rings the callee's number.  When that answers the two legs are bridged.

Normally the details are entered on the web page by a human (you).  However Sipsorcery can initiate GV calls from a phone.  It does that by accessing by its "machine" accessing the same web page and automatically inputting the required info.  (All the info except the callee number is prestored in a dialplan on the Sipsorcery server.)

When you use any phone service (SIP or POTS) to call your own GV number you then have the option to onward dial a call (at no cost in N. America).  There is no callback and you incur normal phone service charges to your GV number for the entire duration of the call (to GV and the onward call). 

Hortoristic

To use SIPSorcery for this, do they make you sign up for the pricey plan?

lhm.

The $69.00 plan will work fine with GV.

Rick

If you have cell service which allows "Friends and Family", and you list your Google Voice number in that list, then whether you call it and it calls you back - or you call it and make a call - everything is then at no cost to you. 

tyeske

I'm currently using Ipkall & Sipsorcery. Lately my CNAM isn't working, but I see I'm not the only one. I have a whitepages key, but it may have died.

I originally tried to set up my SS dialplan so that my OBI would ring SS then route the outbound call to GV.

Currently my calls are routed directly from my OBI202 to GV, but I can't seem to fix my SS dialplan to route the calls to SS first.

Can anyone help me?

Hortoristic

Just curious, with SS being so expensive, why are you solutioning with them? Maybe it was free at one time?

gderf

SS was free. But they now charge for it.
Help me OBiHai PhoneOBi. You're my only hope.

azrobert

#8
Quote from: tyeske on February 26, 2014, 12:40:37 PM
I'm currently using Ipkall & Sipsorcery. Lately my CNAM isn't working, but I see I'm not the only one. I have a whitepages key, but it may have died.

I originally tried to set up my SS dialplan so that my OBI would ring SS then route the outbound call to GV.

Currently my calls are routed directly from my OBI202 to GV, but I can't seem to fix my SS dialplan to route the calls to SS first.

Can anyone help me?

I'm confused at what you want to do.
Do you want to route outbound calls from the OBi phone port to SS?
If yes, assuming GV is on SP1 and SS on SP2 you can try changing the Phone Port Primary Line from SP1 Service to SP2 service.

I switched CNAME over to OpenCnam
Here is the code:

 cid = req.Header.From.FromURI.User
  cid = "#{$1}" if cid =~ /^1(\d{10})$/    
 @OpenCName ||= sys.WebGet("https://api.opencnam.com/v2/phone/#{cid}?format=text",4)
  sys.log("OpenCName: #{@OpenCName}")
  prs = @OpenCName.split(' ')
  State = prs[-1]
  if City = prs[-2]
     @cname = "#{City} #{State}"
   else
     @cname = "#{@OpenCName}"
   end
  @cname = @cname.tr(',',' ')
  sys.log("CName: #{@cname}")


Use variable @cname to display CallerID name on your phone.
If the result is a city and state it will look something like "Scottsdale        AZ".
I then remove some of the blanks and move it to variable @cname like "Scottsdale AZ"
I also remove any commas.
SS has trouble using a comma in cname.

Edit:
cid must be 10 digits.
I added code to above to remove the country code.

tyeske

#9
Azrobert thanks for the suggestions, but when I make SS my Phone Port Primary, I can initiate the call, but I can't get the call to go through. I get the call was rejected by service provider 480 error.

Here is what the SS console shows:
DialPlan 22:04:14:533 sip1(7784): Calling 1763XXXXXXX via Google Voice
DialPlan 22:04:14:533 sip1(7784): SDP on GoogleVoiceCall call had public IP not mangled, RTP socket 97.116.165.126:16804.
DialPlan 22:04:14:533 sip1(7784): UAS call progressing with Ringing.
DialPlan 22:04:14:549 sip1(7784): Logging into google.com for XXXXX@gmail.com.
DialPlan 22:04:14:580 sip1(7784): Google Voice pre-login page loaded successfully.
DialPlan 22:04:14:580 sip1(7784): GALX key XXXXXXXXXX successfully retrieved.
DialPlan 22:04:15:549 sip1(7784): Google Voice home page loaded successfully.
DialPlan 22:04:15:565 sip1(7784): Call key GWOkPogBcpVy/y81hHNjcQNB/tU= successfully retrieved for XXXXX@gmail.com, proceeding with callback.
DialPlan 22:04:15:565 sip1(22492): SIP Proxy setting application server for next call to user XXXXX as udp:67.222.131.147:5070.
DialPlan 22:04:15:627 sip1(7784): Google Voice Call to 1763XXXXXXX initiated, callback #1763XXXXXXX, phone type 1, timeout 15s.
DialPlan 22:04:30:627 sip1(7784): Google Voice Call timed out waiting for callback.
DialPlan 22:04:30:721 sip1(7784): Google Voice Call to 1763XXXXXXX was successfully cancelled.
DialPlan 22:04:30:721 sip1(7784): Dialplan cleanup for XXXXX.
DialPlan 22:04:30:752 sip1(7784): Dial plan execution completed without answering and with no last failure status.
DialPlan 22:04:30:752 sip1(7784): UAS call failed with a response status of 480.

Can you tell me what is going wrong?

Also, I tried your OpenCnam script. I inserted it right below my white pages script. I put a # in front of my white pages script. After adding your script, I couldn't receive any calls.

Do I need to make edits to my dialplan somewhere else in order to use your OpenCnam? I'm not very technical, so please use layman terms.

Thanks!

I went back in and changed my dialplan to the Simple_Dialplan and only made the necessary 4 edits. There must have been an error in my old dialplan. Now I can call out using SS. Every incoming call still has the number 206.682.0185. I used to have a name table, but that doesn't work anymore either. If I could get OpenCnam to work and or get my name table working again, that would be great.

azrobert

#10
I copied the code I supplied and put it at the beginning of the inbound portion of my dialplan.
It works.

Below is code closer to my real dialplan. It includes code for a table lookup. The OpenCnam code is a sub-routine. The dialplan has a Begin statement which requires an additional End statement. I remove a lot of code, so I hope I didn't make any mistakes.

If you can't get it working, post your code and I'll see if I can spot the problem.

#Ruby # DialPlan1

TNAME = {
 '4808370001' => 'Home',
 '4808370002' => 'Work',
 '4808370003' => 'Wife',
 '4808370004' => 'Mother',
 '4808370005' => 'Father',
 '4808370006' => 'Girl Friend'  }

def getcname cid
  @OpenCName ||= sys.WebGet("https://api.opencnam.com/v2/phone/#{cid}?format=text",4)
  sys.log("CallerName: #{@OpenCName}")
  prs = @OpenCName.split(' ')
  State = prs[-1]
  if City = prs[-2]
     @cname = "#{City} #{State}"
   else
     @cname = "#{@OpenCName}"
   end
  @cname = @cname.tr(',',' ')
  sys.log("CName: #{@cname}")
  return @cname
end

begin

if sys.In

  CID = req.Header.From.FromURI.User
  CID = "#{$1}" if CID =~ /^1(\d{10})$/                         #   Remove leading "1"

  sys.log("CallerID:   #{CID}")

  if !(@cname = TNAME[CID]) && CID =~ /^([2-9]\d\d[2-9]\d{6})$/
     @cname = getcname CID
   end

  sys.log("CallerName: #{@cname}")
  sys.Dial("user1@local[fu=#{CID},fd=#{@cname}]",30)

else                                                                #   OUT DIALPLAN STARTS

 end
end



Edit:

I re-read your last post and you are always getting number 206.682.0185. 206 is a Washington state number, so you are using IPKall for your callback number. I know in the past IPKall had problems delivering CID on some of their numbers. Maybe this is your problem and not your dialplan. You can get another IPKall number or an IPComms number. If you get another IPKall number choose a different exchange.

To test OpenCnam put the following statement after I strip the country code to set a dummy CID:

CID = "4808370001"
or
cid = "4808370001"

I used lower case cid in my first example and upper case CID in the second. It makes a difference.

azrobert

#11
I see a fair number of people are reading this thread.
I thought some might want an explanation of the following code:
 
if !(@cname = TNAME[CID]) && CID =~ /^([2-9]\d\d[2-9]\d{6})$/
     @cname = getcname CID
   end

TNAME[CID]          Does a table lookup on CID

@cname = TNAME[CID]
                   The result is placed in @cname
                   If no match the result is null

!(@cname = TNAME[CID])
                   ! is NOT, so this is checking for a null result

&&                  is AND

CID =~ /^([2-9]\d\d[2-9]\d{6})$/
                   Checking CID for proper format

If                  if no result from table lookup and
                   CID is proper format
                   The next command is executed

getcname CID
                   Sub-routine getcname is called
                   CID is passed to the sub-routine

@cname = getcname CID
                   The result from the sub-routine is place in @cname

tyeske

I have tried to put your code into my dial plan, but I must not be putting it in the correct place. Here is my working dial plan. I can dial out and I can receive calls. I'd really like to get the TNAME and OpenCnam working.

Currently with this dial plan, I get the correct incoming phone number sometimes, but other times I get the 206.682.0185 Washington number. I checked and Ipkall doesn't currently have any numbers available. Do you think I should switch to the Ipcomms number?

Thanks for all your help!

# Copyright(c) 2010 Mike Telis

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

# Click "View raw file" in the lower right for the best copy/paste view

AREA_CODE = '763'                  # my area code
GV_USER   = 'XXXXX@gmail.com'     # my GV e-mail address (user@gmail.com)
GV_PASS   = 'XXXXXXX'             # my GV password
CB_NUMBER = '14250000000'          # my 11-digit SIP number (only one) Ipkall

SPEED_DIAL = {         # my speed dial numbers

'411' => '8003733411', # Free411
'266' => '4153767253@podlinez.com',     # CNN Headlines
}


begin
   sys.Log "** Call from #{req.Header.From} to #{req.URI.User} **"

  if sys.Out    # if outbound call
   num = req.URI.User.to_s        # Get a string copy of the number to dial

   num = SPEED_DIAL[num] || num   # Substitute with speed dial entry, if any

   case num
     when /@/ then sys.Dial num   # URI dialing
     when /^[2-9]\d{6}$/          # Local call, 7-digit number
       num = '1'+ AREA_CODE + num # prefix it with country and area code
     when /^[01]?([2-9]\d{9})/    # US number with or without country code
       num = '1' + $1             # add country code and truncate number to 10-digit
     when /^(011|00|\+)(\d{9,})/  # international number
       num = '+' + $2             # GoogleVoiceCall works with '+' prefix only


     else sys.Respond 603, 'Wrong number, check & dial again'
   end

   sys.Log "Calling #{num} via Google Voice"
   sys.GoogleVoiceCall GV_USER, GV_PASS, CB_NUMBER, num, '.*', CB_NUMBER =~ /^1747/ ? 7 : 1, 30

else          # sys.Out
   sys.Dial "#{sys.Username}@local"
end

rescue
sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end


azrobert

#13
I have an IPkall and an IPComms DID. I'm happy with both. If you are having CID problems with IPKall and IPComms is the only free DID available, then go for it.

Try this
AREA_CODE = '763'                  # my area code
GV_USER   = 'XXXXX@gmail.com'     # my GV e-mail address (user@gmail.com)
GV_PASS   = 'XXXXXXX'             # my GV password
CB_NUMBER = '14250000000'          # my 11-digit SIP number (only one) Ipkall

SPEED_DIAL = {         # my speed dial numbers

'411' => '8003733411', # Free411
'266' => '4153767253@podlinez.com',     # CNN Headlines
}

TNAME = {
 '2066820185' => 'IPKall',
 '4808370002' => 'Work',
 '4808370003' => 'Wife',
 '4808370004' => 'Mother',
 '4808370005' => 'Father',
 '4808370006' => 'Girl Friend'  }

def getcname cid
  @OpenCName ||= sys.WebGet("https://api.opencnam.com/v2/phone/#{cid}?format=text",4)
  @OpenCName = "#{req.Header.From.FromName}" if !@OpenCName
   if !@OpenCName
       @OpenCName = "#{CID}"
       @OpenCName.insert(6,"-")
       @OpenCName.insert(3,"-")
    end
  sys.log("CallerName: #{@OpenCName}")
  prs = @OpenCName.split(' ')
  State = prs[-1]
  if City = prs[-2]
     @cname = "#{City} #{State}"
   else
     @cname = "#{@OpenCName}"
   end
  @cname = @cname.tr(',',' ')
  sys.log("CName: #{@cname}")
  return @cname
end

begin
  sys.Log "** Call from #{req.Header.From} to #{req.URI.User} **"

 if sys.Out    # if outbound call
  num = req.URI.User.to_s        # Get a string copy of the number to dial

  num = SPEED_DIAL[num] || num   # Substitute with speed dial entry, if any

  case num
    when /@/ then sys.Dial num   # URI dialing
    when /^[2-9]\d{6}$/          # Local call, 7-digit number
      num = '1'+ AREA_CODE + num # prefix it with country and area code
    when /^[01]?([2-9]\d{9})/    # US number with or without country code
      num = '1' + $1             # add country code and truncate number to 10-digit
    when /^(011|00|\+)(\d{9,})/  # international number
      num = '+' + $2             # GoogleVoiceCall works with '+' prefix only


    else sys.Respond 603, 'Wrong number, check & dial again'
  end

  sys.Log "Calling #{num} via Google Voice"
  sys.GoogleVoiceCall GV_USER, GV_PASS, CB_NUMBER, num, '.*', CB_NUMBER =~ /^1747/ ? 7 : 1, 30

else          # sys.Out

  CID = req.Header.From.FromURI.User
  CID = "#{$1}" if CID =~ /^1(\d{10})$/                         #   Remove leading "1"

#  CID = "xxxxxxxxxx"
  sys.log("CallerID:   #{CID}")

  if !(@cname = TNAME[CID]) && CID =~ /^([2-9]\d\d[2-9]\d{6})$/
     @cname = getcname CID
   end

  sys.log("CallerName: #{@cname}")

  sys.Dial("#{sys.Username}@local[fu=#{CID},fd=#{@cname}]",60)

end

rescue
sys.Log("** Error: " + $!) unless $!.to_s =~ /Thread was being aborted./
end

tyeske

I tried your script and edited my info. I can make outgoing calls, but can't receive and incoming calls. I call from my cell phone and it rings 5 times and goes to VM. Here is the output from the SS console. Can you fix the script?

Monitor 00:58:23:655: basetype=console, ipaddress=*, user=XXXXX, event=*, request=*, serveripaddress=*, server=*, regex=.*.
DialPlan 00:58:40:029 sip1(3216): Using dialplan Working Simple Dial Plan 3-1-14 for In call to sip:XXXXX@sipsorcery.com.
NewCall 00:58:40:045 sip1(3216): Executing script dial plan for call to XXXXX.
DialPlan 00:58:40:092 sip1(3216): ** Call from "unknown" <sip:2066820185@66.54.140.46>;tag=as0a23d929 to XXXXX **
DialPlan 00:58:40:108 sip1(3216): CallerID:   2066820185
DialPlan 00:58:40:108 sip1(3216): WebGet attempting to read from https://api.opencnam.com/v2/phone/2066820185?format=text.
DialPlan 00:58:41:623 sip1(3216): Error in WebGet for https://api.opencnam.com/v2/phone/2066820185?format=text.
DialPlan 00:58:41:639 sip1(3216): CallerName:
DialPlan 00:58:41:639 sip1(3216): ** Error: undefined method `split' for nil:NilClass
DialPlan 00:58:41:639 sip1(3216): Dialplan cleanup for XXXXX.
DialPlan 00:58:41:904 sip1(3216): Dial plan execution completed without answering and with no last failure status.
DialPlan 00:58:41:904 sip1(3216): UAS call failed with a response status of 480.
Registrar 00:59:17:295 sip1(5520): Binding update request for XXXXX@sipsorcery.com from udp:97.116.165.126:5061, expiry requested 120s granted 120s.
RegisterSuccess 00:59:17:310 sip1(5520): Registration successful for XXXXX@sipsorcery.com from udp:97.116.165.126:5061, binding sip:XXXXX@97.116.165.126:5061;expiry=120.

azrobert

#15
This is a strange one.
It looks like opencnam fails when it tries to process CID 2066820185.
Because of this failure variable @OpenCName was set to null.
Then the Split command failed because of the null value.

I put CID 2066820185 in table TNAME, bypassing opencnam.

I set variable @OpenCName to "Unknown" before the WebGet.
This will prevent the Split command from failing if opencnam can't process another CID.
Find comment #  CID = "xxxxxxxxxx"
To test opencname un-comment it and change the x's to a real number.

Edit:
I also changed the WeGet from:
@OpenCName ||= sys.WebGet("https://api.opencnam.com/v2/phone/#{cid}?format=text",4)

To:
@OpenCName = sys.WebGet("https://api.opencnam.com/v2/phone/#{cid}?format=text",4)

The former will only work if @OpenCName is null.

azrobert

Check the WebGet I made another change.

tyeske

We're making some progress. I used your updated dial plan. Now I can make and receive calls. The incoming calls are still unknown unless I put them in TNAME. If I uncomment the CID = , I get whatever number I put in the "XXXXXXX". If that happens to be in TNAME, I get the name too.

I then tried your updated Webget and it broke again. I could no longer receive calls.

Still getting the 206 number though. It seems that Ipkall doesn't always send the correct number. It seems to be very intermittent. Does that make sense?

azrobert

Which version of WebGet works and
which version doesn't?

tyeske

#19
This one works. I saved it from your code before you changed it. It at least allows me to receive calls. The other one won't allow me to receive calls.

@OpenCName =~ sys.WebGet("https://api.opencnam.com/v2/phone/#{cid}?format=text",4)