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


(Phil) #1

People,

I have this chatbot set up:

   https://www.facebook.com/PhiRhoChat

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.

···

--
Philip Rhoades

PO Box 896
Cowra NSW 2794
Australia
E-mail: phil@pricom.com.au


(Hassan Schroeder) #2

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...

···

On Wed, Aug 8, 2018 at 3:19 AM, Philip Rhoades <phil@pricom.com.au> wrote:

Anyway, I want to add this Javascript stuff to the Ruby script somehow so
the FB analytics will work

--
Hassan Schroeder ------------------------ hassan.schroeder@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote


(Phil) #3

Hassan,

Anyway, I want to add this Javascript stuff to the Ruby script somehow so
the FB analytics will work

What "Javascript stuff"? What does it do?

Attached below:

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...

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>

···

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

On Wed, Aug 8, 2018 at 3:19 AM, Philip Rhoades <phil@pricom.com.au> > wrote:

--
Philip Rhoades

PO Box 896
Cowra NSW 2794
Australia
E-mail: phil@pricom.com.au