Issue. I’m very new to coding and Rasa, so please forgive me if I use imprecise or incorrect terminology. I have been facing an issue when trying to fill and custom validate slots from button payloads inside a form action (I’ve had no issues with typed input). It seems that the button payloads are being passed literally to the slot. This in turns causes the validation action to treat it as invalid input. See below excerpts of 1) the form action in the domain file, 2) the slot definition in the domain file, 3) the relevant utterance and buttons in the domain file, 4) the custom validation action in the actions file and, 5) the debug log.
I have been able to work around the issue (see the end of this post), however I’m not sure if the workaround is sustainable, so would welcome any thoughts on getting button payloads right inside form actions.
- Domain (forms):
forms:
compare_price_form:
required_slots:
product:
- type: from_text
- Domain (slots):
slots:
product:
type: any
influence_conversation: false
- Domain (responses):
responses:
utter_ask_compare_price_form_product:
- text: Queres saber o preço mais baixo de qual produto da cesta básica?
buttons:
- title: Arroz
payload: /ask_price_product{{"product":"arroz"}}
- title: Feijão
payload: /ask_price_product{{"product":"feijao"}}
- Actions:
class ValidateComparePriceForm(FormValidationAction):
def name(self) -> Text:
return "validate_compare_price_form"
def validate_product(
self,
slot_value: Any,
dispatcher: CollectingDispatcher,
tracker: Tracker,
domain: DomainDict,
) -> Dict[Text, Any]:
listed_product = ['arroz', 'feijao']
if slot_value not in listed_product:
dispatcher.utter_message(text = f"Por enquanto só procuro o melhor preço de %s e %s . Mas vou ver se um dia adiciono isto!" % tuple(listed_product))
return {"product": None}
else:
return {"product": slot_value}
- Debug log:
Workaround. I have been able to get around the issue for now by stripping the button payloads down to the literal desired text input, however I can’t find any support for this approach in the documentation and am worried that it will cause unexpected issues down the line. Is this a valid approach or should I be trying something else? Any thoughts greatly appreciated! See below the workaround in the utterance and buttons in the domain file, which for now seems to work
Domain:
responses:
utter_ask_compare_price_form_product:
- text: Queres saber o preço mais baixo de qual produto da cesta básica?
buttons:
- title: Arroz
payload: arroz
- title: Feijão
payload: feijao