title: how to check whether a user signed in to facebook by clicking on "Send to Mesenger" button?
body: <p>I have a php page in which I am having a "Send to Messenger" button and a Submit button.</p>
  
  <p>If the user clicks on the "Send to Messenger" button, they will get logged in into their facebook account and they will get an automatic message from us. (These things are done through manychat).</p>
  
  <p>And if the user clicks on the Submit button, I have to check whether if the user clicks the"Send to Messenger" button and signed in to their facebook account. If only, then I have to insert the user into my database.</p>
  
  <p>May I know how to check whether the user clicks the "Send to Messenger" button as well as log in into their facebook account?  </p>
  
  <p>I am using the following code:</p>
  
  <pre><code>&lt;script src="//widget.manychat.com/my-page-id.js" async="async"&gt; &lt;/script&gt;
  &lt;body&gt;
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  &lt;script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&amp;version=v6.0&amp;appId='my-app-id'&amp;autoLogAppEvents=1"&gt;&lt;/script&gt; 
  &lt;div class="mcwidget-embed" data-widget-id="widget-id-from-manychat"&gt;&lt;/div&gt;
  &lt;script&gt;
  FB.Event.subscribe('send_to_messenger', function(e) {
        console.log("in function");
        console.log(e.event);
        console.log("button clicked");
        });
  }
  &lt;/script&gt;
  </code></pre>
  
  <ol>
  <li>"Send to Messenger" button is coming from manychat.</li>
  <li>I want to check when user clicks the "Send to Messenger" button, the event "e.event" is equal to "opt_in" so that I will know whether the user clicks the button as well as logged in.</li>
  <li>But the above code doesnt work. It Shows the error"FB is not defined".
  Please help.</li>
  </ol>