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.
This post shows a plain CLID popup.
download the zipped files
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.
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.
Reading from MySQL Database
The following AGI retrieves asterisk extensions from Asterisk database in MySQL and displays them as verbose.
Here is the basic architecture of AGI in php
How to connect to MySQL database and read/write data
[ext-local-custom] exten => *779,1,AGI(testAgi.php) exten => *779,n,hangup
How to pass argument from dialplan to AGI
Bellow I show a simple example:
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; $agi->text2wav("Currency rate from $fromCurrency to $toCurrency is"); $agi->say_number($curr); $agi->text2wav("Thank you"); $agi->hangup(); ?>