Skip to content

MovieMate A chatbot that knows everything about movies!

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

Movie Mate - Smart (NLP) Chatbot

  • It uses the wit.ai services.

wit.ai

  • It was acquired in 2015 by Facebook.
  • Provides speech & text recognition and processing as a service.
  • Uses machine learning and natural language processing.
  • wit.ai - 40+ languages, large community, free for commercial applications as well.

Speech/Text -------> wit.ai --------> Entities (intent / other entities);

  • wit can be used directly over http.
  • It has ready to use SDKs for Ruby, Python and Nodejs.
  • Login in - your developed apps will be displayed on the dashboard.
  • In order to create new App - "+" , language, private/public.

wit.ai | Intent & Training

  • Click on the app -> understanding -> Create the intent and entities.
    • tell me about war of the worlds.
      • intent - movieinfo
      • movie - "war of the worlds" (entites)
      • validate
    • click on the entities - see all the training data.

Built-in NLP and wit.ai

  • Built-in NLP <------> FB Messenger <-------> Chatbot (Nodejs APP)
  • Built-in NLP automatically parse messages into fundamental entities.
    • Hi, I'll meet you tomorrow at 10 am.
    • entities:{ greetings: [{confidence: 0.9689, value: true}], datetime: [{confidence: 0.9509, value: 'Sun...}]}

wit.ai <---> Built-in NLP <---> FB Messenger (Query) <---> Nodejs chatbot App -> entities.

  • developers.facebook App - built-in NLP section - Turn it on.
  • wit.ai - settings - server access token - copy.
  • Back in developers.facebook App ---> built-in NLP section
    • select the page.
    • Paste Wit Token - save.

Extracting Entities

FB Messenger <---> FBeamer <--> Extract entity values <---> getMoviesData --(The MOVIE DB) -- getDirector() ---> createResponse --> FBeamer <--> FBMessenger

Movie Database Application

  • themoviedb
  • Sign up and login.
  • Profile -> Settings -> API
  • Generate the API Key -> by providing basic Info.
  • Insert the generated key in the (tmdb) config/development.json file.

Understanding the Movie API

  • Developers - themoviedb
  • For movies -> Search -> Search movies
  • GET / search/movie
    • Try it out tab
      • Variables: api.key -> insert the tmdb key generated previously.
      • Query String - Query - (Movie Name)
      • Send Request.
  • GET /movie/{movie_id}/credits

Summary

  • Built a simple Q&A chatbot.
  • Understood NLP helps build smarter chatbots.
  • Introduced to Wit.ai.
  • Used Movie DB to fetch movie related information.

Step for Review

Facebook Page Creation and App Id Generation Details

I. Creation of a Page

  • Facebook - create a page.
  • Choose the category - Business or brand.
  • Update the information accordingly - Test the button to update the messager chat.

II. Creation of Application Id

  • Facebook for developers - https://developers.facebook.com/;
  • MyApps - Add New App
  • Create a New App Id - Display Name , create App Id.
  • Developers Facebook Page opens - Messanger - Settings
    • Token Generation - Link the respective created page and generate the Access token.
      • In the code base - config/development.json file - page access token.
    • Verify Token Generation
      • In cmd
        • node
        • require('crypto').randomBytes(24).toString('hex')

III. Creation of Webhooks

  • Downloads Ngrok - Run it.
  • http E.g D:/.../ngrok http 3000
  • This generate url -> https://1332f745.ngrok.io;
  • Set up Webhooks
    • Callback URL - the generated url from ngrok.
    • Verify Token - generated crypto 24 byte token - config/development.json file.
    • Subscription field - messages.
  • Choose the Page (Movie Mate) -> Subscribe;

IV. Wit.ai (Natural Language Processing - Tool)

  • wit.ai homepage.
  • login - github, etc;
  • Create a new App

V. Movie Database Application

  • URL -> https://www.themoviedb.org
  • Sign up and login.
  • Profile -> Settings -> API
  • Generate the API Key -> by providing basic Info.
  • Insert the generated key in the (tmdb) config/development.json file.

VI. Understanding the Movie API

  • URL -> https://developers.themoviedb.org
  • For movies -> Search -> Search movies
  • GET / search/movie
    • Try it out tab
      • Variables: api.key -> insert the tmdb key generated previously.
      • Query String - Query - (Movie Name)
      • Send Request.
  • GET /movie/{movie_id}/credits

VII. Deploying it in Heroku Cloud

  • URL -> https://dashboard.heroku.com/login;
  • Create a free account -> go to the dashboard.
  • Install the Heroku CLI for windows.
  • URL -> https://devcenter.heroku.com/articles/heroku-cli
  • While Deploying on Heroku
    • package.json file -> remove the main key, mention the exact node version.
    • invoke the start, engine -> node engine.
    • delete app.js file as it not necessary.
    • create .gitignore file.
      • node_modules
      • config/development.json
    • Ensure to have git install.
      • In cmd -> git init
  • Login in to the heroku account from the cmd
    • heroku login
    • email id, password
    • git add , git commit, git push heroku master
  • Heroku offers cloud computing
    • heroku create
    • an app is created and a https link is also provided.
    • In the facebook developers page -> Webhooks
      • Edit Subsciption -> the https link, verify token.
  • Back to the Heroku Dashborad -> settings
    • reveal config var -> define the key values.
  • Test the chatbot of Facebook.
    • In case it doesn't work.
      • messanger - settings - [webhook]
      • select the page.
      • unsubscribe and then subscribe it.

VIII. Making an APP public on Facebook / Approval Process

  • URL -> Facebook.developers.com
  • App Review :
    • Face developers page
    • Messenger - settings - bottom part - review.
    • Click on Add to submission - show the required actions.
    • privacy policy - iubenda.com;
    • provide examples and complete the approval process.
    • On approval, click the slide -> turn on the chat bot and make it publically available.
  • Tester - add ppl to test the chatbot.