SMS callback for Asterisk

this article was originally published in 1telecom.net

SMS Callback for Asterisk PBX
SMS callback allows you to eliminate dtmf detection problems and inconvenience when using a callback solution. In this section I will show a generic example for accepting SMS messages and using them as a trigger for asterisk callback call.
For the integration of the sms gateway with asterisk server we will use Hypermedia SMS Server module to accept the SMS messages and open url in which the asterisk manager originate command will reside.
Hypermedia SMS Server Configuration
edit smsgw.ini:

[general]
IP=192.168.9.2
Port=8878
OpenUrl=yes
Url=http://192.168.9.10/receivesms.php

Hypermedia SMS server will open the url http://192.168.9.10/receivesms.php for each incoming SMS. Do not forget to select allow SMS triggers for the modules in HMC.
Web page code
edit receivesms.php:
include "phpagi.php";
$callback_number = $_REQUEST['number'];
$destination_number = trim($_REQUEST['message']," ");
$unicode = $_REQUEST['unicode'];

$phone_number="";
$msg="";
if ($unicode=="8"){
$i=1;
while($i*4<strlen($destination_number)){
$str=substr($destination_number,4*$i,4);
//$str=substr($destination_number,4*$i+3,1);
if (substr($str,0,3)=="003"){
$msg=$msg.substr($str,3);
}
$i++;
}
$destination_number=$msg;
}

$agiManager = new AGI_AsteriskManager();
$manager = $agiManager->connect("192.168.9.10","user","pasword");
if (!$manager) {
syslog(LOG_ERR, "Connection to Asterisk Manager Failed");
die("Connection to Asterisk Manager Failed");
} else {
$astVariable=array (
"callback_number=".$callback_number,
"destination_number=".$destination_number,
);
$eventName="Originate";
$eventData['Channel']="sip/hmgw/$callback_number";
$eventData['Context']="hm_callback";
$eventData['Exten']="$destination_number";
$eventData['Account']="$callback_number";
$eventData['Callerid']="";
$eventData['Priority']=1;
$eventData['Timeout']="60000";
$eventData['ActionID']="";
$eventData['Variable']="dummyvariable=null\r\n";
foreach ($astVariable as $variable) {
$eventData['Variable'].="Variable: ".$variable."\r\n";
}
$agiManager->send_request($eventName,$eventData);
}


Asterisk Dialplan
edit extensions.conf and add the following:

[hm_callback]
exten => _X.,1,answer
exten => _X.,n,dial(sip/hmgw/${destination_number})

edit sip.conf and add the following for using HG trunk:


[hmgw]
type=friend
host=192.168.9.2
disallow=all
allow=ulaw
allow=alaw
insecure=very
context=default


more information about 1telecom solutions >>

Copyright © 2008 1Telecom Ltd


SMS Callback Software

  • MobiSnow VoIP SMS callback an android app enabled your regular Android phone to a SMS callback gateway. Small and easy application for VoIP Providers.

See also

this article was originally published in 1telecom.net

SMS Callback for Asterisk PBX
SMS callback allows you to eliminate dtmf detection problems and inconvenience when using a callback solution. In this section I will show a generic example for accepting SMS messages and using them as a trigger for asterisk callback call.
For the integration of the sms gateway with asterisk server we will use Hypermedia SMS Server module to accept the SMS messages and open url in which the asterisk manager originate command will reside.
Hypermedia SMS Server Configuration
edit smsgw.ini:

[general]
IP=192.168.9.2
Port=8878
OpenUrl=yes
Url=http://192.168.9.10/receivesms.php

Hypermedia SMS server will open the url http://192.168.9.10/receivesms.php for each incoming SMS. Do not forget to select allow SMS triggers for the modules in HMC.
Web page code
edit receivesms.php:
include "phpagi.php";
$callback_number = $_REQUEST['number'];
$destination_number = trim($_REQUEST['message']," ");
$unicode = $_REQUEST['unicode'];

$phone_number="";
$msg="";
if ($unicode=="8"){
$i=1;
while($i*4<strlen($destination_number)){
$str=substr($destination_number,4*$i,4);
//$str=substr($destination_number,4*$i+3,1);
if (substr($str,0,3)=="003"){
$msg=$msg.substr($str,3);
}
$i++;
}
$destination_number=$msg;
}

$agiManager = new AGI_AsteriskManager();
$manager = $agiManager->connect("192.168.9.10","user","pasword");
if (!$manager) {
syslog(LOG_ERR, "Connection to Asterisk Manager Failed");
die("Connection to Asterisk Manager Failed");
} else {
$astVariable=array (
"callback_number=".$callback_number,
"destination_number=".$destination_number,
);
$eventName="Originate";
$eventData['Channel']="sip/hmgw/$callback_number";
$eventData['Context']="hm_callback";
$eventData['Exten']="$destination_number";
$eventData['Account']="$callback_number";
$eventData['Callerid']="";
$eventData['Priority']=1;
$eventData['Timeout']="60000";
$eventData['ActionID']="";
$eventData['Variable']="dummyvariable=null\r\n";
foreach ($astVariable as $variable) {
$eventData['Variable'].="Variable: ".$variable."\r\n";
}
$agiManager->send_request($eventName,$eventData);
}


Asterisk Dialplan
edit extensions.conf and add the following:

[hm_callback]
exten => _X.,1,answer
exten => _X.,n,dial(sip/hmgw/${destination_number})

edit sip.conf and add the following for using HG trunk:


[hmgw]
type=friend
host=192.168.9.2
disallow=all
allow=ulaw
allow=alaw
insecure=very
context=default


more information about 1telecom solutions >>

Copyright © 2008 1Telecom Ltd


SMS Callback Software

  • MobiSnow VoIP SMS callback an android app enabled your regular Android phone to a SMS callback gateway. Small and easy application for VoIP Providers.

See also

Created by: liorm, Last modification: Sun 06 of Apr, 2014 (23:19 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+