Incoming dial plan

Support zone
Post Reply
TheGiant
Posts: 2
Joined: Wed Mar 16, 2016 1:25 pm

Incoming dial plan

Post by TheGiant » Thu Mar 17, 2016 5:10 pm

I'm working on incoming, and I know very little about Ruby, but so far, I have gotten this to work.

Code: Select all

sys.Log("New incoming call received to #{req.URI.User} from #{req.Header.From.ToString()}.")  

    sys.Dial("#{sys.Username}@local", 30)              		    # Ring logged in user.
    sys.Dial("17778008826@in.callcentric.com[fu=864236145]") # go to voicemail if no pickup.
But, what I would like to do, is a go a little farther, have it check if I am connected, and then if I am not, just dial the voicemail. How would I go about doing that?

Aaron
Site Admin
Posts: 4652
Joined: Thu Jul 12, 2007 12:13 am

Re: Incoming dial plan

Post by Aaron » Tue Mar 22, 2016 8:55 am

Well what you've got does exactly that. If there are no registered contacts for #{sys.Username}@local then the dial command won't generate any usable SIP addresses and the dialplan moves onto the next command.

If you really want to explicitly check whether an account has any registered bindings you can use the snippet below but note that doing this check won't make any difference as far as the "Dial" commands go.

Code: Select all

bindings = sys.GetBindings("#{sys.Username}", "sipsorcery.com")
if bindings != nil then
 bindings.each { |binding|
  sys.Log("binding contact=#{binding.ContactURI.ToString()}")
 }
end

Post Reply