Custom sentences and intent scripts

Custom sentences and intent scripts are an alternative to automations for controlling devices via voice assistants.

The custom sentence acts as the trigger. It passes parameters to the intent script, which carries out the required actions and plays the TTS response.

You can use them to extend and personalise Home Assistant's built-in sentences, or to send the TTS response to a speaker other than the one in your voice assistant. Sentences can be marked up with alternate phrases and words that may be omitted, and values passed to the intent script can be tightly controlled. The scripts support templating.

Here are some simple, practical examples of what you can do, including setting timers and alarms and managing shopping lists.

The examples are quite modular - everything doesn't have to be crammed into the intent. Templates can be used to construct common phrases that can be repeated in different places. Scripts can be used to carry out common actions, and these may be easier to maintain, particularly if you prefer to use the UI.

To use intent scripts you have to install the intent script integration. You can't use the UI to edit them.'

Please make comments and suggestions in the GitHub discussions page


About speakers

By default Assist responds to built-in commands through the voice assistant that heard the command. This is difficult to change short of hacking the voice assistant device itself. (If your voice assistant is an ESPHome device there are some configuration tools.)

This is one reason for choosing to use custom sentences and intents - the response can be played through any speaker you like.

The examples in this repository call a script to deliver TTS sentences.

    - action: script.tts_response
      data:
        tts_sentence: "Whatever you need to say..."

You can substitute your own script, of if you want responses to come through your voice assistant you can simply use speech:

    speech:
      text: Whatever you need to say...