How to use set boolean value for a FormAction


(Rakshit Singbal) #1

class ActionSearch(Action):

@staticmethod
def required_fields():
    return [
        EntityFormField("cuisine", "cuisine"),
        EntityFormField("people", "people"),
        BooleanFormField("vegetarian", "affirm", "deny")
    ]

def name(self):
    return 'action_search'

def submit(self, dispatcher, tracker, domain):
    results = RestaurantAPI().search(
        tracker.get_slot("cuisine"),
        tracker.get_slot("people"),
        tracker.get_slot("vegetarian"))
    return [SlotSet("search_results", results)]

(Akela Drissner) #2

Just as you’ve specified it. See more details here; http://rasa.com/docs/core/slotfilling/#slot-filling-with-a-formaction