Solved

Asterisk IVR - How to return to the top of the menu

Posted on 2010-08-15
7
1,154 Views
Last Modified: 2013-12-21
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(hello)
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-press-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(cancelit.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-press-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.

0
Comment
Question by:netrxinc
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 32

Accepted Solution

by:
DrDamnit earned 500 total points
ID: 33441388
Don't test for a range. Assume that if it isn't "1", then it should go back to menu top.

Change:
exten => 7,n,GotoIf($[ ${CANCELORD} = 1]?cancelit:)
exten => 7,n,GotoIf($[ ${CANCELORD} !=  [0123456789] ]?menut

to

exten => 7,n,GotoIf($[ ${CANCELORD} = 1]?cancelit:menutop)

You'll find that cascading logic is always easier in Dialplan coding.

If 1 then this...
if 2 then this....
if anything else, then this...
0
 

Author Comment

by:netrxinc
ID: 33441455
Originally I had used that logic.  But I want to be able to go to "menutop" only if the asterisk (*) key is pressed.  If any other key is press I want to return to exten=7,1
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 33441465
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.
0
Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

 
LVL 32

Expert Comment

by:DrDamnit
ID: 33441472
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...
0
 
LVL 7

Expert Comment

by:nauliv
ID: 33441641
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-press-1-press-star-return)
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]
0
 

Author Closing Comment

by:netrxinc
ID: 33441681
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
0
 
LVL 32

Expert Comment

by:DrDamnit
ID: 33445653
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?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linksys e2000 router 10 87
QoS needed if there's no contention on a link? 4 76
Cisco UCM licensing - do the unregistered count? 2 79
Change name on 7940 Cisco UM 10 67
Ever wanted to query Cisco Call Manager CDR records from MS SQL Server? Here's how! CUCM can be configured to upload a CDR file to a given FTP server every minute. This article will show you how to set this up, schedule the import of this data an…
Article by: user_n
How Sip Phone (User Agent) works and communicates with sip servers 1.  There is a sip server and a sip registrar.  The sip server and sip registrar can be one server or two different servers. The sip registrar is the server on which it is record…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question