PIONEERS Facebook Messenger Webhooks

DO YOU HAVE FACEBOOK MESSENGER INSTALLED ON YOUR MOBILE DEVICE?

  • YES

  • NO


Results are only viewable after voting.

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
15,247
Reaction score
2,670
Traditional SMS Messaging with Facebook Messenger



We've implemented a new SMS function in the latest build.

Syntax in Messenger:
Code:
sms 10-digit-SMS-number "Some message"
This requires a working Google Voice account and a working pygooglevoice implementation on an Incredible PBX platform. Google Voice need not be installed in Incredible PBX. You just need an account.

After installing the latest build from above, insert your Google Voice credentials for a working Google Voice account in .smssend. Then test the SMS functionality by issuing the following command from the Linux CLI:

Code:
/var/www/html/fb/.smssend 10-DIGIT-SMS-NUMBER "This is a test"
If the command fails, follow the instructions on the screen and immediately try again. Google has gotten picky about plain-text passwords. If you try several times with no success even after enabling the Google Voice password relaxer, then you might try reinstalling the latest pygooglevoice from here.

Until you get this working from the command line, the SMS command in Messenger won't work.
 
Last edited:

ABSGINC

You can call me Scott.
Joined
Oct 1, 2014
Messages
59
Reaction score
31
Location
Flint, MI
We've added a new "help" option to today's build......

That is very cool, never ceases to amaze me the possibilities.. @wardmundy & @Sylvain Boily have continued to provide great base examples in this proof of concept in communicating quickly with our PBX's. Thank you both very much! All open source and free so long as Facebook keeps it plugged in. I'm sure it will be just fine, withstanding possible version updates of facebooks graph api's, though this one seems like it will be around for at least a few years before depreciated as it's chat was just superseded by what were using now.

Time to get busy!
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
15,247
Reaction score
2,670
Hopefully, this will be the last manual update you ever have to apply. There's a new update command which, after loading today's release, will do all of the heavy lifting for you.

1. To get current, protect your existing config files and settings with chattr:
Code:
cd /var/www/html/fb
mv smssend .smssend
chattr +i  cli-message.php
chattr +i  config.inc.php
chattr +i .smssend
chattr +i .cli-call
2. Then download and install the latest tarball following the previous instructions.

3. If your FB Messenger implementation is not stored in /var/www/html/fb, edit .update and insert the correct directory to match your location.

4. Reset the chattr settings to default and reset fb directory ownership and permissions:
Code:
cd /var/www/html/fb
chattr -i  cli-message.php
chattr -i  config.inc.php
chattr -i .smssend
chattr -i .cli-call
chown -R asterisk:www-data /var/www/html/fb
chmod -R 775 /var/www/html/fb
After you get today's update installed, you can load new updates by typing update in Facebook Messenger. It won't hurt to run it more than once.

 
Last edited:

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
15,247
Reaction score
2,670
Just want to raise a SPECIAL ALERT FLAG FOR WAZO admins (only) integrating Facebook Messenger with your PBX. For whatever reason, Wazo runs some apps as asterisk and others (such as NGINX web server) as www-data. This differs from other deployments such as Incredible PBX and Issabel that run all tasks as asterisk. Normally, this doesn't cause problems on Asterisk platforms because the file owner/creator has read, write, and execute permissions. But, when you are integrating Webhooks into Asterisk servers running Wazo, it can be a headache if you're not careful about file permissions.

When new files are created, the default permissions are typically 755 or 744 meaning the Group account does not have write permissions to the files. In the Wazo design, www-data is the Group account holder which means that Messenger Webhooks cannot write or overwrite files unless you alter the file permissions outside of the webhooks environment, i.e. as the root user. This could be a major headache now that we have incorporated an update utility in the software because it would mean that attempts to replace index.php would fail unless you set the permissions on the fb directory and files correctly on the Wazo platform (only) to begin with. Here's how:

Code:
chown -R asterisk:www-data /var/www/html/fb
chmod -R 775 /var/www/html/fb
As part of the update process, since webhooks is operating as www-data user with Wazo, it means new files created as part of the update procedure will have www-data ownership. Therefore, we will make asterisk the group owner on the newly created files. This preserves the Wazo scheme, just backwards, while preserving the asterisk group setting used on other platforms. These generic commands will work on ALL platforms for newly created files generated by webhooks:
Code:
chown :asterisk index.php
chmod 775 index.php
 
Last edited:

krzykat

Guru
Joined
Aug 2, 2008
Messages
1,582
Reaction score
428
Location
South Florida
Yes! @krzykat I blogged about that exact problem and it's beautiful solution as it came to life on this fourm. Check it out!

https://absg.tech/blogged/

Tell a friend and encourage shared open source developments over additional 3rd party commercial API layers that also add an extra layer for security concerns, and someone help sponsor my Astricon admission. Whewww.
Hey - make this work with the SMS messaging from VoIP Innovations and I'll help sponsor your trip
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
15,247
Reaction score
2,670
@krzykat: Did you look at our .smssend script. There's only one line of bash code for Google Voice SMS messaging. Should be about the same for any other provider:
Code:
if [ -z "$2" ]; then
 echo 'Syntax: smssend 10-DIGIT-SMSNUMBER "SMS Message enclosed in quotes"'
 exit 0
fi

SMSNUM=$1
SMSMSG=$2


echo "Sending SMS message to: $SMSNUM"
gvoice -e $GVACCT -p $GVPASS send_sms $SMSNUM "$MSGSUBJECT: $SMSMSG"




And here's the PHP code for VoIP.ms SMS messages after adding their class.voipms.php component to the same directory:

Code:
$voipms = new VoIPms();

/* Send SMS */
$response = $voipms->sendSMS($SMSsender,$smsnumber,$smsmessage);
 
Last edited:

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
15,247
Reaction score
2,670
Enhanced Call Option. Beginning with the October 1 update which you can obtain by entering the update command in Messenger, you now have two calling options on some smartphone platforms. The call command still triggers an AsteriDex lookup on your PBX. But now... (1) you can click the dial button to place the outbound call through your PBX, or (2) you can click on the retrieved phone number link to place the outbound call using the client-side resource available on your mobile phone's Messenger platform, e.g. Facetime, Skype, or Google Hangouts. Depending upon your location, the second option may be preferable so long as it is a free call.

 

krzykat

Guru
Joined
Aug 2, 2008
Messages
1,582
Reaction score
428
Location
South Florida
Just thought of another excellent application of this. Conference room - alert who has arrived, left, and user count. You could even reply back "Freeze" to freeze the conference from any new users.
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
15,247
Reaction score
2,670
Just thought of another excellent application of this. Conference room - alert who has arrived, left, and user count. You could even reply back "Freeze" to freeze the conference from any new users.
FYI: You can control a number of ConfBridge functions for the Incredible PBX 2663 conference already using the ! shell command:

Code:
!asterisk -rx "confbridge [command] 2663"
Available commands are documented here.
 
  • Like
Reactions: ABSGINC

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
15,247
Reaction score
2,670
@wardmundy Is there going to be any ready made integrations for this with the new Incredible 13-13 ??
Just obtain your SSL certificate and then follow the existing tutorial here. Skip the first 6 Security steps which already are in place. Edit /usr/local/sbin/iptables-custom and uncomment the last 3 lines in the file. Then iptables-restart. Perform steps #7a and #9. Assuming the test shows your HTTPS is working properly, continue on with:

1. Installing Incredible PBX Webhooks Application

2. Hooking Up with Facebook

3. Outbound Call Setup for Facebook Messenger

4. Incoming Call Alerts with Facebook Messenger




 
  • Like
Reactions: ABSGINC

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
15,247
Reaction score
2,670
@wardmundy
Hi I would like to ask you what PBX is better to start this Project, as I would like to work with Incredible PBX it will be better with the upgrade Enchilada or without the upgrade?
Thank you very much for your time attention and help.
Enchilada provides enhancements. It doesn't limit functionality in any way.
 
  • Like
Reactions: Jose Pinto

trupsalms

Member
Joined
May 13, 2011
Messages
337
Reaction score
6
From ssl_error_log

PHP Parse error: syntax error, unexpected '[' in /var/www/html/fb/index.php on line 32
 

trupsalms

Member
Joined
May 13, 2011
Messages
337
Reaction score
6
Incredible PBX/FAX 13-13.7 Centos 6
Asterisk 13.22.0
Incredible 13.0.122.33
 

trupsalms

Member
Joined
May 13, 2011
Messages
337
Reaction score
6

ABSGINC

You can call me Scott.
Joined
Oct 1, 2014
Messages
59
Reaction score
31
Location
Flint, MI
@krzykat please help if you can https://pastebin.com/kwJZAgrq

I have got most steps in place, when i browse to https://siteexample.com/fb/index2.php, i receive a working webpage with ssl enabled and working however if i browse to https://siteexample.com/fb/, i receive: This page isn’t working (site)is currently unable to handle this request. HTTP ERROR 500, also when i check to see if the site is ssl, it says its not,working.
... it would probably respond to a browser request like that, as that URL is for Facebook to send specific requests that your files in that folder would process for it's BOT logic.

@wardmundy made some great examples and it's been an adventure marrying the concepts into the the existing open source projects we have floating around.

But you might need to brush up on your programming and also check out the Facebook Messenger tutorials on facebook's website.

You have to have a facebook developer account, valid tokens uploaded, also there is a good chance that the php logic that ward has in his example might not execute on the version of PHP you are running on your system, check out your logs in /var/log/httpd and look at the access and error, you might find that some of the php code array functions need to be defined differently as they won't interupert on your system. That's the best place to get started...
 
Last edited:
  • Like
Reactions: wardmundy

Members online

PIAF 5 - Powered by 3CX

Forum statistics

Threads
22,456
Messages
138,073
Members
14,620
Latest member
Brads#Bell