Intent Script


The intent_script integration allows users to configure actions and responses to intents. Intents can be fired by any integration that supports it. Examples are Alexa (Amazon Echo), Dialogflow (Google Assistant) and Snips.

If you are using intent script with LLMs and have parameters, make sure to mention the parameters and their types in the description.

# Example configuration.yaml entry
intent_script:
  GetTemperature:  # Intent type
    description: Return the temperature and notify the user
    speech:
      text: We have {{ states('sensor.temperature') }} degrees
    action:
      service: notify.notify
      data:
        message: Hello from an intent!

Inside an intent we can define these variables:

Configuration Variables

intent map Required

Name of the intent. Multiple entries are possible.

description string (Optional)

Description of the intent.

platforms list (Optional)

List of domains that the entity supports.

action action (Optional)

Defines an action to run to intents.

async_action boolean (Optional, default: false)

Set to True to have Home Assistant not wait for the script to finish before returning the intent response.

mode string (Optional, default: single)

The script mode in which to run the intent script. Use this to define if the intent should be able to run multiple times in parallel.

card map (Optional)

Card to display.

type string (Optional, default: simple)

Type of card to display.

title template Required

Title of the card to display.

content template Required

Contents of the card to display.

speech map (Optional)

Text or template to return.

type string (Optional, default: plain)

Type of speech.

text template Required

Text to speech.

Using the action response

When using a speech template, data returned from the executed action are available in the action_response variable.

conversation:
  intents:
    EventCountToday:
      - "How many meetings do I have today?"

intent_script:
  EventCountToday:
    action:
      - service: calendar.get_events
        target:
          entity_id: calendar.my_calendar
        data_template:
          start_date_time: "{{ today_at('00:00') }}"
          duration: { "hours": 24 }
        response_variable: result                     # get service response
      - stop: ""
        response_variable: result                     # and return it
    speech:
      text: "{{ action_response['calendar.my_calendar'].events | length }}"   # use the action's response