Conversation process variable

Hi, I’m trying to accomplish a lovelace button that when pressed, tells the result of an assist (llm) query

If I call this service:

service: conversation.process
data:
  text: dimmi le previsioni meteo per oggi e la temperatura attuale in balcone
  agent_id: conversation.google_generative_ai_conversation

I get this result:

response:
  speech:
    plain:
      speech: >-
        Il meteo attuale a Roma è nuvoloso. La temperatura attuale in balcone è
        29.6°C.
      extra_data: null
  card: {}
  language: it
  response_type: action_done
  data:
    targets: []
    success: []
    failed: []
conversation_id: 01J0TGBVKVH4MRZJZWVHNJFBD1

I want to pass the “speech” part as a variable and tts that variable on a device:

I did this script:

alias: Meteo OP5T
sequence:
  - service: conversation.process
    metadata: {}
    data:
      text: dimmi le previsioni meteo per oggi e la temperatura attuale in balcone
      agent_id: conversation.google_generative_ai_conversation
    response_variable: risposta
  - service: tts.speak
    metadata: {}
    data:
      cache: true
      media_player_entity_id: media_player.oneplus_5t
      message: "{{ risposta }}"
    target:
      entity_id: tts.piper
description: ""
icon: mdi:weather-lightning

Problem is that the message is the full response and not just the “speech” part. How to filter that? I tried {{ speech.risposta }} but did not work

{{ risposta.speech.plain.speech }}

it gives this error:

Error rendering data template: UndefinedError: 'dict object' has no attribute 'speech'

the yamls is now:

alias: Meteo OP5T
sequence:
  - service: conversation.process
    metadata: {}
    data:
      text: dimmi le previsioni meteo per oggi e la temperatura attuale in balcone
      agent_id: conversation.google_generative_ai_conversation
    response_variable: risposta
  - service: tts.speak
    metadata: {}
    data:
      cache: true
      media_player_entity_id: media_player.oneplus_5t
      message: "{{ risposta.speech.plain.speech }}"
    target:
      entity_id: tts.piper
description: ""
icon: mdi:weather-lightning

Sorry, I missed the top-level of the result. It’s probably

{{ risposta.response.speech.plain.speech }}

You can look in the trace for the automation and see the “changed variables” tab for the step that calls the service to see the actual structure of the data.

thank you it now works!!