Intent variables

I’m trying to add a voice assistant intent to add items to my shopping list. My current configuration:

config/custom_sentences/en/shopping.yaml:

language: "en"
intents:
  ShoppingAdd:
    data:
      - sentences:
          - "add"

config/custom_sentences/en/shopping.yaml:

intent_script:
  ShoppingAdd:
    speech:
      text: "added"

So far so good, this works (left out action as it’s not necessary for now).

But when I try to add a variable to the intent by modifying "add" to "add {name}", "add {{name}}", "add <name>" etc i get the response intent-failed:

config/custom_sentences/en/shopping.yaml:

language: "en"
intents:
  ShoppingAdd:
    data:
      - sentences:
          - "add {name}"

config/custom_sentences/en/shopping.yaml:

intent_script:
  ShoppingAdd:
    speech:
      text: "added {{name}}"

did you see Calling shopping_list.add_item service from HA Assist - #6 by grzech1983 ?

I got it working by pre-populating my usual shopping items in the yaml (used python to build the yaml from a simple list)

Any way to do it without pre-populating a list? I would rather have an actual variable instead of a list of defined values.

As seen here, this is not currently possible by the default intent language, but it will most likely be supported in the future.

However, there’s a reasonable workaround: this integration provides a custom agent with regex support, falling back to the default one if no match is made.

2 Likes

Looks like this is coming : Add HassShoppingListAddItem intent + wildcards by synesthesiam · Pull Request #1466 · home-assistant/intents · GitHub

2 Likes