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();
?>
Continue Reading

How to install FreePBX bulk extension module in Elastix

How to install FreePBX bulk extension module in Elastix

Bulk extension is a fabulous module to mass edit extensions. It’s a lot more useful than the in built export/import extensions in Elastix.

Here is the way to install:

  1. Download the module from this link: http://freepbx.org/trac/browser/contributed_modules/release/bulkextensions-2.5.0.1.tgz
  2. copy this file to /var/www/html/admin/modules
  3. tar -xvfz bulkextensions-2.5.01.tgz
  4. go to Unembeeded FreePBX GUI > Module Admin
  5. find the module and follow with the installation instructions
Continue Reading

How to restrict certain extentions to call international numbers only

Custom Context

This is done using custom context module. If you’re using Elastix you must install this module (refer to Elastix witout tears)

Custom Contexts creates contexts that can be used to allow limited access to dial-plan
applications.
Features:

  • Allows for time restrictions on any dialplan access.
  • Allows for pattern matching to allow/deny.
  • Allows for failover destinations, and PIN protected failover.
  • This can be very useful for multi-tenant systems.
  • Inbound routing can be done using DID or zap channel routing, this module
  • allows for selective outbound routing.
  • Phones can be placed in a restricted context allowing them only internal calls.
Continue Reading