1. Learn
  2. /
  3. Courses
  4. /
  5. Building Chatbots in Python

Connected

Exercise

Filtering with excluded slots

Now you're going to put together some of the ideas from previous exercises in order to allow users to tell your bot about what they do and do not want, split across multiple messages.

The negated_ents() function has already been defined for you. Additionally, a slightly tweaked version of the find_hotels() function, which accepts a neg_params dictionary in addition to a params dictionary, has been defined.

Instructions

100 XP
  • Define a respond() function which accepts a message, params, and neg_params as arguments.
  • Use the negated_ents() function with message and ent_vals as arguments. Store the result in negated.
  • Use the tweaked find_hotels() function with the params and neg_params dictionaries as arguments to find matching hotels. Store the result in results.
  • Initialize the params and neg_params dictionaries outside the respond() function and hit 'Submit Answer' to see the bot's responses!