Asterisk We transfer the number of the caller when forwarding to mobile using SMS



Hello dear Khabrovites and amateurs of solutions based on Asterisk. In this article I want to share my experience in solving an interesting problem. It was necessary to make sure that when forwarding calls from one mobile / city number to another mobile, we would see the caller's number, and not our city number. But the fact is that telecom operators will not allow us to simply substitute their numbers when calling through their network (And really, it would be a real mess). But you can solve the problem by transmitting it via SMS message through a GSM modem.


What we have:
Server with FreePBX Distro FreePBX 2.11.0.0beta2.5 (Asterisk 1.8), Huawei E171 modem, several connected city lines, dialplan with redirection.

First, install the modem, transfer it to the desired mode. It is important to switch the modem to “only modem” mode:
HUAWEII http://huawei.mobzon.ru/instruktsii/25-instruktsiya-po-nastrojke-modem
ZTE http://www.yccy.ru/category/raznoe/346.html

Set up a program for sending SMS - Gnokii. Hereinafter I describe the actions for CentOS.

1. Be sure to put the dependencies:

yum install usbutils libusb1-devel tcl


2. Insert the modem and see how it was determined:

lsusb
Bus 002 Device 007: ID 12d1:14fe Huawei Technologies Co., Ltd.
So in the beginning the line looks.

3. In my distribution kit there was no package for building programs from source. We put Development Tools.

yum groupinstall "Development Tools"


4. Download the program to switch modem modes. Usb-modeswitch usb-modeswitch-data packages we take from here .

5. Unpack both archives and install in turn:

tar xvjf ...
make install


6. We distort the modem and check:

lsusb
Bus 002 Device 008: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard


So everything is OK and the modem will be determined every time as it should. If the line is the same as at the beginning, then go here .

The dmesg command will show us:

option 2-1.4:1.0: GSM modem (1-port) converter detected
usb 2-1.4: GSM modem (1-port) converter now attached to ttyUSB0
option 2-1.4:1.1: GSM modem (1-port) converter detected
usb 2-1.4: GSM modem (1-port) converter now attached to ttyUSB1
option 2-1.4:1.2: GSM modem (1-port) converter detected
usb 2-1.4: GSM modem (1-port) converter now attached to ttyUSB2


7. Install the repository for EPEL CentOS like this .

8. Install gnokii

yum --enablerepo=epel install gnokii gnokii-smsd


You can download the package: http://rpm.pbone.net/index.php3/stat/4/idpl/27788385/dir/redhat_el_6/com/gnokii-0.6.30-2.el6.i686.rpm.html
and the http dependency : //rpm.pbone.net/index.php3/stat/4/idpl/16859934/dir/redhat_el_6/com/libpcsclite1-1.4.0-9.el6.i686.rpm.html

9. Edit the config / etc / gnokiirc

[global]
port = /dev/ttyUSB0 
model = AT
initlength = default
connection = serial
use_locking = no
serial_baudrate = 115200


there may be a different port for different modems, it is necessary to find by brute force

10. We check the sending of SMS:

echo 'Bingo!' | gnokii --sendsms +79060000000


Now you need to allow the asterisk user to run gnokii from the dialplan. Since gnokii was installed under the root account, the asterisk user will not be able to start it. Edit the / etc / sudoers file with the visudo command (it is strongly recommended to use only visudo to edit the sudoers file):

add the line for the asterisk user:

asterisk ALL=NOPASSWD:/usr/bin/gnokii 


Save the file and exit.

Next, we need to implement the System () command in our dialplan to send CID to SMS. FreePBX, of course, will not allow us to edit extensions.conf and extensions_additional.conf, since he himself overwrites them all the time. But you can insert your edits into the plan using the extensions_override_freepbx.conf file, which we will do. You can simply find the desired context in the extensions_additional.conf file, copy its fragment into extensions_override_freepbx.conf and make your changes. I have an internal number 203 which is forwarded to the mobile number by SIP / trunk / phone_number. We will rule this part of the dialplan:

[ext-local]
exten => 203,1,Set(__RINGTIMER=${IF($[${DB(AMPUSER/203/ringtimer)} > 0]?${DB(AMPUSER/203/ringtimer)}:${RINGTIMER_DEFAULT})})
exten => 203,n,System(echo '8${CALLERID(num)}' | sudo gnokii --sendsms +79061234567) ; отправка номера
exten => 203,n,Macro(exten-vm,novm,203,0,0,0)
exten => 203,n(dest),Set(__PICKUPMARK=)
exten => 203,n,Goto(${IVR_CONTEXT},return,1)
exten => 203,hint,SIP/10000/778899
exten => Narva778899,1,Goto(from-internal,203,1)


Now, when making a call or forwarding to 203, an SMS will be sent with the number of the caller, taken from the CALLERID (num) variable directly to the mobile phone.

In the next article I want to talk about setting up a bunch of Asterisk and SugarCRM to display the number of the caller on the monitor screen of the CRM operator, for subsequent entry into the customer database. ( done )

Pls, throw karma if someone came in handy article.

Also popular now: