Twilio Integration Problem

I am trying to integrate Twilio to send SMS notifications using this guide
https://www.open-emr.org/wiki/index.php/Short_Message_Service.

I have done all required changes and when I visit http://x.x.x.x/openemr/modules/sms_email_reminder/cron_sms_notification.php,
I receive the following error
Error in SMS authorization! (ERR: 108, Invalid or missing api_id)

Checking further, I can see the following at the end of /var/log/apache2/error.log when I visit the link

[Wed Dec 09 11:20:51.317933 2020] [php7:notice] [pid 3841] [client x.x.x.x:57122] PHP Notice: Undefined variable: argc in /var/www/openemr/modules/sms_email_reminder/cron_sms_notification.php on line 25 [Wed Dec 09 11:20:51.318489 2020] [php7:warn] [pid 3841] [client x.x.x.x:57122] PHP Warning: mysqli_query() expects at least 2 parameters, 1 given in /var/www/openemr/modules/sms_email_reminder/cron_sms_notification.php on line 41 [Wed Dec 09 11:20:51.318585 2020] [php7:warn] [pid 3841] [client x.x.x.x:57122] PHP Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, null given in /var/www/openemr/modules/sms_email_reminder/cron_sms_notification.php on line 42 [Wed Dec 09 11:20:51.318672 2020] [php7:notice] [pid 3841] [client x.x.x.x:57122] PHP Notice: Undefined variable: AccountSid in /var/www/openemr/modules/sms_email_reminder/cron_sms_notification.php on line 50 [Wed Dec 09 11:20:51.319012 2020] [php7:notice] [pid 3841] [client x.x.x.x:57122] PHP Notice: Undefined variable: AccountSid in /var/www/openemr/modules/sms_email_reminder/cron_sms_notification.php on line 98

I configured Twilio Account Sid, Twilio Auth Token and Twilio From name as per the guide and I can confirm that my Twilio account has enough balance.

OpenEMR Version
Version Number: v5.0.1 (6)

Browser:
Chrome & FireFox

Operating System
Mac OSX

Hi @Adam,

You have to create your account into Twilio to get access api_id or token then it will be going to work.

Thanks,
Nilesh

Thank you @Nilesh_Hake. I already did and filled relevant field as per the guide. Here is a screenshot for the configurations.

That cron should not be called like that. Look at cron source!
Go check out how my fax/sms module does this.


specifically:

Thank you Jerry, I was doing the manual run test as per the guide https://www.open-emr.org/wiki/index.php/Short_Message_Service:

  • Doing a manual run:

  • While you are testing the script, you may want to do a test-run of outgoing SMS’s instead of using CRON.

  • Set the SMS Notification Hours to 1

  • Make a test patient and use your own mobile/cell number in the Contact (use the number format: +CountrycodeAreacodeNumber (preceding + is important and there should be no spaces, hyphens or periods anywhere) ). Make sure you select ‘Yes’ for your test patient’s “Allow SMS” (in Demographics >> Choices).

  • Schedule an appointment for your test patient an hour away. Open the following URL: http://IP_NUMBER/openemr/modules/sms_email_reminder/cron_sms_notification.php(change IP_NUMBER in above command to IP Number of OpenEMR on which the twilio script is running).

  • If all’s OK, you should see something like what’s in the screenshot and you should receive the SMS(if your Twilio a/c has enough SMS credits).

I am not sure what action actually should I do. I am not a programmer myself and I will appreciate letting me know how to troubleshoot this.

Adam,

Did you get this to work?

Jeff

The Twilio SMS with my fax/sms module works pretty well once setup for notifications with manual and automated runs. You can test run available notifications before sending to patients.
I’m guessing the problem is there is not an install for 5.0.1 but i’d be willing to bet it would run on v5.0.1 with some command line magic for a manual install or I could allow install for v5.0.1 from composer with a minor change on the repository.
I know of several practices, including my practice, that uses in this way.

I am afraid not.

Thank you.

I contacted Twilio support and this was their response

Blockquote > looking into the code I can see that the SDK version which they are using is way old:

hxxps://github.com/bradymiller/openemr/blob/twilio_1/modules/sms_email_reminder/twilio/Services/Twilio.php#L25
modules/sms_email_reminder/twilio/Services/Twilio.php:25

