Hi there, I’m somewhat new to Home Assistant and very new to YAML scripting. I am currently experimenting with creating sentences with wildcards and, at a minimum, am trying to have a response respond back using those wild cards.
I am running HASS OS 2026.1.3 and using the HA Voice Preview. I’ve reviewed the documentation for using wildcards, triggers, etc. I first attempted to create the same wildcard example from the documentation (using album and artist as my variables) using the drop down options, but received this error:
Error: Error rendering service name template: UndefinedError: ‘dict object’ has no attribute ‘slots’
I also tried diving deeper and look more into YAML scripting and followed various examples from the community to try and piece various solutions together. However, I still receive the same error.
This occurs any time I use {{trigger.slots.}}. However, if I use something like {{trigger.}}, there’s no error but the trace seems to run the response without getting those wild card variables.
I’ve included the YAML script below:
alias: Wildcard Test
description: ""
triggers:
- trigger: conversation
command:
- Play {album} by {artist}
conditions: []
actions:
- set_conversation_response: Playing {{trigger.album}} by {{trigger.artist}}
mode: single
I’m sure it’s something obvious, but any assistance would be greatly appreciated.
alias: Wildcard Test
description: ""
triggers:
- trigger: conversation
command:
- Play {album} by {artist}
conditions: []
actions:
- set_conversation_response: Playing {{trigger.slots.album}} by {{trigger.slots.artist}}
mode: single
So I just tried using the debug under the Voice Assistant section and sent it a message. It did indeed repeat the message back, which is crazy. I literally did this several times last night and this is the first time it responded back. However, when I actually say the phrase to my voice assistant. Nothing happens at all.
The trace screenshot you posted shows that the trigger wasn’t used… like it was fired using the “Run Actions” menu button or the automation.trigger action. With either of those there is no value assigned to the trigger object, so that error is expected.
When you say it to the voice assistant, does the automation trigger?
Is the interaction captured in the Debug assistant for that voice pipeline? What does it show?
That shows it is using Speech-to-phrase, which I’m not that familiar with, but based on the docs it looks like it will require you to set up a list of allowed values for album and artist.
I actually just went through this exact process for the first time a few days ago (using speech to phrase). I can confirm that I got erratic results every time I setup or changed the sentence/conversation triggers; typically it would respond that it didn’t understand when I tried to talk to my phone or watch. This was incredibly frustrating and confusing (and led to a lot of profanity being yelled at said device Ha). I ASSUME that it’s doing some updating in the backend to include the sentence/conversation triggers in its list of possible phrases (obviously being more complicated by the fact that there are wildcards as well). I tried restarting the speech to phrase add-on with mixed results, thinking this MIGHT trigger this updating process.
HOWEVER, after trying it again a few hours later, it’s since worked flawlessly since. So you probably just need to wait a short bit.
Not to sidetrack this thread, but one thing I wasn’t clear on, is if it’s possible to list the slot options in a sentence/conversation trigger rather than using pure wildcards. The docs only mention being able to do this in YAML intent configs, not in an automation. Presumably, this would work increase accuracy if you know ahead of time what the possible responses are.
As I understand it, you would set up the lists as shown in the docs in YAML in a file sentences.yaml. There is no way I am aware of to do it in the Automation editor.
I also thought this might be possible, it just wasn’t clear to me that if I used a ‘wildcard’ in an automation, whether HA will try to match it to the defined lists in speech to phrase or if it’s a level lower and exists as an independent variable on it’s own.
Example:
I used the {hours} ‘wildcard’ in an automation. Is this treated as a wholly separate wildcard regardless of it’s name or is it matched to the ‘hours’ list defined in YAML? I’m kind of assuming its being matched, but I never found any docs that answer this and the fact that it’s explicitly called a wildcard in the docs makes me extra unsure.
Edit: Just played around with the YAML files, and my experience seems to confirm that it’s matching the ‘wildcards’ in automation sentence triggers to the defined lists located in YAML. Good to know!