Hello, I want to fill a form that requieres a dynamic utter_ask message that depends on the previous answers. Is there any way to achive this? For example:
utter_ask_car_version:
- text: "F). Versión"
and the running form would look like:
F). Versión
V1
V2
…
in which the list lenght is variable and then select one option.
Since you’re using forms you probably know about slots, but maybe you need to read about custom actions.
The same way you should ask for a slot named my_slot in an utterance named utter_ask_my_slot, you could instead use a custom action named action_ask_my_slot (ref).
So, completely remove utter_ask_car_version, and, in actions.py, add the following:
class ActionAskCarVersion(Action):
def name(self):
return "action_ask_car_version"
def run(self, dispatcher, tracker, domain):
info = tracker.get_slot("info") # Replace "info" with the name of the slot you want to use to decide what to utter
if info = "ABC"
dispatcher.utter_message(text = f"F). Versión {info}")
elif info = "DEF"
dispatcher.utter_message(text = "Another answer")
return []
Of course this is just an example, you can do whatever you want inside a custom action!
Look at this action (line 844). It’s not an action to ask for a slot, but it does different things depending on the values of the slots topic_type, account_type, and service_type. The action is not complete at all and badly written, but the skeleton/logic is here.