home-assistant.io/source/_integrations/conversation.markdown

3.0 KiB

title description ha_category ha_release ha_quality_scale ha_codeowners ha_domain
Conversation Instructions on how to have conversations with your Home Assistant.
Voice
0.7 internal
@home-assistant/core
conversation

The conversation integration allows you to converse with Home Assistant. You can either converse by pressing the microphone in the frontend (supported browsers only (no iOS)) or by calling the conversation/process service with the transcribed text.

Screenshot of the conversation interface in Home Assistant.

# Example base configuration.yaml entry
conversation:

{% configuration %} intents: description: Intents that the conversation integration should understand. required: false type: map keys: '<INTENT NAME>': description: Sentences that should trigger this intent. required: true type: list {% endconfiguration %}

Adding custom sentences

By default, it will support turning devices on and off. You can say things like "turn on kitchen lights" or "turn the living room lights off". You can also configure your own sentences to be processed. This works by mapping sentences to intents and then configure the intent script integration to handle these intents.

Here is a simple example to be able to ask what the temperature in the living room is.

# Example configuration.yaml entry
conversation:
  intents:
    LivingRoomTemperature:
     - What is the temperature in the living room

intent_script:
  LivingRoomTemperature:
    speech:
      text: It is currently {% raw %}{{ states.sensor.temperature }}{% endraw %} degrees in the living room.

Adding advanced custom sentences

Sentences can contain slots (marked with curly braces: {name}) and optional words (marked with square brackets: [the]). The values of slots will be passed on to the intent and are available inside the templates.

The following configuration can handle the following sentences:

  • Change the lights to red
  • Change the lights to green
  • Change the lights to blue
  • Change the lights to the color red
  • Change the lights to the color green
  • Change the lights to the color blue
# Example configuration.yaml entry
conversation:
  intents:
    ColorLight:
     - Change the lights to [the color] {color}
{% raw %}
intent_script:
  ColorLight:
    speech:
      text: Changed the lights to {{ color }}.
    action:
      service: light.turn_on
      data:
        rgb_color:
          - "{% if color == 'red' %}255{% else %}0{% endif %}"
          - "{% if color == 'green' %}255{% else %}0{% endif %}"
          - "{% if color == 'blue' %}255{% else %}0{% endif %}"
{% endraw %}

Service conversation.process

Service data attribute Optional Description
text yes Transcribed text