Speech response in automation

Can I get a spoken response in an automation? Automations seem to be the simplest way of adding routines to be triggered by voice. In a simple test I created this (which has no practical use except as a preliminary test). This works.

alias: Testing speech
description: I want this as a speech response to an action in Assist. Can't that be done?
trigger: []
condition: []
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.corner
    data:
      media_content_id: >-
        media-source://tts/tts.piper?message=Home+Assistant+is+fine+today.+Thank+you+for+asking+Monkey&language=en-us&voice=en-us-lessac-low
      media_content_type: provider
    metadata:
      title: Home Assistant is fine today. Thank you for asking Monkey
      thumbnail: https://brands.home-assistant.io/_/tts/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/tts.piper?message=Home+Assistant+is+fine+today.+Thank+you+for+asking+Monkey&language=en-us&voice=en-us-lessac-low
mode: single

However, if I then add the following speech trigger for Assist, I get the error Message malformed: expected dict for dictionary value @ data[ā€˜event_dataā€™]

Iā€™ve tried adding quotes to the trigger string but that makes no difference. Is this just not possible, or is there something wrong with my syntax? The visual editor accepts it until itā€™s time to save.

alias: Testing speech
description: I want this as a speech response to an action in Assist. Can't that be done?
trigger:
  - platform: event
    event_type: Conversation
    event_data: How are you today
condition: []
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.corner
    data:
      media_content_id: >-
        media-source://tts/tts.piper?message=Home+Assistant+is+fine+today.+Thank+you+for+asking+Monkey&language=en-us&voice=en-us-lessac-low
      media_content_type: provider
    metadata:
      title: Home Assistant is fine today. Thank you for asking Monkey
      thumbnail: https://brands.home-assistant.io/_/tts/logo.png
      media_class: app
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://tts
        - media_content_type: provider
          media_content_id: >-
            media-source://tts/tts.piper?message=Home+Assistant+is+fine+today.+Thank+you+for+asking+Monkey&language=en-us&voice=en-us-lessac-low
mode: single

Thanks.

1 Like

Try changing the above to:


trigger:
  - platform: conversation
    command: ā€œHow are you todayā€

1 Like

Thanks rossk! That worked. Iā€™m grateful: donā€™t think Iā€™d ever have figured it out on my own but itā€™ll be a useful example to work from. A supplementary question: the logical thing in this example would be to play back the response on the device that triggered the automation (instead of the ā€œDoneā€) but that isnā€™t offered as an option. If the media_player identity ID is null, the message isnā€™t played. Is there a way to set that, or would that have to be a suggestion for the developers?

1 Like

Does anybody know the answer to this? If we want the response to play on the device triggering it, do we need to create the voice routine as something other than an automation?

1 Like

For now, I did so by creating custom sentences instead of automations

Did you get any further with this?

For my use case I want to:

  1. Send a HTTP request to an API
  2. Get the response
  3. Parse the response
  4. Return the parsed response to the voice assistant (running on ESP-s3-box-3)
1 Like

Iā€™m trying to automate an action from Assist with a condition

e.i
At specfic time to get Assist to make a joke given the parameters

Is this possible?