Skip to content

Weather Bot Meets Facebook Messenger!

Amitha R edited this page Oct 13, 2018 · 4 revisions

Bot on Facebook Messenger

  • Chatbot App ---- (Send & Receive API) --- Facebook Messenger ----> User Interface (phone,laptop, etc);

Process

  1. Create a Facebook Page
  2. Create a Facebook App
  3. Add the Messenger Platform to the app
  4. Code your chatbot / use as a service
  5. Link your chatbot app to the Messenger platform using webhooks.
  6. Test and Train
  7. Submit for Review

Express Server

  • Weather Bot (Server Instance) <------------> Facebook Messenger.
  • The bot requires a server instance to interact with the facebook messenger.
  • FBeamer - It is the interface being built for the Facebook Messenger platform.

Create a Facebook App

  • Facebook App -> My Apps -> Create a New App.
  • Product Dashboard - Messenger - setup.
    • Page Access Token
      • Token Generation -> Select a page - Authorise access.
      • Token is generated.
    • Verify Token (Register chatbot API on the Messenger platform)
      • webhooks are urls that accept get and post requests.
      • Verify Token Generation
        • In cmd
          • node
          • require('crypto').randomBytes(24).toString('hex')

FBeamer

  • Register Webhooks
  • Receive Messages from Messanger
  • Send text Messages
  • Send Image Messages

Registering Webhook b/w FB and Bot

  • Messenger [Register Webhook] --Get ---(mode - 'subscribe', verifytoken, challenge) ---> Bot [Receiver/send challenge] --- challenge --> Messenger.
  • The interaction between Messenger and Bot requires a webhook to be accessible over a HTTPS connection.
  • Inorder to setup HTTPS service locally require NGROK.

Messenger --- (https://something.ngrok.io) -----ngrok----- (http://localhost:3000) -----[webhook]-----> chatbot (local nodejs app).

  • Start the ngrok -> http 3000
  • In the facebook developers app - setup the webhook.
    • Webhook - setup webhook
    • Paste the ngrok url in the Callback URL.
    • Verify Token - copy the created one.
    • Subscription Fields - messages.
    • verify -> main page - complete.
    • cmd -> nodemon - "webhook registered".