Here is the Asterisk AGI to play Farsi numbers. The script is meant to play numbers as big as 1000, so for bigger numbers you need to do some simple modifications.
Category Archives: Asterisk AGI
CLID popup using Asterisk AGI and jquery
using cURL in Asterisk Dialplan
There are many times when you need to interact with external application within Asterisk dialplan. Using the cURL function of asterisk dialplan we can POST/GET whatever information we have to any URL.
Integration with external applications using AGI
Recently we had a customer that requested for integration with their CRM web application (based on .NET framework and MSSQL). They wanted to get the caller id of the caller and the number which they have called. Here is a simple approach to get this done. In this example, I have used AGI to get the CLID and channel number and then I use the cURL method of PHP to POST the 2 parameters to the URL on the other side.
How to interact with MySQL inside AGI
Reading from MySQL Database
The following AGI retrieves asterisk extensions from Asterisk database in MySQL and displays them as verbose.
handling AMI using phpagi-asmanager
AMI + phpagi-asmanager
AGI structure
Here is the basic structure of AGI
AGI Sample – MySQL + PHP + AGI
How to connect to MySQL database and read/write data
[ext-local-custom]
exten => *779,1,AGI(testAgi.php)
exten => *779,n,hangup
AGI Sample – Passing argument to AGI
How to pass argument from dialplan to AGI
Bellow I show a simple example:
Continue reading
AGI sample – currency converter using web service
Bellow is an AGI sample to convert currency using a web service:
Step 1) create an extension in /etc/asterisk/extensions_custom.conf
[ext-local-custom]
exten => *777,1,AGI(currency.php)
exten => *777,n,hangup()
Step 2) Create currency.php in /var/lib/asterisk/agi-bin
#!/usr/bin/php -q
answer();
//fetch the web service and store the result into $curr
$fromCurrency="USD";
$toCurrency="MYR";
$res=file_get_contents("http://www.webservicex.com/CurrencyConvertor.asmx/ConversionRate?FromCurrency=$fromCurrency&ToCurrency=$toCurrency");
$xml = new SimpleXMLElement($res);
$curr=$xml[0];
$agi->text2wav("Currency rate from $fromCurrency to $toCurrency is");
$agi->say_number($curr);
$agi->text2wav("Thank you");
$agi->hangup();
?>