Decide next action based on DB search

Hello,

I want to develop a simple chatbot that gives information to the user about some restaurants in a certain city.

So, the user asks for some specifications (type of food, pricerange, area…), the system looks in a database that contains all the restaurants and returns the information.

I have created a custom action that handles such requests and makes the database query. Now my problem is: how do I decide the next action once I’ve done the query? For example, if the query returns 0 results I will have to send an utterance like “no restaurants were found”, if I find only one restaurant I will return the information of that restaurant, if I find a lot of restaurants I will have to ask the user to limit his/her search. Of course I could do all this by a set of rules in my code inside the custom action, but instead I would like a smarter way of doing that (aka machine learning). My idea is that once I’ve done the query, I return the result to the dialogue manager and based on that, it decides the best utterance to select, along with the entity values that I found in the db. Is that a way of doing that?

Thank you, Tiziano

Use forms

Don’t forms work by rules? Like, if X slots are missing go on asking the user for them until all slots are filled. However my question is how to automatically (without explicitly coding it) select the best answer based on a database query

Hi @tiziano, you can use Dynamic Form Behavior

Thank you for the answer. However I’m not sure this is what I’m looking for. With Dynamic Forms you can change the order or the amount of slots that are requested, but (for what I understood) you still have to code it manually! As in the example that you linked, where you need to specify that when the user said (s)he wants to sit outside then it will ask if (s)he prefers shade or sun. Instead I would like the system to learn it from the data, based on the db query. For example, if it saw in the data that every time that the query returns 0 results it selects the action “utter_NoRestaurants” then it learns to reproduce this behavior