Alexa skill: can I access a "slot" in a template?

Hi,

I want Alexa to tell me what the current temperature for a room is, e.g. “Alexa, ask homeassistant for the temperature in the livingroom”. I have created a custom skill with a “slot” (that’s what the variables are called, I believe) named “Room”.

How do I access this slot from within a template?

I tried:

speech:
  type: plaintext
  text: >
    {% if {{Room}} == 'livingroom' %}
    ...

which is apparently not the right syntax.
Leaving out the braces around Room completely, seems to be syntactically correct, but it doesn’t have the desired effect.

How do I do this correctly?

TIA,
Sebastian

Here is an example of what I think you are trying to do.

    MediaPlayerPlayPauseIntent:
      action:
        service: media_player.media_play_pause
        data_template:
          entity_id: media_player.{{ MediaPlayer | replace(" ", "_") }}
      speech:
        type: plaintext
        text: !include alexa_confirm.yaml

the MediaPlayer is in a slot/variable list in the Alexa interaction model. I have a list of the names of all of my media players in there.

I just read what you were asking again. You are trying to respond with a slot variable, not sure I know how to do that exactly how you are trying to do it, but… this is how my device tracker status works which is kinda similar.

    LocateIntent:
      speech:
        type: plaintext
        text: >
          {%- for state in states.device_tracker -%}
            {%- if state.name.lower() == User.lower() -%}
              {{ state.name }} is at {{ state.state }}
            {%- endif -%}
          {%- else -%}
            I am sorry, I do not know where {{ User }} is.
          {%- endfor -%}

Where User is the name spoken to Alexa.

1 Like

Ah, thanks a lot!
So I can access it - in my case - just using Room as variable name.
I added a .lower() and now it seems to work! Great :slight_smile:

Sebastian

1 Like