[asterisk-users] hwo to stok variable wiith menu
Dale Noll
dnoll at wi.rr.com
Tue Nov 29 19:48:19 CST 2011
On 11/28/2011 08:24 AM, salaheddine elharit wrote:
> thank you for your help
You are welcome.
> i would to ask you please, i want to store the phone number of the
> customer in the option_name column when he press 3 in context menu
> i have created a database "aheevacss" with user "aheevaccs" and
> password "aheevaccs" and also i have creatd a table in this database
> name of table test with two columns:
> option_name varchar(15)
> count int
> 1-how can i check if the app_mysql module compiled and loaded i use
> asterisk 1.4 and if not installed how can ido in order to install and
> loaded it
I saw in some other message threads, it looks like you are working out
getting the mysql connectivity working in 1.4. In this version, it is
an 'add on' that you have to download separately from the Asterisk
source tree. The instructions given by Warren Selby are correct.
When you do the 'make menuselect', you are presented with a menu with 5
options. Under 'Applications' you need to check app_addon_sql_mysql.
Under 'Call Detail Recording' select cdr_addon_mysql. Under 'Resource
Modules' check res_config_mysql. Exit from menuselect and type 'make'.
You probably do not need the res_config_mysql, but it does not hurt
anything to compile it.
Aslo as mentioned in another thread, you do need to have mysql-devel
package installed.
Then run 'make' and 'make install' and 'make samples'. This will build
the modules app_addon_sql_mysql.so, cdr_addon_mysql.so and
res_config_mysql.so and install them in /usr/lib/asterisk/modules. This
does not change any existing modules, just adds the new ones.
Start an Asterisk cli (asterisk -r) and issue the command 'module load
app_addon_sql_mysql'. This should load the module and the MYSQL app
will be available in your dialplan. To verify it is loaded, you can
issue the command 'module show like sql'
You should also check the /etc/asterisk/modules.conf file. There should
be a line that says 'autoload=yes'. If it says no, you will have to add
a line 'load => app_addon_sql_mysql' (do not include the quotes).
Note: If you want to load cdr_addon_mysql, you will have to add a 'load
=> cdr_addon_mysql' line as well. This file is read by asterisk at
startup, so after you restart asterisk for the first time after these
changes, make sure the module is loaded with the module show command.
> 2- can you please veify the menu below and tell me waht is wrong
> thanks and regards
> [default]
> exten => 529,1,Ringing()
> exten => 529,2,Wait(4)
> exten => 529,3,Goto(accueil,s,1)
>
> [accueil] ; définition d’un contexte pour l’accueil
> exten => s,1,SetGlobalVar(sounds_path=/var/lib/asterisk/sounds/)
> exten => s,2,Background(${sounds_path}welcome)
> exten => s,3,goto(accueil,s,1)
> exten => #,1,Goto(menu,s,1)
> exten => i,1,Playback(${sounds_path}erreur-saisie)
> exten => i,2,goto(accueil,s,1)
> exten => t,1,Goto(accueil,s,1)
> [menu]
> exten => s,1,Background(${sounds_path}menu)
> exten => 0,1,Goto(menu,s,1)
> exten => 1,1,Goto(appel,s,1)
> exten => 2,1,Goto(message,s,1)
> exten => 3,1,NoOp(User chose support option)
> exten => 3,n,MYSQL(Connect connid localhost aheevaccs aheevaccs aheevaccs)
> exten => 3,n,MYSQL(Query resultid ${connid} update test set count =
> count + 1 where option_name = 'support')
> exten => 3,n,MYSQL(Clear ${resultid})
> exten => 3,n,MYSQL(Disconnect ${connid})
> exten => 3,n,Goto(support,s,1)
> exten => s,2,goto(menu,s,1)
> exten => i,1,Playback(${sounds_path}erreur-saisie)
> exten => i,2,Goto(menu,s,1)
> exten => t,1,Goto(menu,s,1)
> [appel] ; définition d’un contexte pour le menu d’appel
> exten => s,1,Background(${sounds_path}appel)
> exten => s,2,WaitExten(10)
> exten => 0,1,Goto(menu,s,1)
> exten => 223,1,Dial(SIP/${EXTEN},20,tr)
> exten => i,1,Playback(${sounds_path}erreur-saisie)
> exten => i,2,Goto(appel,s,1)
> exten => t,1,Goto(appel,s,1)
> [message] ; définition d’un contexte pour la messagerie
> exten => s,1,VoiceMailMain(${CALLERIDNUM})
> exten => t,1,Hangup()
>
> [support] ; définition d’un contexte pour le support
> exten => s,1,GoToIfTime(09:00-17:00|mon-fri|*|*?s,4)
> exten => s,2,Playback(${sounds_path}no-relation-support)
> exten => s,3,Goto(menu,s,1)
> exten => s,4,Playback(${sounds_path}relation-support)
> exten => s,5,Queue(default)
> exten => t,1,Hangup()
In the [accueil] context, you call Background with the name of the file
to play, then immediately return to the top and play the message again,
and again and again. It will never stop until the caller hangs up.
Also, you are asking the caller to press the '#' key to get past the
welcome greeting before getting to the main menu. I would recommend
playing the welcome followed immediately by the Background() for the
menu. The call the WaitExten() to give the caller a chance to enter a
selection. The if a timeout or invalid entry occurs, go back to the
point where the menu is played. You should also think about a look so
that after a few failed attempts, you hangup the line and do not tie up
that channel.
To save the telephone number that you when option 3 is pressed, change
the MYSQL query line to be something like this:
exten => 3,n,MYSQL(Query resultid ${connid} insert into test (
option_name ) values ('${CALLERID(num)}'))
I noticed that in your dialplan, you have the database, username and
password the same, aheevaccs . However in your email, you spelled the
database "aheevacss". Probably a typo, but in case you have connect
errors, that is a place to look.
Dale
--
"The truth speaks for itself. I'm just the messenger."
Lyta Alexander - Babylon 5
More information about the asterisk-users
mailing list