Upgrade 3CX to v18 and get it hosted free!

SMS callback for Asterisk

Author image

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

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


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.