Reputation: 35
I hope you're all having a good day.
I'm trying to make a dynamic quiz chatbot in dialogflow.
So, I have a user saying "Let's play a game". It'll then go to the intent and go into fulfillment. The fulfillment will then go into a method and get a list of dynamic questions from my database. There could be any number of questions. So, the bot will ask the first question and then it will wait for the user's answer and see if it's correct. Then it will ask the next question.
So the bot will firstly ask a question, However, I'm stuck at the part where the user will give an answer. Because I have no idea how to get the bot to listen to the user's answer after asking the first question, and go back into the right fulfillment method.
Because if the user answers with "blue", how will the chatbot know that the user is answering a question instead of just randomly saying blue?
Upvotes: 0
Views: 463
Reputation: 6800
You need to make use of contexts
.
When the intent is invoked and it fetch the list of questions from your database, you will also set an output-context
.
Then you will have to create one more intent which will be invoked when user is giving an answer. In this intent you will set same context in input-context
which you have earlier set in output-context.
This way, Dialogflow will know that user is giving an answer, not just randomly saying some words.
Context is the key in conversations.
Upvotes: 1