Dynamic menus

hi all…

what is the best way to write dynamic menus using the agi commands. like if i want to have something like:

exten => s,n, Background(one) ; press one if you want
exten => s,n, Festival(’$joe’);
exten => s,n, Background(two) ; press 2 if you want
exten => s,n, Festival(’$jane’)
etc…
exten => 1,1,Dial($joes_number)
exten => 2.1,Dial($janes_number)

the reason for this is that the options for the menu are always different amount and it is desired to avoid writing sound files on the fly which takes seconds and it might result in a weird pause and cpu usage on a heavly used machine, wheres files like ‘one’ and ‘two’ can be predone and use festival to spell out the names…

i can write the Background/Festival sequence using the agi EXEC i guess but how do i write the options (1,1…, 2,1…, 3,1… etc)? and if i use EXEC would those Background/Festival be executed in the order they were placed by the script?!

thanks…

design it with a database in mind.
use the MYSQL function from within the asterisk dialplan.
voip-info.org/wiki/view/Asterisk+cmd+MYSQL

it’ll also be easier to manage down the track, less maintenance and probably easier to document.

thanks… how is that going to help compared to the agi script that already connects to mysql and gets the results back?..

i just need them presented to the dial plan in an order and put after that the possible DTMF options… how would that be done using the mysql addon - something i dont thing this particular machine has installed…

thanks…

say you have your DB table look like this
company_id | menu_level | option | announcement

for the first level in the auto-attendant you may have
1001 | top | 1 | sales
1001 | top | 2 | accounts
1001 | top | 3 | service
1001 | sales-1 | 1 | quotes (sales)
1001 | sales-1 | 2 | tracking (sales)
1001 | accounts-1 | 1 | receivable (accounts)
1001 | accounts-1 | 2 | payable (accounts)
1001 | service-1 | 1 | enter your account id (service)

something like that where each tree in your auto-attendant/IVR would be the “menu_level”.

you’ll probably also need to set the channel variable for the current menu the caller is up to for the next query etc…

As for the AGI script vs dialplan MYSQL command. I’ve done work with both - i’m not a strong perl programmer yet (java & php for me) so when the job needs to be done quickly I just stick to my strengths.

I’m presuming quite a bit of what you are trying to do and it could have gone in the wrong direction slightly :wink:

i guess i didn’t explain myself well…

this is for a list of possible numbers to dial. like if i have a db with names and numbers for a particular caller. the agi script finds them and it needs to present them to the context in the dial plan that called it so that the user will hear all the options - lets say (this time) you have 5 possible numbers to dial. so it will basically give you the five options and the opportunity to dial 1 - 5 to get to one of them. the issue is that every time you call/are been called the number of those options might change and there is no a preset.

maybe i’m not undersatnding your examples… can you elabora te please?

thanks

how many people are we talking about that will call in?

how many people for each caller that calls in could they possibly talk to?

It definitely sounds like a DB job.
based on caller id, you’d have their options. Say:

  1. i wanted to talk to you
  2. my caller id is 555-1234.
  3. i can talk to three other people on monday
  4. i can talk to only you and someone from service on saturday

db table would look somethign like this: on monday
caller_id | option_num | ext_num | ext_person_name
5551234 | 1 | 100 | toshog
5551234 | 2 | 101 | fred smith
5551234 | 3 | 102 | foo bar
5551234 | 4 | 103 | jack press

on saturday

5551234 | 1 | 100 | toshog
5551234 | 2 | 105 | engineer bob

Is this what you had in mind?

So, in the dialplan
exten => s,1,festival(to speak with)
exten => s,2,festival(${RESULT FROM MYSQL}) ; e.g. toshog
exten => s,3,festival(press)
exten => s,4,festival(${RESULT FROM MYSQL}) ; e.g. one

somehow loop this little part for the amount of options that you have.

that is the main problem. how to do that? how do you write that to do dial plan either with mysql or agi script?

c’mon mate, use your head :wink:

lots of ways.

you can set a variable, and check it with the $[] expressions using a GotoIf statement.
Look in the doc directory of the asterisk source. There is a file called README.variables.
It is a VERY GOOD read.

e.g.
GotoIf( $[do_your_test]?exten,pri:exten,pri)

Check out the GotoIf command on the wiki - it’s quite a handy command.

I’ve got a busy morning, so read through that and experiment for a couple of hours.

What’s your background? Programming, sys admin, or just tinkering?

not just tinkering. but i’m fiarly new to asterisk and it’s logic. i have 2 jobs and sometimes helping a friend with asterisk for the last month or so - not always have time to read through all the documentation - if it wasn’t for voip-info i’ll be totally in the dark…

thanks for you input. i appreciate it…