how to reach an extension when dialing from PSTN

Place for developers to chat about the code
jay75
Posts: 26
Joined: Fri Jul 23, 2010 11:54 am

how to reach an extension when dialing from PSTN

Postby jay75 » Thu Jul 29, 2010 1:26 pm

Hello guys,
I have my account set and one sub account. now both work fine for dialing out and dialiing the extension between them work great using speed dial. but how can one call my PSTN line IPKALL number and reach like a voice message asking to dial the extension they wish to reach...for now it rings all of the registered account and sub accounts.
Is that possible with SS if not could you please provide some info how to acheive this with SS and any other outside resources.
Thanks you.

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

Re: how to reach an extension when dialing from PSTN

Postby MikeTelis » Thu Jul 29, 2010 1:40 pm

You definitely need a 3rd party media server. I'd suggest Tropo (and pay attention to Aaron's post in the blog)

jay75
Posts: 26
Joined: Fri Jul 23, 2010 11:54 am

Re: how to reach an extension when dialing from PSTN

Postby jay75 » Thu Jul 29, 2010 1:55 pm

Thank you Mike for the quick reply...

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

Re: how to reach an extension when dialing from PSTN

Postby MikeTelis » Thu Jul 29, 2010 2:11 pm

You're welcome! Tropo is free for developers. I think they will eventually change this policy but even if this happens, you won't need to pay for the whole duration of your incoming calls, because Tropo's work will be limited to less than a minute per call (that's what it takes to listen to the greeting and push extension selection button). That is, of course, if you employ Aaron's solution (in lieu of Tropo's transfer() method).

jay75
Posts: 26
Joined: Fri Jul 23, 2010 11:54 am

Re: how to reach an extension when dialing from PSTN

Postby jay75 » Thu Jul 29, 2010 4:16 pm

Hi Mike, thanks for the info but unfortunatly i can't get it to work.
i followed every step Aaron explained but no go.. here is what i have done so far:

created an Application on Tropo. linked to a file transfer.rb which contacins the following code:

Code: Select all

require 'java'

answer()
say "hello world"
log "Call-ID=" + $currentCall.getHeader("x-sbc-call-id")
svcURL = "https://www.sipsorcery.com/callmanager.svc/blindtransfer?user=MySSuserName&callid=#{$currentCall.getHeader("x-sbc-call-id")}&destination=hold";
url= java.net.URL.new svcURL
conn = url.openConnection
log "javaURL created"
stm = conn.getInputStream
transferResult = org.apache.commons.io.IOUtils.toString(stm)
log transferResult
say "http://202.6.74.107:8060/triplej.mp3" # Play some audio while transfer is being carried out.


and in SS i have a dial plan attached to my userName called transfer that contains the following:

Code: Select all

sys.Log "new icomming"
sys.Dial("9991MycompleteTPNumber@sip.tropo.com[fu=uniquexxxx]") #Not sure what i should put instead of uniquexxxx


if i dial out i get to the Tropo mp3 music.. obviously because the sys.Dial() is making the call ...

but when i dial into Tropo's number from a PSTN i hear the music and my SS dial plan never kickes in and when i check Tropo's Application Debugger i see that the callManager.svc is returning no Call-ID found...

Code: Select all

Call[xxxxxx->xxxxxxx] : <string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">Sorry the blind transfer could not be initiated, the Call-ID to transfer could not be found.</string>

what am i missing????

Thanks.

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

Re: how to reach an extension when dialing from PSTN

Postby MikeTelis » Thu Jul 29, 2010 4:45 pm

Are you forwarding calls to:

999xxxxxxx@sip-noproxy.voxeo.net

??? That's the trick (and if I remember it correctly, Aaron wrote about it somewhere in the comments) you can use to get custom SIP headers in your Tropo application.

jay75
Posts: 26
Joined: Fri Jul 23, 2010 11:54 am

Re: how to reach an extension when dialing from PSTN

Postby jay75 » Thu Jul 29, 2010 4:53 pm

The thing is when i call the Tropo PSTN number my SS dialplan never kicks in...i don't see anything in the event.

like i said the SS callmanager returns the no CallID found...back to Tropo...

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

Re: how to reach an extension when dialing from PSTN

Postby MikeTelis » Thu Jul 29, 2010 5:15 pm

Probably you didn't get the idea!

1. You call your own PSTN number (such as IPKall DID) and you receive this call on your SS SIP account.

2. You transfer it (with sys.Dial) to your Tropo application, using your application's SIP URI 999xxxxxxx@sip-noproxy.voxeo.net. Note that the application's settings will give you a different URI, 999xxxxxxx@sip.tropo.com but you shouldn't use it or else you won't get call-id (do not confuse it with caller ID!!!).

3. Your tropo application should ask the caller about extension he wants to call and then issue transfer request using Aaron's mechanism.

From Tropo's point of view, it will look like the caller just hung up. For the caller, it will be transferred to desired destination.

Gotcha? ;-)

jay75
Posts: 26
Joined: Fri Jul 23, 2010 11:54 am

Re: how to reach an extension when dialing from PSTN

Postby jay75 » Thu Jul 29, 2010 6:51 pm

LOL I knew i was going to confuse my self with all of these numbers laying around...
thanks for pointing that out...

now i have everything as it should i make the call to my IPKALL which routes to my account in SS, i see the call coming in in the event log and all i have in the dial plan is this:

Code: Select all

if sys.In               # If incoming call...
  sys.Log "A Call is in"
  sys.Dial("9991mynumber@sip-noproxy.voxeo.net[fu=someuniquexxxx]")
end


Which calls my Tropo address,i see the call coming into my tropo through the application debugger, but the nothing happens on my phone it just keeps ringning... eventhough tropo shows the .mp3 playing....
here is the code in tropo

Code: Select all

#ruby
answer()
require 'java'
wait (350)
options = { :choices => '[1-20 DIGITS]', :terminator => '#' }
result = ask 'Please enter your number then press pound', options
say "Thank you."
log "Call-ID=" + $currentCall.getHeader("x-sbc-call-id")
svcURL = "https://www.sipsorcery.com/callmanager.svc/blindtransfer?user=mySSUserName&callid=#{$currentCall.getHeader("x-sbc-call-id")}&destination=#{$currentCall.getHeader("x-sbc-my_special_info")}";
url= java.net.URL.new svcURL
conn = url.openConnection
log "javaURL created"
stm = conn.getInputStream
transferResult = org.apache.commons.io.IOUtils.toString(stm)
log transferResult
say "http://202.6.74.107:8060/triplej.mp3" # Play some audio while transfer is being carried out.



now what is wrong.

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

Re: how to reach an extension when dialing from PSTN

Postby MikeTelis » Thu Jul 29, 2010 7:47 pm

At a glance, I don't see anything wrong. Tropo must answer your call (so that your phone stops ringing) and then you should hear "Please enter your number then press pound" prompt. As far as I understand, it doesn't happen.

I've had quite a number of troubles with ask(), mainly because it needs :onHangup and :onBadChoice handlers. Here is a piece of my code, you may find it useful:

Code: Select all

      result = ask question,
            :repeat        => 3,
            :timeout       => 5,
            :choices       => "1,2",
            :minConfidence => 0.45,
            :onHangup      => lambda {|event| log "Hangup!"},
            :onBadChoice   => lambda {|event| say "Wrong choice!"}

      if result.name == "choice"
        case result.value
# ...

If I were you, I'd delete all the "transfer" stuff and tried calling your Tropo application by SIP or Skype directly. Debug the "answer ... ask" part; once you get it right, add the "transfer" code.


Return to “Developer Chat”

Who is online

Users browsing this forum: No registered users and 1 guest