const USER_AGENT = ‘twilio-php/3.10.0’;

The latest version is 6.15.0

Reference:

hxxps://github.com/twilio/twilio-php
twilio/twilio-php
A PHP library for communicating with the Twilio REST API and generating TwiML.
hxxps://www.twilio.com/docs/libraries/php

Also the API version:hxxps://github.com/bradymiller/openemr/blob/twilio_1/modules/sms_email_reminder/twilio/Services/Twilio.php#L31
modules/sms_email_reminder/twilio/Services/Twilio.php:31

protected $versions = array(‘2008-08-01’, ‘2010-04-01’);

Latest is API version is 2010-04-01.

I hope this information helps.

This was their answer to:

Can you please confirm that API url mentioned here and other Twilio parameters are correct
github.com/bradymiller/openemr/blob/twilio_1/modules/sms_email_reminder/twilio/Services/Twilio.php

Any help out there!

Thank you.

Did you ever get this to work? im currently trying to get this going and im getting this error as well

I never did get this to work.

Jeff

thank you for your reply, are you currently using any other solution for sms?

No, unfortunately, everything I found is very expensive.

Very disappointing to have lost this highly valuable resource when we “upgraded”.
Twilio is less than a penny per SMS text message (0.75 cents to be exact) and now it costs us $200 per month for phone minutes and labor time to make patient reminder calls. Is there no one out there willing to work with us to get this back?

@hitechelp are you saying that you’ve tried using @sjpadgett’s sms module which uses twilio and its not working for you? This thread seems to suggest the person is trying to do twilio on a older version of OpenEMR and can’t use the new sms module that Jerry Padgett put together?

Hi Stephen,

I appreciate your taking the time to respond in a timely manner. Thank you.

I need to install Composer which is apparently just the first step in many undocumented steps.
I read up on their site, but I don’t know which directory it must be installed in for OpenEMR use or which type (local vs global). And it seems we must use an old version (1.10.10) Ok but only if it’s secure.

I got this “How to” off the Composer site; My notes are in caps.

DO A PACKAGE UPDATE FIRST
sudo apt-get update
sudo apt-get upgrade

INSTALL COMPOSER DEPENDENCIES (IF NOT ALREADY INSTALLED)
sudo apt install curl php-cli php-mbstring git unzip

CD TO YOUR DESIRED INSTALLATION DIRECTORY
php -r “copy(‘https://getcomposer.org/installer’, ‘composer-setup.php’);”
php -r “if (hash_file(‘sha384’, ‘composer-setup.php’) === ‘756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”
php composer-setup.php --version=1.10.10
php -r “unlink(‘composer-setup.php’);”

I was hoping to find someone who’s got this working so I can get some answers.

There has to be more to getting this working than just using Composer to install Jerry’s module with;
composer require "openemr/oe-module-faxsms:2.2.0

I have no such module (registered or unregistered) in my “Manage Modules” tab in OpenEMR.

Thanks again,

David

What is the operating system of your OpenEMR installation. Are you using docker? Is this on Windows, Linux, Other? How familiar are you with information technology (IT) tasks?

Composer is a third party php software installer (called a package manager). It allows you to install 3rd party software packages that live on https://packagist.org/ Jerry’s SMS module is a 3rd party library that adds SMS functionality into OpenEMR.

Ubuntu 18.04 (LAMPS), OpenEMR v6.0.0 (1), not using docker. Would you recommend that I should?
I am a 30+ year Unix SysAdmin, and Information Systems Security Officer (US Navy retired)
I’ve been running OpenEMR since 2012 on multiple headless servers I built over the years.
I set up SMS Appointment Reminders back in 2013 on v4.1.1 using Twilio, but lost that functionality when we “upgraded” to v5.02 in May of 2020. Been struggling ever since to get it going again.

I don’t have much experience in PhP but I can usually make my way.

A lot of us are using the docker since it comes already with the tools such as composer installed, I don’t think you have to switch your installation but you may run into things from time to time like this where a tool needs to be installed.

Here is some documentation for installing and configuring the fax/sms module that Jerry wrote. Note the fax has been disabled by Twilio since the module was written: