DevHeads.net

Ruby CGI script <=> Java chatbot server - need to run some Javascript code for FaceBook Analytics

People,

I have this chatbot set up:

<a href="https://www.facebook.com/PhiRhoChat" title="https://www.facebook.com/PhiRhoChat">https://www.facebook.com/PhiRhoChat</a>

and it stopped working sometime recently for NEW chats - I can't work
out why Messenger continues to work for my test FB account but not for
new chatters - there are alerts to get the app reviewed again although
under "App Review" it says: "Your app is currently live and available to
the public."

Anyway, I want to add this Javascript stuff to the Ruby script somehow
so the FB analytics will work so I might have a better chance of finding
out why NEW chats are not making it to the Ruby script . .

Is it possible?

Thanks,

Phil.

Comments

Re: Ruby CGI script <=> Java chatbot server - need to run some J

By Hassan Schroeder at 08/08/2018 - 12:47

What "Javascript stuff"? What does it do?

There are at least a couple of gems ("johnson" and "javascript") that
address incorporating JS into Ruby code. I've used the former but it's
~8 years unmaintained, and the latter also seems broken (on 2.5.1 at
least).

It might be easier to figure out what data the JS collects and ship that
back to the appropriate endpoint from Ruby...

Re: Ruby CGI script <=> Java chatbot server - need to run some J

By Philip Rhoades at 08/08/2018 - 23:48

Hassan,

On 2018-08-09 02:47, Hassan Schroeder wrote:

Attached below:

Yes, I was wondering if that were possible - the other thought I had was
that the code could be incorporated into cgi.header in my ruby script?

Thanks!
Phil.

<script>
window.fbAsyncInit = function() {
FB.init({
appId : '{your-app-id}',
cookie : true,
xfbml : true,
version : '{api-version}'
});

FB.AppEvents.logPageView();

};

(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>