How to let callers dial an extension


#1

Hi,
I am having a strange problem with a simple task.
I have two channels, a CAPI and a SIP channel. The CAPI connection to Asterisk is in T mode so when someone calls he comes in with an extension, 20 in my case. All I want to do is let this persion dial an extension and dial this extension via sip.
Code in extensions.conf:
[default]
exten => 20,1,Wait,1 ; Wait a second, just for fun
exten => 20,2,Answer ; Answer the line
exten => 20,3,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
exten => 20,4,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
exten => 20,5,BackGround(demo-instruct) ; Play some instructions
exten => 20,6,WaitExten ; Wait for an extension to be dialed.
exten => _X.,7,Dial(sip/${EXTEN}@sipgate,r)
exten => i,1,Playback(invalid) ; "That’s not valid, try again"
exten => #,n,Hangup ; Hang them up.
exten => t,1,Goto(#,1) ; If they take too long, give up

Effect, I get an “invalid” message right after the first digit I dial.
I tried with the s extension instead of 20 but it is not considered for some reason - it looks as if the incoming MSN is used first.
I hear the demo sound so I know the basic context gets chosen.
What am I doing wrong?
Thanks in advance


#2

Your _X. extension should start with priority 1, not 7: Its a new extension, remember… :wink:

WaitExten is actually a wrong commandname, it should be named WaitDigit !
Its only waiting for ONE digit… :unamused:

Two ways:

  1. "If you want to …press 1…if you want to…press 2"
    and then branch on THESE choices.

Or you need to addup a number.

There is a nice example which might help you, its easy to understand - so you can tune it to your needs:

So you need to do this:
Answer the call
Play info
wait for digit
tune the script that (e.g.) the # sign is causing the waitexten-script to start dialing, else wait for more digits to the given timeouts.

Dial
Have another script branch on the conditions of the outgoing call
like

exten => s,3,Goto(s-${DIALSTATUS},1)
; Jump based on status (NOANSWER,BUSY,CHANUNAVAIL,CONGESTION,
;ANSWER)

exten => s-NOANSWER,1,Wait(1)
exten => s-NOANSWER,2,Voicemail(uNoOfWhateverbox)
exten => s-NOANSWER,3,hangup

exten => s-BUSY,1,Wait(1)
exten => s-BUSY,2,Voicemail(uNoOfWhateverbox)
exten => s-BUSY,3,hangup

exten => _s-.,1,Goto(s-NOANSWER,1)
; Treat anything else as no answer

Richard


#3

[quote=“RichardHH”]1.
Your _X. extension should start with priority 1, not 7: Its a new extension, remember… :wink:
[/quote]
That was it!
Thanks!
And by replacing the 7 with the 1 it does exactly what I want i.e. add up numbers automatically and dial them once I don’t enter numbers anymore for 5 seconds.

This is strange, why does it work for me then?


#4

Because im an idiot and mixed up
WaitExten and the exit.digit funtion from a Queue (single digit).

Too much work…too less sleep, sorry - but happy it helped you anyway :smiley:


#5

I was unable to get the Waitexten() to do what I wanted. But I was able to do what I wanted by using Read() as I show in
forums.digium.com/viewtopic.php?t=5863