Handset control of your forwarding of incoming calls

Catalog of dial plans
Post Reply
mnipp
Posts: 192
Joined: Sat Oct 03, 2009 9:48 am
Location: NSW Australia

Handset control of your forwarding of incoming calls

Post by mnipp » Tue Sep 21, 2010 9:28 am

dial ***1 to forward incoming calls to sip:music@iptel.org
dial ***2 to forward incoming calls to your mobile
dial ***8xxxxxxxx to forward incoming to this number xxxxxxxx with ptel
dial ***9xxxxxxxx to forward incoming to this number xxxxxxxx with mynet
dial ***0 to return to no forward setting

place at the start of your outplan

Code: Select all

# if dialled *** store the number after it.

case req.URI.User.to_s

  when /^\*\*\*([0-9]+)$/ 
       sys.DBWrite("forwardto","#{$1}")
       sys.Dial("early_music@iptel.org",8) # some music to say the number was stored.
       sys.Respond(486, "Stored number")   # plus a busy signal
end

# start of your normal outplan
place into your inplan to set your destination for incoming calls

Code: Select all

case sys.DBRead("forwardto").to_s

  when '1'
       sys.Dial("music@iptel.org")    # forward to music only
       sys.Respond(480, "Not Available")
  when '2'
       sys.Dial("04.....@ptel")      # a preset for your mobile
       sys.Respond(480, "Not Available")
       
  when /^8([0-9]+)$/
       sys.Dial("#{$1}@ptel")    # will forward the call to the number after 8 on ptel
       sys.Respond(480, "Not Available")
       
  when /^9([0-9]+)$/
       sys.Dial("#{$1}@mynet[fu=09xxxxxx]")   # will forward the call to the number after 9 on mynet
       sys.Respond(480, "Not Available")
end

sys.Dial("#{sys.Username}@local") # default if no matches above like ***0
Last edited by mnipp on Sat Sep 25, 2010 3:17 pm, edited 3 times in total.
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)

jschwalbe
Posts: 28
Joined: Sun Jul 11, 2010 9:31 pm

Re: Handset control of your forwarding of incoming calls

Post by jschwalbe » Wed Sep 22, 2010 2:38 am

Very cool! Quick question: I was looking through the code trying to see how much I understand, and I wasn't able to see where dialing ***0 resets the dial plan.. I'm expecting a when '0' in case forwardtonum.. am I mistaken?


Also I'd like to contribute something that might be helpful if you want to use GV to forward to another phone:
dial ***7xxxxxxxx to forward incoming to this number xxxxxxxx with GV

Code: Select all

when /^7([0-9]+)$/
GV_USER = 'emailaddy@gmail.com'
GV_PASS = 'gvpass'
CB_NUMBER = '1747xxxyyyy'
sys.GoogleVoiceCall GV_USER, GV_PASS, CB_NUMBER, '#{$1}', '.*', CB_NUMBER =~ /^1747/ ? 7:1, 30
where CB_NUMBER is Gizmo # (or I guess any other number like sipgate, etc)

I haven't had time to try this as a whole (although the parts work separately). I'd be interested to know if this works for anyone.
edited to correct missing quote mark
Last edited by jschwalbe on Wed Sep 22, 2010 12:23 pm, edited 1 time in total.

mnipp
Posts: 192
Joined: Sat Oct 03, 2009 9:48 am
Location: NSW Australia

Re: Handset control of your forwarding of incoming calls

Post by mnipp » Wed Sep 22, 2010 2:45 am

***0 is simply a no match in the above code so incoming calls go through to the normal inplan below.

Your GoogleVoice looks Ok to me.
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)

mnipp
Posts: 192
Joined: Sat Oct 03, 2009 9:48 am
Location: NSW Australia

Re: Handset control of your forwarding of incoming calls

Post by mnipp » Wed Sep 22, 2010 2:57 am

Correction you are missing a quote mark:: '#{$1}', .*',
correct to:: sys.GoogleVoiceCall GV_USER, GV_PASS, CB_NUMBER, $1, ".*", CB_NUMBER =~ /^1747/ ? 7:1, 30
billion 7404VGP
dialplan (<9*:*>[0-9*][0-9*].T<:@sipbroker>|[0-9*].T)

Post Reply