问题
My objectives: Client(SIP phone, i use 3CX phone) dial to asterisk server, asterisk then connect with external relational database(not located in the same place with asterisk server), and if database response something, asterisk server play a voice file(predefined .gsm file) to response client.
What i already have: I have installed AsteriskNow in VirtualBox as a asterisk server, the client is using softphone to connect with Asterisk server in SIP channel. When the Client dial to asterisk server, the server can execute the dialplan.
My question: If i want asterisk server establish connection to external database, for example, MySQL. and access the request data, Do i need to let dialplan invoke AGI script to do that? If so, using creating AGI script in PHP is much easier to achieve? If not, what should do to connect mysql? Using ODBC?
Is it possible to manipulate the data in asterisk server using dialplan, not using other programming language? But it seems dialplan does not have complete syntax support like other programming language?
回答1:
you can use ODBC
on asterisk. even you can connect asterisk to Microsoft SQL Server
.
if you want to save log data on asterisk you can use CEL
or CDR
or you can recieve events by AMI
. but if you want to force asterisk to do a special task (dynamic) it's better that use AGI
. I hope it be helpful.
回答2:
Asterisk can use MySQL or other database to store billing information, but for your task -- playing various vice files you should use AGI. AGI is very flexible because you can use various languages and libraries you want. I use Python for my AGI scripts but others use C, Perl, Java. You will find examples in those languages on Asterisk wiki: http://www.voip-info.org/wiki/view/Asterisk+AGI
Of course from your AGI program you can connect to database or use HTTP/SOAP/REST to integrate with other software.
回答3:
No, you not need AGI script.
Most easy way is use of func_odbc(user defined sql functions via odbc) with dialplan.
btw, diallplan is full language like any other programming language. Anything can be done via dialplan only. But not all things effective and require alot of experience.
来源:https://stackoverflow.com/questions/12524035/how-to-integrate-asterisk-server-with-external-relational-database-like-mysql