Setting up TurboSMS in ABillS

I will give an example of setting up the TurboSMS service in ABillS, which I used to send Ureports reports to clients in Viber, as well as send Checkbox fiscal checks to Viber.

First of all, we conclude agreements with TurboSMS, register the name of the Viber sender in the TurboSMS panel.

In the /usr/abills/libexec/config.pl configuration, I specified +380 to the beginning of the number, and also that the number should consist of 10 characters, for example 0981234567:

$conf{SMS_NUMBER_EXPR} = '^0/+380;';
$conf{SMS_NUMBER}='[0-9]{10}';

Since all mobile phones were entered without +380 and once upon a time I specified a parameter that allows only 10 digits in the mobile phone field:

$conf{CELL_PHONE_FORMAT}='\d{10}';

Also specified more options:

$conf{SMS_CONTACT_ID} = '1';
$conf{SMS_TURBOSMS_VIBER} = 1;
$conf{SMS_TURBOSMS_VIBER_TOKEN}='ixnfo.com';
$conf{SMS_TURBOSMS_VIBER_URL}='https://api.turbosms.ua/message/send.json';
$conf{SMS_TURBOSMS_MESSAGE_HEADER}='IXNFO';
$conf{SMS_TURBOSMS_VIBER_COUNTRY_CODE}='38';
$conf{SMS_TURBOSMS_TRANSACTIONAL}='1';
$conf{SMS_TURBOSMS_DBHOST} = 'sql.turbosms.ua';
$conf{SMS_TURBOSMS_DBNAME} = 'users';
$conf{SMS_TURBOSMS_DBCHARSET}= 'utf8';
$conf{SMS_TURBOSMS_USER} = 'ixnfo.com';
$conf{SMS_TURBOSMS_PASSWD} = 'xxx';
$conf{SMS_TURBOSMS_TABLE} = 'ixnfo';
#$conf{SMS_TURBOSMS_SEND_TIME}= '12:00:00';
#$conf{SMS_TURBOSMS_SEND_FEES}=0;
#$conf{SMS_TURBOSMS_DEBUG} = 6;
$conf{SMS_TURBOSMS_SIGN}='IXNFO';
$conf{SMS_TURBOSMS_TTL}='28800';

$conf{UREPORTS_SKIP_ACTIVATE_SMS}=1;
#$conf{UREPORTS_ROUNDING}=1;
$conf{UREPORTS_ALLOWED_TYPES} = 'Viber';

$conf{EXTRECEIPTS_USER_CELL_PHONE}='1';
$conf{EXTRECEIPTS_SEND_USER}='Viber';
$conf{EXTRECEIPTS_EXT_RECEIPT_INFO}=1;

I also added tasks to /etc/crontab (the first one runs daily at 10 am to send Ureports reports, the second one runs every 30 minutes to get the status of messages, which can be viewed in the ABillS menu Reports – Alerts):

1 10 * * * root /usr/abills/libexec/ureports_sender.pl
*/30 * * * * root /usr/abills/libexec/billd sms_status

Messages from ABillS are sent as transactional, so before sending, you need to add message templates in the TurboSMS panel https://turbosms.ua/pattern.html, which are moderated for a couple of days.

Without a confirmed template in turbosms, the message will not be sent, and it will not be sent to the turbosms admin panel sent by Viber, there will be an error (but not always):

"response_status":"NOT_ALLOWED_MESSAGE_TRANSACTION_PATTERN"

Up to 500 characters are allowed in a Viber transactional message. You can’t pass a list in a variable, but only a few words, I don’t know the number, Viber determines it, but you can test it or ask the TubroSMS manager. But we sent dozens of words to the variable, there were no problems with this. Also, if nothing is passed in any of the variables, then the message can be sent as an advertisement, so something must be passed.

I will give examples of several of my templates, for example, for sending a link to a Checkbox fiscal receipt:

https://%1%.checkbox.in.ua/api/v1/receipts/%2%/png

Ureports Report #11:

You do not have enough funds to activate the next month's tariff.
Deposit: %1%
Credit: %2%
Subscriber monthly fee: %3%
Good day!

Ureports report #13 (I only send out this report):

Service ends in %1% days.
Monthly payment: %2%
On account: %3%
ID: %4%
Good day!

The template by which we sent applications to employees through a self-written system (in the variable after “Application text:” dozens of words were sent):

Application type: %1%
Application number: %2%
Address: %3%
Customer phone: %4%
Application text: %5%
Complete by %6%
Good day!

Application type: Service
Application number: 11278
Address: Zasullya str. Lisna, 290
Customer phone: 0670000000
Application text: Red light on the modem
Complete by June 15, 2022
Good day!

The default message lifetime (TTL) is 3600 (1 hour), after which, if the user is not in the Viber network, the message is considered undelivered and payment for the message is not charged, you can change the TTL by passing a different value via the API.

There was another case when the user had business messages disabled, he turned them on, but he did not see our sender in the blocked ones, even after a few days he did not receive messages, there was a NOT_ALLOWED_NUMBER_STOPLIST error. In the list of subscribers in the TurboSMS panel, I saw this user and that he unsubscribed on a certain date (when he received the first message, which he did not even see because business messages were disabled). I wrote to TurboSMS support about this and they removed it from their ignore list.

Also, once Viber had some problems and messages stopped sending, with the Rejected status, I wrote to TurboSMS support, they contacted Viber support and after a few hours the problem was solved.

There was also a case when there was an error connecting to the mysql server sql.turbosms.ua, turbosms support advised changing the username and password, after changing the username the database will be named the same as the username. After that, the connection was successful.

ABillS official documentation http://abills.net.ua:8090/display/AB/Sms
API documentation https://turbosms.ua/api.html

See my other articles about ABIllS
Script to send SMS via Goip4 gateway for ABillS

Leave a comment

Leave a Reply