Save an incomming number to mysql

I’m very new to asterisk and mysql. I want to know how to save an incoming number (say {CALLERID(num)} ) to an IVR into mysql database. what modification should I do in extensions.conf?

Hi justyn!

You will need the Asterisk addon "asterisk-addons"

After that you will find the help you might need at this page:
Asterisk cmd MYSQL

Hope this gets you going!

Virtually yours // Nypon


As pointed out this is fairly straight forward using the mysql command, if for example you are storing it to a CRM you may want to look at using curl, some CRMS and CMS systems have a good API and this can be used, we have done both methods.

See This for an example on one way using an API

the simplest way is to use the asterisk system() application and run the mysql query
mysql --user=dbuser --password=‘mypass’ dbname -e 'INSERT INTO tbl_name (a,b,c) VALUES(1,23);

Tested and working

exten=>*59,3,system(/usr/bin/mysql --user=root --password=‘19r01r982’ asterisk -e ‘UPDATE users SET password="${idcaller}" where username=“kl”’;

If you need this information for statistics then why are you dont use CDR ?

Thank you so much…