netrxinc
asked on
Asterisk IVR - How to return to the top of the menu
I have created an IVR. The IVR prompts user to press 1 to confirm. I am using the READ() function to receive the input from the user and placing this value into a variable. Then I am using GotoIf to test the value of the variable. If the variable = 1, then I branch to another extention. I wanted to be able to loop back to prompting for input if any other key is pressed, but if the asterisk (*) key is pressed, I want to be able to return to the top of the IVR. From what I can see, READ() only works with numeric keys.
This is a sample segment of the dialplan:
[confirm]
exten => s,1,Playback(silence/2)
exten => s,n(menutop),Playback(hell o)
exten => s,n,SayDigits(${ORDNUM})
exten => s,n,Background(is-correct)
exten => s,n,WaitExten(,)
.
.
.
exten => 7,1,Playback(cancel-this)
exten => 7,n,SayDigits(${ORDNUM})
exten => 7,n,Read(CANCELORD,correct -press-1-p ress-star- return,1)
exten => 7,n,GotoIf($[ ${CANCELORD} = 1]?cancelit:)
exten => 7,n,GotoIf($[ ${CANCELORD} = *]?menutop:)
exten => 7,n,Goto(,7,1)
exten => 7,n(cancelit),DeadAGI(canc elit.php,$ {ORDNUM})
exten => 7,n,Goto(,hang,6)
exten => hang,1,Playback(thank-you)
exten => hang,2,Hangup()
exten => hang,3,Playback(tryagin)
exten => hang,4,SayDigits(${ORDNUM} )
exten => hang,5,Hangup()
exten => hang,6,Playback(cancelled)
exten => hang,7,SayDigits(${ORDNUM} )
exten => hang,8,Hangup()
I though I could try something like this:
exten => 7,1,Playback(cancel-this)
exten => 7,n,SayDigits(${ORDNUM})
exten => 7,n,Read(CANCELORD,correct -press-1-p ress-star- return,1)
exten => 7,n,GotoIf($[ ${CANCELORD} = 1]?cancelit:)
exten => 7,n,GotoIf($[ ${CANCELORD} != [0123456789] ]?menutop:)
exten => 7,n,Goto(,7,1)
So that if 1 is pressed it goes to the "cancelit" section. If any key not in the range [0-9] is pressed go to the "menutop" and then if any of the numeric keys are pressed loop back to the beginning of this section of the dialplan and prompt again. I could not figure out how to test for a range.
Thanks.
This is a sample segment of the dialplan:
[confirm]
exten => s,1,Playback(silence/2)
exten => s,n(menutop),Playback(hell
exten => s,n,SayDigits(${ORDNUM})
exten => s,n,Background(is-correct)
exten => s,n,WaitExten(,)
.
.
.
exten => 7,1,Playback(cancel-this)
exten => 7,n,SayDigits(${ORDNUM})
exten => 7,n,Read(CANCELORD,correct
exten => 7,n,GotoIf($[ ${CANCELORD} = 1]?cancelit:)
exten => 7,n,GotoIf($[ ${CANCELORD} = *]?menutop:)
exten => 7,n,Goto(,7,1)
exten => 7,n(cancelit),DeadAGI(canc
exten => 7,n,Goto(,hang,6)
exten => hang,1,Playback(thank-you)
exten => hang,2,Hangup()
exten => hang,3,Playback(tryagin)
exten => hang,4,SayDigits(${ORDNUM}
exten => hang,5,Hangup()
exten => hang,6,Playback(cancelled)
exten => hang,7,SayDigits(${ORDNUM}
exten => hang,8,Hangup()
I though I could try something like this:
exten => 7,1,Playback(cancel-this)
exten => 7,n,SayDigits(${ORDNUM})
exten => 7,n,Read(CANCELORD,correct
exten => 7,n,GotoIf($[ ${CANCELORD} = 1]?cancelit:)
exten => 7,n,GotoIf($[ ${CANCELORD} != [0123456789] ]?menutop:)
exten => 7,n,Goto(,7,1)
So that if 1 is pressed it goes to the "cancelit" section. If any key not in the range [0-9] is pressed go to the "menutop" and then if any of the numeric keys are pressed loop back to the beginning of this section of the dialplan and prompt again. I could not figure out how to test for a range.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So use the same logic, and test for the asteirsk (*) key first, then "1" for confirmation, then default to returning to exten=7,1
Asterisk is "a" for testing.
Asterisk is "a" for testing.
or at least I think it's "a".... you can always do a READ(THISVAR,1), then use NoOP to output what a DTMF asterisk is saved as when you stick it in a variable...
How about putting this portion of code into its own context and using background ?
* on your original code:
exten => 7,1,Goto(cancel-confirm,s, 1)
* then:
[cancel-confirm]
exten => s,1,Playback(cancel-this)
exten => s,n,SayDigits(${ORDNUM})
exten => s,n,Background(correct-pre ss-1-press -star-retu rn)
exten => s,n,WaitExten(10)
exten => s,n,Goto(s,1)
exten => 1,1,Goto(somecontext,exten ,cancelit)
exten => *,1,Goto(s,1)
exten => i,1,[put here what you want to do if anything else than * or 1 was pressed]
* on your original code:
exten => 7,1,Goto(cancel-confirm,s,
* then:
[cancel-confirm]
exten => s,1,Playback(cancel-this)
exten => s,n,SayDigits(${ORDNUM})
exten => s,n,Background(correct-pre
exten => s,n,WaitExten(10)
exten => s,n,Goto(s,1)
exten => 1,1,Goto(somecontext,exten
exten => *,1,Goto(s,1)
exten => i,1,[put here what you want to do if anything else than * or 1 was pressed]
ASKER
Thanks for your help. I tried to evaluate the asterisk (*) key as "a" or as *, I also used the NoOp and it displayed that I had entered *. In the end I did a series of cascading GotoIf statements for each value, and at the end had a Goto command to return to the top. It works.
Thanks again
Thanks again
nauliv:
That was a solution I thought of as well...but I didn't know if he had any context only variables in his dialplan code. Doing cascading logic saves the effort of having to store them as globals. Unless you have a better way?
That was a solution I thought of as well...but I didn't know if he had any context only variables in his dialplan code. Doing cascading logic saves the effort of having to store them as globals. Unless you have a better way?
ASKER