Lumimd Movie Chat Bot

Made by hongyuc

Creating a chat bot which can provide every information about movie to users. In addition, with the help of MovieDB API, this bot can help users to check the ticket information and help them to order the ticket.

0

Lumimd is a bot that can chat with you about anything of movie. You could get the basic information of movie once you tell it the movie name. In addition, it can also recommend you some current popular movies and assist you to order a ticket. In the future, I will add some different recommend methods to my bot. It will no longer only reply you after inputting the movie name. What I expected is that it can give you more options to set up conditions to search the movie you want, then it will recommend some expected movie to users. Also, I will apply googlemap api to locate the user's position. 

0
require "sinatra"
require 'sinatra/reloader' if development?
require 'twilio-ruby'
require 'spotlite'
enable :sessions

@client = Twilio::REST::Client.new ENV["TWILIO_ACCOUNT_SID"], ENV["TWILIO_AUTH_TOKEN"]


#moviedb api
url = 'https://api.themoviedb.org/3/search/movie?api_key=9ec125b878c86c1f6ce8ca3a234cda31&language=en-US&query=iron%20man'
response = HTTParty.get(url)
results = response["results"].first
title = results["title"].first
vote_average = results["vote_average"].first
popularity = results["popularity"].first
overview = results["overview"].first


configure :development do
  require 'dotenv'
  Dotenv.load
end

movie_name = String.new

get "/" do
	404
end


get "/sms/incoming" do
  session["last_intent"] ||= nil

  session["counter"] ||= 1
  count = session["counter"]

  sender = params[:From] || ""
  body = params[:Body] || ""
  body = body.downcase.strip

  if session["counter"] == 1
    message = "Hey there, I'm Lumimd. I can share any information about any movie!"
   elsif body[0] == "~"
        #findmovie
        #@movie = TmdbMovie.find keywords
        movie_name = body.delete("~")
        url = url + movie_name
        response = HTTParty.get(url)

        title = response["results"][0]["title"]
        vote_average = response["results"][0]["vote_average"]
        overview = response["results"][0]["overview"]
        vote_average = response["results"][0]["vote_average"]
        popularity = response["results"][0]["popularity"]
        answer = title + vote_average + popularity + overview

        message = answer.to_s

  elsif body[0] = "l"
    location = body.delete("l")
    url_location = "https://www.fandango.com/search?q=" + location + "&mode=general"
    message = "Here are some movies near" + location +". Reply the number you want to go." + url_location
  elsif body[0] = "d"
    date = body.delete("d")
    url_date = "  https://www.fandango.com/" + location + "movietimes?date=" + date
    message = "Here we get some shows on" + date + "at" + location + "Please check your tickets in this page." + url_location
  end

  session["counter"] += 1

  twiml = Twilio::TwiML::MessagingResponse.new do |r|
    r.message do |m|
      m.body( message )
      unless media.nil?
        m.media( media )
      end
    end
  end


  content_type 'text/xml'
  twiml.to_s

end
Click to Expand
0
x
Share this Project


About

Creating a chat bot which can provide every information about movie to users. In addition, with the help of MovieDB API, this bot can help users to check the ticket information and help them to order the ticket.

Created

October 19th, 2017