How to send 'Response variable' to Voice Assist?

Hi,

I have been trying to set up a Voice Assist to enumerate all the items from my shopping list.

At the moment, can add items to the shopping list. The problem is grabbing those items and enumerating them on voice assist.

I tried the following automation but seems that conversation.process is not sending the data back to the prompt.

alias: Voice - Grab the items
description: ""
triggers:
  - trigger: conversation
    command:
      - What items are on the shopping list
conditions: []
actions:
  - alias: Get Shopping List Items
    target:
      entity_id: todo.shopping_list
    data:
      status: needs_action
    response_variable: shopping_list_data
    action: todo.get_items
  - alias: Format the Shopping List
    variables:
      items: |
        {% if shopping_list_data and shopping_list_data['items'] is iterable %}
          {{ shopping_list_data['items'] | map(attribute='summary') | list }}
        {% else %}
          []
        {% endif %}
      formatted_list: |
        {% if items | count > 0 %}
          Shopping List: {{ items | join(', ') }}
        {% else %}
          Your shopping list is empty.
        {% endif %}
  - alias: Send Items to Conversation
    data:
      text: "{{ formatted_list }}"
    action: conversation.process
mode: single

What is the right process to make my automation run and output the results? Also, it is possible to send that to the LLM via Voice Assist?

There seems to be some confusion about the action conversation.process. This action processes a text input just like when you use the text Conversation agent in the UI or an STT integration passes text to an agent… it does not directly produce a TTS action.

Your example above also contained a couple other issues that needed attention:

  1. Missing todo entity ID in both instances where you used shopping_list_data['items'] instead of shopping_list_data['todo.shopping_list']['items'].
  2. There’s no reason to use such a convoluted condition in the if statement when you can just check the state of the todo entity.

Try the following:

alias: Voice - Grab the items
description: ""
triggers:
  - trigger: conversation
    command:
      - What items are on the shopping list
conditions: []
actions:
  - alias: Get Shopping List Items
    target:
      entity_id: todo.shopping_list
    data:
      status: needs_action
    response_variable: shopping_list_data
    action: todo.get_items
  - alias: Format the Shopping List
    variables:
      message: |
        {% if states('todo.shopping_list')|int(0) != 0 %}
          {% set x = shopping_list_data['todo.shopping_list']['items'] | map(attribute='summary')| list %}
          {{' and '.join((x|join(', ')).rsplit(', ', 1)) }}
        {% else %}
          Your shopping list is empty.
        {% endif %}
  - set_conversation_response: "{{ message }}"
mode: single
1 Like

I understand not what my problem was. Now it’s working great!

After this automation, I tried to talk to my agent with a different sentence than the trigger command. Is it possible to make my LLM call the automation if I request something similar?

Well, I changed my approach and used a script. The Agent is calling the script but the output seems that is not being sent to the LLM.

sequence:
  - alias: Get Shopping List Items
    target:
      entity_id: todo.shopping_list
    data:
      status: needs_action
    response_variable: shopping_list_data
    action: todo.get_items
  - alias: Format the Shopping List
    variables:
      message: |
        {% if states('todo.shopping_list')|int(0) != 0 %}
          {% set x = shopping_list_data['todo.shopping_list']['items'] | map(attribute='summary')| list %}
          {{' and '.join((x|join(', ')).rsplit(', ', 1)) }}
        {% else %}
          List is empty!
        {% endif %}
  - set_conversation_response: "{{ message }}"
    enabled: true
alias: Voice - Get Items from Shopping List
description: "Script to grab all items inside the shopping list."

The output that I get from the agent is “Your Shopping List is empty” which is not right and is not even the string “List is empty!”.