Setting a bool slot using a form (template with buttons) - help please

I want to set a slot value using buttons, with the slot being of type bool.

This should then influence the story

It’s not being recognised, i.e. I’m getting a fallback response when I click either button

I’m not sure where my problem lies:

  • the payload for the button?
  • the slot type?
  • the logic in the slot_mappings for the actions?

Struggling to troubleshoot this. So grateful if anyone can point out where I’m going wrong?!

domain.yml

 slots:
   proceed:
    type: bool
 templates:
   utter_ask_proceed:
    - buttons:
      - payload: '/choose{"proceed": false}'
        title: no
      - payload: '/choose{"proceed": true}'
        title: no
    text: Do you want to proceed?

stories.md

* proceed 
    - proceed_form
    - form{"name": "proceed_form"}
    - form{"name": null}
    - slot{"proceed": "True"}
    - next_form
* stop
    - proceed_form
    - form{"name": "proceed_form"}
    - form{"name": null}
    - slot{"proceed": "False"}
    - exit

from proceed_form in actions.py

    def slot_mappings(self) -> Dict[Text, Union[Dict, List[Dict]]]:
        """A dictionary to map required slots to
            - an extracted entity
            - intent: value pairs
            - a whole message
            or a list of them, where a first match will be picked"""
        return {
            "proceed": [
                self.from_text(),
            ]
        }
1 Like

Hi there, I would suggest using from_intent here:

      - payload: '/affirm'
        title: yes
      - payload: '/deny'
        title: no
        return {
            "proceed": [
                self.from_intent(intent="affirm", value=True),
                self.from_intent(intent="deny", value=False),
            ]
        }

it is similar to the outdoor_seating slot in the form example here: Forms

and as a bonus, your user can type yes and no as well as clicking buttons to answer it!

Of course, you should have affirm and deny intents in order to let them type their answer as well.

Thanks. Changing to from_intent and in stories.md, changing:

\- slot{"proceed": "False"} to \- slot{"proceed": false} fixed it.

That works as well :slight_smile: