Skip to main content

Intent Responses and Whitespace

· One min read

The intents repository which powers Assist, has had two important changes.

First, data blocks in the intents YAML can now have a response key. For example:

language: en
intents:
HassTurnOn:
data:
- sentences:
- "open {name}"
response: cover

A response with a matching key must be defined in responses/<language>/<intent>.yaml:

language: en
responses:
intents:
HassTurnOn:
cover: "Opened {{ slots.name }}"

Response templates are in the Jinja2 format, and may access the matched intent's slots as well as the state of the affected entity.

The second change comes from hassil, the parser for our intent template syntax. In addition to an 8-10x speed-up in parsing, whitespace inside templates is taken literally.

Previously, a template like light(s | ing) would match both "lights" and "lighting". Now, "light s" and "light ing" would be matched instead due to the extra space around |. The correct template would be light(s|ing)