blueprint:
  name: Ask a Yes/No question
  description: |
    Ask a simple Yes/No question. Supports 50 different ways of confirming or rejecting the question. Supports retries.
  domain: script
  author: JLo
  homeassistant:
    min_version: 2025.6.99
  input:
    question:
      name: Question
      description: The question that will be asked by the voice assistant.
      selector:
        text:

    yes_section:
      name: Confirmation ('Yes', 'Of course', ...)
      description: Define what should happen if you reply positively to the question asked.
      icon: mdi:play
      input:
        yes_actions:
          name: Actions
          description: Actions to perform if you reply positively to the question asked.
          default: []
          selector:
            action:
        yes_answer:
          name: Answer
          description: Answer of the voice assistant if you reply positively to the question asked.
          default: "Done"
          selector:
            text:

    no_section:
      name: Rejection ('No', 'Negative', ...)
      description: Define what should happen if you reply negatively to the question asked.
      icon: mdi:stop
      input:
        no_actions:
          name: Actions
          description: Actions to perform if you reply negatively to the question asked.
          default: []
          selector:
            action:
        no_answer:
          name: Answer
          description: Answer of the voice assistant if you reply negatively to the question asked.
          default: "Action cancelled"
          selector:
            text:

    other_section:
      name: Other responses
      description: Define what should happen if the response is not understood.
      icon: mdi:help
      collapsed: true
      input:
        other_actions:
          name: Actions
          description: Actions to perform if the response is not understood.
          default: []
          selector:
            action:
        other_answer:
          name: Answer
          description: Answer of the voice assistant if the response is not understood.
          default: "Sorry, I couldn't understand that"
          selector:
            text:

    repeat_section:
      name: Advanced parameters (Retries)
      description: Define how many times the question should be asked if the answer is not understood.
      icon: mdi:cog
      collapsed: true
      input:
        number_of_retries:
          name: Number of retries
          description: Number of times the question should be re-asked if the answer is not understood.
          default: 0
          selector:
            number:
              min: 0
              max: 10
              mode: slider

fields:
  voice_assistant:
    name: Voice assistant
    description: The voice assistant that will be used for that conversation.
    required: true
    selector:
      entity:
        multiple: false
        filter:
          - domain: assist_satellite
  preannounce:
    name: Preannounce
    description: Play a sound before the question is asked.
    required: true
    default: true
    selector:
      boolean:

sequence:
  - variables:
      number_of_retries: !input number_of_retries
  - repeat:
      sequence:
        - action: assist_satellite.ask_question
          continue_on_error: true
          data:
            question: !input question
            preannounce: "{{preannounce}}"
            entity_id: "{{voice_assistant}}"
            answers:
              - id: "yes"
                sentences: 
                  - "Yes"
                  - Yes please
                  - Yes thank you
                  - Sure
                  - Absolutely
                  - Go ahead
                  - Please do
                  - Of course
                  - That's fine
                  - Do it
                  - Yep
                  - Yeah
                  - Ok
                  - Okay
                  - Affirmative
                  - I agree
                  - Sounds good
                  - You got it
                  - Definitely
                  - By all means
                  - Why not
                  - Indeed
                  - Confirmed
                  - Let's do it
                  - Certainly
                  - Right
                  - Fine
                  - All good
                  - Make it so
                  - I approve
                  - That's right
                  - I'm okay with that
                  - No problem
                  - Go for it
                  - Sounds fine
                  - I'm on board
                  - Proceed
                  - It's a yes
                  - I'm in
                  - Okay yes
                  - That's a yes
                  - Yeah go ahead
                  - I'm good with that
                  - Positive
                  - Do that
                  - It's okay
                  - Works for me
                  - I'm fine with that
                  - Yep do it
                  - Please go ahead
                  - That's what I want
                  - Exactly
              - id: "no"
                sentences: 
                  - "No"
                  - Nope
                  - Don't
                  - Please don't
                  - Please no
                  - No thank you
                  - I don't think so
                  - Not now
                  - That's a no
                  - I'd rather not
                  - No way
                  - Not really
                  - Cancel that
                  - Negative
                  - Stop
                  - Don't do it
                  - I said no
                  - No need
                  - Never mind
                  - Not necessary
                  - No that's not right
                  - I disagree
                  - Skip it
                  - Don't proceed
                  - I don't want that
                  - Don't go ahead
                  - Leave it
                  - That's incorrect
                  - I prefer not to
                  - No thanks
                  - I'm not okay with that
                  - I'm saying no
                  - Let's not
                  - Not this time
                  - I'm not in
                  - Please don't do that
                  - Don't take action
                  - I'd say no
                  - No action needed
                  - I'm against that
                  - I'd skip it
                  - Rather not
                  - Not today
                  - I'm not sure better not
                  - That's not what I want
                  - That won't be necessary
                  - I don't agree
                  - No that's wrong
                  - Let's skip that
                  - I'm not comfortable with that
          response_variable: response
        - choose:
            - conditions:
                - condition: template
                  value_template: "{{response.id == 'yes'}}"
              sequence:
                - sequence: !input yes_actions
                - action: assist_satellite.announce
                  metadata: {}
                  data:
                    message: !input yes_answer
                    preannounce: false
                  target:
                    entity_id: "{{voice_assistant}}"
            - conditions:
                - condition: template
                  value_template: "{{response.id == 'no'}}"
              sequence:
                - sequence: !input no_actions
                - action: assist_satellite.announce
                  metadata: {}
                  data:
                    message: !input no_answer
                    preannounce: false
                  target:
                    entity_id: "{{voice_assistant}}"
          default:
            - sequence: !input other_actions
            - action: assist_satellite.announce
              metadata: {}
              data:
                message: !input other_answer
                preannounce: false
              target:
                entity_id: "{{voice_assistant}}"
      until:
        - condition: template
          value_template: "{{ (response is defined and response.id in ['yes','no']) or repeat.index > number_of_retries}}"
