TXT

sms-callback

By Leonard Wells,2014-04-14 10:08
18 views 0
SMS Callback for Asterisk PBX

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

     $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

Report this document

For any questions or suggestions please email
cust-service@docsford.com