session["last_intent"] ||= nil
session["users_name"] ||= nil
puts "Previous Intent #{session["last_intent"]}"
puts "Current Username #{session["users_name"]}"
puts "Current Problem #{session["current_problem"]}"
puts "User Zipcode #{session["zipcode"]}"
# this bit is important!!!
body = body.downcase.strip
if match(body, user_greetings)
if session["users_name"].nil?
session["last_intent"] = "find_name"
message = puka_greetings.sample + " What's your name?"
else
session["last_intent"] = "welcome"
message = "Hi, #{session["users_name"]}. Welcome back!" + " Is there something needin' a fixin'?"
end
elsif match(body, help_greetings)
session["last_intent"] = "emergency"
message = description + " What seems to be the problem? \n" + problem_list
elsif session["last_intent"] == "find_name"
session["last_intent"] = "saved_name"
session["users_name"] = body
message = "Nice to meet ya #{ body } 👋🏼! \n" + description + "Is there something needin' a fixin'?"
elsif session["last_intent"] == "saved_name" || session["last_intent"] == "welcome"
if is_affirmation? (body)
session["last_intent"] = "problem"
message = what_problem?
elsif is_negation? (body)
session["last_intent"] = "no_problem"
message = "Glad to hear, partner!"
else
message = error_response
end
elsif session["last_intent"] == "problem" || session["last_intent"] == "emergency"
session["last_intent"] = "pick_problem"
# stores problem
session["current_problem"] = body
message = pick_problem body
elsif session["last_intent"] == "pick_problem"
session["last_intent"] = "get_zipcode"
# stores location based on zipcode
session["zipcode"] = body
message = get_zipcode body
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .