#Run Automations from 'Ask a question' response variable

1 messages · Page 1 of 1 (latest)

ancient fractal
#

I've created an automation that will ask me a yes or no question (using an assist satellite, HA voice preview edition). The answer is stored in a variable. I can't figure out how use an input_text helper to pull the answer/variable from that automation so I can use it as a trigger to run other automations. Should I create an input_text helper with the same name as the response variable? How do I get a differ automation trigger to 'notice' that the question was answered? Any help would be appreciated!

marble portal
#

I guess when one automation asks you, you give an answer and automation will get this answer. Then you can immediately do whatever this "yes/no" means, or you can store the result to the input_text helper and then trigger another automation

ancient fractal
marble portal
#

In your "yes/no" automation request, I guess there is a response variable, which gives you certain result

#

but why don't you simply receive a yes/no answer to the response variable, and then continue in the same automation with the activity according to the yes/no response? Use the if option

#

You also have an action for input_text.set_value to store the value to your input text helper, whatever the value is (yes/no) or (1/0)

ancient fractal
#

That would be ideal, honestly, where does the 'if' option need to go? Here's what it looks like so far

marble portal
#

can you share the yaml of the full automation you have so far?

#

the response variable should be "variable_name_type" text, no spaces, as it is a "programming" one.

ancient fractal
#

I haven't done anything in yaml, I'm pretty unfamiliar with it, how do I do that?

marble portal
#

top-right on the page, you have "show YAML"

#

and then copy it here, use the formatting with triple ` characters

ancient fractal
#

Got it, I haven't updated it to have underscores yet:

description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.everything_presence_one_5b2078_occupancy
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 1
conditions:
  - condition: state
    entity_id: input_boolean.automation_override
    state: "off"
actions:
  - action: assist_satellite.ask_question
    metadata: {}
    data:
      question: Good morning! Would you like to know what's on your agenda for today?
      preannounce: true
      entity_id: assist_satellite.home_assistant_voice_09bdfd_assist_satellite
      answers:
        - id: "Yes"
          sentences:
            - "Yes"
        - id: "No"
          sentences:
            - "No"
    response_variable: Morning Agenda Answer
mode: single
marble portal
#
actions:
  - action: assist_satellite.ask_question
    metadata: {}
    data:
      question: Good morning! Would you like to know what's on your agenda for today?
      preannounce: true
      entity_id: assist_satellite.home_assistant_voice_09bdfd_assist_satellite
      answers:
        - id: "Yes"
          sentences:
            - "Yes"
        - id: "No"
          sentences:
            - "No"
    response_variable: response_answer_hoes_here
  - if:
      - condition: template
        value_template: "{{ response_answer_hoes_here == 'Yes' }}"
    then:
      - action: light.turn_on
        metadata: {}
        data: {}
        target:
          entity_id: light.lights_all
#

See my actions part, First you execute the assist_satellite, and then you do another action just after, that is an if statement, depends on the value from previous.

#

A demo of my simple AI task that asks for data and gets the reply:

sequence:
  - action: ai_task.generate_data
    data:
      task_name: home summary
      instructions: >-
        Randomly select "yes" or "no" word and reply with a single word. use all
        lowercase
    response_variable: ai_response
  - action: system_log.write
    metadata: {}
    data:
      level: debug
      message: "{{ ai_response }}"
  - if:
      - condition: template
        value_template: "{{ ai_response.data == 'yes' }}"
    then:
      - action: light.turn_on
        target:
          entity_id: light.office_ceiling
    else:
      - action: light.turn_off
        target:
          entity_id: light.office_ceiling
alias: New script
description: ""
ancient fractal
#

I think I'm getting it. I'm trying to do this via the UI, so I've adjusted the response variable to be be Morning_Agenda_Answer
I'm adding a second action afterward that is if/then - so isthe Morning_Answer_Agenda an entity?

#

Sorry, I just have no idea how to interact with yaml 🙁

marble portal
#

No worries, let's go step by step.

#

this is an advanced topic.

ancient fractal
#

This would ideally be the first in several, thank you for your help

marble portal
#

when your action will ask you by voice do you wantblabla and you reply with yes/no, then this yes/no will be stored in your "response variable", which you have named as Morning_Answer_Agenda

#

And this action is now completed. You can, in your automation, put next action afterwards, and this next action can use the result from previous one

#

you see in my example, how my first action is the "get data in the response varaible"

#

and second action is "write log" of the data from action before

ancient fractal
#

I do, yes

marble portal
#

ok, so then, the third action is the if check

#

where I made a decision that if the answer was yes, I turn on the light, and if answer was no, I do something else

#

I use the jinja template, because it is considered as an advanced check operation

#

in my case the variable name is ai_response and ai_response.data holds the information

#

If you run actions you have so far, you can see the content of the variable in the traces view

ancient fractal
#

Okay, so then I just need to work on the if statement after the response is provided

marble portal
#

yes

#

when you look at traces, you will see step by step the exeuction for example in my case

#

First step was t oget yes/no answeR:

#

I got the yes, so ai_response.data was set to yes

#

my if executed the then part because the if was a success

#

so now when I run the script multiple times, light is a bit on a bit off 🙂

ancient fractal
#

So this is only accomplishable using the traces? I understand the logic, but I don't know how to use traces or yaml, so I have to use the UI for now

#

I do really appreciate the help, I just am limited, coding is a little out of my expertise right now

marble portal
#

no, traces are there for you to debug what is going on 🙂

#

when your automation runs, you have traces, that allows you to see what happened in the past, so you can debug the problem

#

you can contact me privately and we organize voice if you want - up to you

ancient fractal
#

Possibly, I'd like to keep it here if possible so others can see how this was resolved, or I can refer back to it in the future, it's been very helpful so far

#

So right now I need to know what options to select for the second action, I'm choosing 'add built block' then 'if-then'

marble portal
#

yes

#

for condition use "template"

#

Hmm, to guide you step-by-step like this it might be tough, because I'd like to know the variable response format from the first action. For that you must run the automation actions first to see the traces, and then see the result, like I showed you just above in my example

ancient fractal
#

Ah, I understand

marble portal
#

so, with the first action only, can you run the automation once (top right corner -> run actions)

#

and see what is the variable response under the traces?

ancient fractal
#

This is all that I see afterward

#
  entity_id: automation.morning_agenda
  state: 'on'
  attributes:
    id: '1753811331742'
    last_triggered: '2025-09-21T17:46:23.816775+00:00'
    mode: single
    current: 1
    friendly_name: Morning Agenda
  last_changed: '2025-09-21T17:44:50.914043+00:00'
  last_reported: '2025-09-21T17:46:23.816888+00:00'
  last_updated: '2025-09-21T17:46:23.816888+00:00'
  context:
    id: 01K5PP4M6865ESEKTC4RYNBZZN
    parent_id: 01K5PP4M67MJQ5BY32WVB0KBW5
    user_id: null
trigger:
  id: '0'
  idx: '0'
  alias: null
  platform: state
  entity_id: binary_sensor.everything_presence_one_5b2078_occupancy
  from_state:
    entity_id: binary_sensor.everything_presence_one_5b2078_occupancy
    state: 'off'
    attributes:
      device_class: occupancy
      friendly_name: Everything Presence One 5b2078 Occupancy
    last_changed: '2025-09-21T17:45:41.887504+00:00'
    last_reported: '2025-09-21T17:45:41.887504+00:00'
    last_updated: '2025-09-21T17:45:41.887504+00:00'
    context:
      id: 01K5PP3B7ZG7QAA3MN4NVVRQEQ
      parent_id: null
      user_id: null
  to_state:
    entity_id: binary_sensor.everything_presence_one_5b2078_occupancy
    state: 'on'
    attributes:
      device_class: occupancy
      friendly_name: Everything Presence One 5b2078 Occupancy
    last_changed: '2025-09-21T17:46:29.302924+00:00'
    last_reported: '2025-09-21T17:46:29.302924+00:00'
    last_updated: '2025-09-21T17:46:29.302924+00:00'
    context:
      id: 01K5PP4SHP5SEZG5XATMJ4CY89
      parent_id: null
      user_id: null
  for:
    __type: <class 'datetime.timedelta'>
    total_seconds: 1
  attribute: null
  description: state of binary_sensor.everything_presence_one_5b2078_occupancy```
marble portal
#

this is the automation one (trigger one)

#

click on one step on the side and click "changed variable"

#

these points are clickable so you can see each step

#

find the step that asks you for yes/no

ancient fractal
#

Oh, I didn't realize that, thank you. It looks like maybe it isn't changing the variable

marble portal
#

the step was not executed

#

can you show the step config ?

ancient fractal
#
metadata: {}
data:
  question: Good morning! Would you like to know what's on your agenda for today?
  preannounce: true
  entity_id: assist_satellite.home_assistant_voice_09bdfd_assist_satellite
  answers:
    - id: 'Yes'
      sentences:
        - 'Yes'
    - id: 'No'
      sentences:
        - 'No'
response_variable: Morning_Agenda_Answer```
marble portal
#

and you got the voice in reality and you said "yes" as a response ?

ancient fractal
#

I did, it asked the question as usual, i verbally responded yes, and then it stopped listening

marble portal
#

then this step did execute

#

you sure you have clicked the correct icon on the left of the steps?

#

there are 2 orange, which one did you enable?

#

click all 4 icons and check "changed variables" for all of them....

#

if you got voice then it was executed

ancient fractal
marble portal
#

please make sure that you are looking at correct trace -> there are several on top

#

I've asked GPT to see if it will be the same what I asked above, seems so:

alias: Example - Ask Yes/No with Assist Satellite
sequence:
  - service: assist_satellite.ask_question
    target:
      entity_id: assist_satellite.living_room
    data:
      question: "Do you want me to turn on the heater?"
      type: "yes_no"
    response_variable: answer

  - if:
      - condition: template
        value_template: "{{ answer == 'yes' }}"
    then:
      - service: switch.turn_on
        target:
          entity_id: switch.heater
    else:
      - service: notify.mobile_app_myphone
        data:
          message: "Heater left off"
mode: single
ancient fractal
#

Do you think it's not capturing the response?

marble portal
#

well the trace is saying that step was not executed

#

this is strange

ancient fractal
#

Hah, I was hoping this would be a simple mistake on my end

marble portal
#

I think there is one 🙂

ancient fractal
#

Okay, I've made some progress

#

I watched this video on YouTube: https://www.youtube.com/watch?v=3SaQlqrnFpo

It is now possible for Home Assistant to ask YOU a question and you be able to answer conversationally. This does not require that you use an LLM. It is all handled locally. If you don't have the local hardware power for this and you subscribe to the Nabu Casa cloud, you can use their hardware for super-fast responses.

Support this channel by b...

▶ Play video
marble portal
#

show YAML, let's see

ancient fractal
#

Basically after following his steps, it still wasn't quite working, so I changed the response to 'Deny' and 'Affirm' instead of 'Yes' and 'No' because one of the commenters said they had trouble with that, but it still wasn't working

So I looked at the traces you showed me how to use, and realized that it was capturing the last word of the verbal response as part of my answer, so if the last word of the question it asks is 'today', it will hear 'Today Yes'

#

And this is happening because there is a slight delay caused by the bluetooth speaker I am using which is connected to voice assistant

marble portal
#

alright, so then the traces helped you to get a solution, very good

ancient fractal
#

So it asks the question, begins listening, but the bluetooth speaker is still actually broadcasting while home assistant is listening, so it captures an answer that isn't matching up, so I'm testing options now

#

It works!