How to enable WaitExten() to support multi digits?

If you observe my FreeWorldDialUp incoming calls context (shown below), you will notice I have configured my asterisk-1.4.19.1 with several extensions using a 4-digit number. The context of this FreeWorldDialUp incoming calls will play an IVR (this is where the caller is given an option to enter an extension number), check for CID number, transfer the caller to certain extensions based on his/her CID number, or set to wait until time out using the WaitExten() function. So far, so good with one exception that the caller can ONLY enter a single digit number while my extensions are all 4-digit numbers. Does anyone here know how to remedy this problem so that my callers can enter a 4-digit extension?

Here is my FreeWorldDialUp incoming context I used:

[code][incoming_calls_on_FreeWorldDialUp]
exten=>FWD,1,NoOP(Incoming: Free World Dial Up)
exten=>FWD,n,Macro(cid_grab_num)
exten=>FWD,n,GotoIf($[${INCID} != 666666]?:internal,1001,1)
exten=>FWD,n,GotoIf($[${INCID} != 777777]?:internal,1002,1)
exten=>FWD,n,Goto(incoming_calls_on_FreeWorldDialUp,announce,1)

exten=>announce,1,Background(if-u-know-ext-dial&otherwise&pls-stay-on-line)
exten=>announce,n,WaitExten()

exten=>i,1,Playback(pbx-invalid)
exten=>i,n,HangUp()

exten=>t,1,Playback(pls-hold-while-try)
exten=>t,n,Macro(extension,1003)[/code]

try using the Read() function to set a variable, then use a Goto incorporating that variable (instead of the WaitExten)

edit: hey, noticed we joined the same day!

Hi Mazilo

I do not see the ‘way out’ for the extension dialed.
After the very first digit dialed Asterisk sees that there is no route for such a number in the current context.

I suppose you need to add something like this:

include => internal

Thanks and I will be looking into this.

What a coincidence! :smiley:

Actually, I have the include=>internal on my /etc/asterisk/extensions.conf file and incoming calls from 666666 or 777777 do get forwarded to extensions 1001 and 1002, respectively. Of course, it my real dial-plan strings, I have used real CID numbers instead of 666666 and 777777.

As suggestion above, it looks like Read() is my only solution. I was hoping to be able to facilitate the WaitExten() function to do this task.

[quote=“mazilo”]Actually, I have the include=>internal on my /etc/asterisk/extensions.conf file and incoming calls from 666666 or 777777 do get forwarded to extensions 1001 and 1002, respectively. Of course, it my real dial-plan strings, I have used real CID numbers instead of 666666 and 777777.

As suggestion above, it looks like Read() is my only solution. I was hoping to be able to facilitate the WaitExten() function to do this task.[/quote]

You should have this include statement in this particular context. Alternatively you should have any other routing rule for the number dialed.
WaitExten() works fine for me.

Why don’t you check your debug? It should tell you a lot.

AndrewZ, did you mean your WaitExten() can detect more than one digit? If so, then that’s the answer what I have been looking for.

Yes, it can detect much more digits :wink:
Think about this function like it’s your extra keypad. It will ‘detect’ all the digits your pressed but the rest of the job should be done by your dialplan.

Let’s imagine you dialed in without the right caller id and you got the dialtone.
If you will try to manually dial for example 1001 then you will fail, because there is no rule in your current context which will handle such a number.

As I suggested before you may add include statement which will include another context where a suitable rule exists for _1XXX numbers for example.
Or you can add explicit rules to the current context, something like

exten => _1XXX,1,Macro(stdexten,${EXTEN},SIP/${EXTEN})

or

exten => _1XXX,1,Goto(internal,${EXTEN},1)

AndrewZ,

Actually I have [internal context in my extensions.conf file filled with several different lines. For instance, I have the following for echo test:

exten=>500,1,Noop(UnixTime) exten=>500,n,SayUnixTime(,EST5EDT) exten=>500,n,NoOp(demo-echotest) exten=>500,n,Playback(demo-echotest) exten=>500,n(echo),Echo() exten=>500,n,Playback(demo-echodone) exten=>500,n,Hangup()
The problem is the WaitExten() responded when it detected the 1st DTMF tone and did not let me to complete the numbers I want to reach, i.e. 500.

You should have this include statement in this particular context where you have your IVR configured and not only somewhere else in your file.

If you posted your entire context [incoming_calls_on_FreeWorldDialUp] then it’s definitely not there.

Hi AndrewZ,

I am not sure if we are talking about the same thing. The fact is these two GotoIf lines work with no problem to direct any incoming calls with a CID of 666666 or 777777 to extensions 1001 or 1002, respectively. Just to prove what you said has nothing to do with the problem I have encountered with WaitExten() being ONLY able to detect a single digit, I remove the GotoIf lines by commenting them as shown below. This way, an incoming call will reach the WaitExten() after the announcement. Then, I called my line and asterisk answered with an announcement of the message. After the announcement, I tried to dial 500. Right after I pressed 5, asterisk responded with a message saying that extension doesn’t exist before it gave me a chance to press 0 and 0 to complete my dialing of 500.

[code][incoming_calls_on_FreeWorldDialUp]
exten=>FWD,1,NoOP(Incoming: Free World Dial Up)
exten=>FWD,n,Macro(cid_grab_num)
;exten=>FWD,n,GotoIf($[${INCID} != 666666]?:internal,1001,1)
;exten=>FWD,n,GotoIf($[${INCID} != 777777]?:internal,1002,1)
exten=>FWD,n,Goto(incoming_calls_on_FreeWorldDialUp,announce,1)

exten=>announce,1,Background(if-u-know-ext-dial&otherwise&pls-stay-on-line)
exten=>announce,n,WaitExten()

exten=>i,1,Playback(pbx-invalid)
exten=>i,n,HangUp()

exten=>t,1,Playback(pls-hold-while-try)
exten=>t,n,Macro(extension,1003)[/code]
I will try to PM you my extension.conf file later on.

Just try to read either my posts or Asterisk’ output with some attention.

that extension doesn’t exist in your current context !!!

Which extension doesn’t exist? If you meant extension 500, it is there in my asterisk. I tried to dial 1001 or 1002 and asterisk responded with the same message once it detected the first digit (in this case 1). If I removed the comments on the GotoIf lines, extensions 1001 and 1002 are reachable directly if the caller’s ID is 666666 or 777777.

This is how we do it.

[code]
[acd-2600]

exten => s,1,Background(your wav file here)
;
; dial 0-9, *, #
;
; transfer to main hunt group
exten => 0,1,Goto(acd-7000,s,1)
; 1 = dial by name
exten => 1,1,Goto(acd-7001,s,1)
; 2 = ebay sales
exten => 2,1,Goto(acd-7002,s,1)
; 3 = sales
exten => 3,1,Goto(acd-7003,s,1)
; 4 = accounting
exten => 4,1,Goto(acd-7004,s,1)
; 5 = production
exten => 5,1,Goto(acd-7005,s,1)
; 6 = warehouse
exten => 6,1,Goto(acd-7006,s,1)
; 7 = RMA
exten => 7,1,Goto(acd-7007,s,1)
; * = start over
exten => *,1,Goto(s,1)
;
; exception processing
exten => t,1,Goto(s,1)
exten => i,1,Playback(invalid)
exten => i,2,Goto(s,1)
;
; extension was dialed
exten => 9321,1,Goto(NORRIS,${EXTEN},1)
exten => 9322,1,Goto(NORRIS,${EXTEN},1)
exten => 9323,1,Goto(NORRIS,${EXTEN},1)
exten => 9324,1,Goto(NORRIS,${EXTEN},1)
exten => 9325,1,Goto(NORRIS,${EXTEN},1)
exten => 9326,1,Goto(NORRIS,${EXTEN},1)
exten => 9327,1,Goto(NORRIS,${EXTEN},1)
exten => 9328,1,Goto(NORRIS,${EXTEN},1)
exten => 9329,1,Goto(NORRIS,${EXTEN},1)
exten => 9330,1,Goto(NORRIS,${EXTEN},1)
exten => 9331,1,Goto(NORRIS,${EXTEN},1)
exten => 9332,1,Goto(NORRIS,${EXTEN},1)
exten => 9333,1,Goto(NORRIS,${EXTEN},1)
exten => 9334,1,Goto(NORRIS,${EXTEN},1)
;[/code]

Hi Marco,

Thanks for your feedback. There are two problems:
[ol][li]Your exten codes use Background() and not WaitExten() function.[/li]
[li]I can only see your codes are capable of accepting a single and not multi digit number[/li][/ol]
I would like to configure an asterisk system with different extension numbers with different lengths, i.e. 12, 034, 741, 9999, 12345, etc. (you get the idea - random numbers with random lengths). I am hoping to use WaitExten() function to be able to pickup numbers entered by caller (during Or) once the announcement is done. If a caller enter a 3-digit extension, WaitExten() function should time out to pick up the entered number and transfer to the proper extension. This way, if the caller doesn’t know the extension number, s/he can’t just enter a guessed number to enter and expect to reach the extension.

It is capable of handling multidigit numbers. If you look below, you can see where it handles the call when one of the extensions is dialed. Yes, we use background as WaitExten can only accept a single digit. Functionally, this should give you what you need.

[quote=“BruceAtMaxup”]
we use background as WaitExten can only accept a single digit[/quote]

This is absolutely not true. I’m using 2-digit extensions and 5-digit speed-dials through my IVR without a problem.

Hi Bruno,

I still can’t see how your codes work; however, I appreciated your reassurance and will go to explore your scripts. Again, many thanks.

Give it a try. There’s one caveat: If you have an extension that begins with a digit that is a single digit selection, the call won’t transfer immediately as it is waiting to see if you are, in fact, entering an extension. So, in the example I posted, selecting 1,2,4,5,6,7 or * will transfer immediately, while pressing 3 will wait for a timeout.

To Andrew, you are correct. I was thinking about when we use read with the maximum number of digits set to 1.