I want to create a chatbot where,
I have a branch of questions and answers like,
Q1. How are you
A1. - Fine.
- Good.
Q2. Do you like travelling?
A2 - Yes
- Absolutely
- I like it.
Q3. Did you ever use RASA chatbot?
A3 - Yes
- Almost 2 years.
now,
If I ask questions to the chatbot but miss some questions like forget to ask Q2, the chatbot will say that end of the conversion that I miss that questions,
After the chatbot say I miss some questions have to go throw all the questions from start again but,
When I ask those questions again the chatbot will give different answers than it gives 1st time.
Example: 1st time when I ask Q1 and Q3 it gives answers -Fine and -Yes but when 2nd time I go throw the process for Q1 and Q3 it has to give different answers than -Fine and -Yes.
Now my questions are,
yes, all three conditions are possible.
Please correct me as I understood your question,
I am adding follow solution as per the below understanding:
You want your assistant to ask How are you?
and end-user answers Fine/Good
,
and so as Q2 and Q3 do.
Solution
For this to work, you have to use forms in Rasa. Below is a simple example for using this functionality.
import os
from pathlib import Path
from typing import Any, Text, Dict, List
from rasa_sdk import Action, Tracker, FormValidationAction
from rasa_sdk.executor import CollectingDispatcher
from utils.utils import get_html_data, send_email
class ValidateContactUsForm(FormValidationAction):
def name(self) -> Text:
return "validate_contact_us_form"
def validate_name(
self,
value: Text,
dispatcher: "CollectingDispatcher",
tracker: "Tracker",
domain: "DomainDict",
) -> Dict[str, str]:
if value in ["Fine", "Good"]:
return {"name": value}
else:
# return {"name": None, "requested_slot": "name"}
return {"requested_slot": "name"} # to request the same slot again,
# assistant will ask same question again.
Note: return {"name": None, "requested_slot": "name"}
This will close the form and restart the whole form, in this case, the form has just one slot, if you have more slots you have to nullify them too.