Exercise

Refining your search

Now you'll write a bot that allows users to add filters incrementally, just in case they don't specify all of their preferences in one message.

To do this, initialize an empty dictionary params outside of your respond() function (as opposed to inside the function, like in the previous exercise). Your respond() function will take in this dictionary as an argument.

Instructions

100 XP
  • Define a respond() function that accepts two arguments - a message and a dictionary of params - and returns two results - the message to send to the user and the updated params dictionary.
  • Extract "entities" from the message using the .parse() method of the interpreter, exactly like you did in the previous exercise.
  • Find the hotels that match params using your find_hotels() function.
  • Initialize the params dictionary outside the respond() function and hit 'Submit Answer' to pass the messages to the bot.