Session Ready
Exercise

Creating SQL from natural language

Now you'll write a respond() function that can handle messages like "I want an expensive hotel in the south of town" and respond appropriately according to the number of matching results in a database. This is an important functionality for any database-backed chatbot.

Your find_hotels() function from the previous exercises has already been defined for you, along with a Rasa NLU interpreter object, which can handle hotel queries, and a list of responses, which you can explore in the Shell.

Instructions 1/2
undefined XP
  • 1
  • 2
  • Use the .parse() method of interpreter to extract the "entities" in the message.
  • Find matching hotels using the params dictionary and find_hotels() function.
  • Use the min() function to choose the right index for the response to send. In this case, n is the number of results.
  • Select the appropriate response from the responses list and insert the names of hotels using the .format() method.