HA not recognising intents from alexa

I’m losing my noodles on this one…

So i’m setting up my first Alexa using HA intents,

  1. I trigger an intent “Alexa, Ask home assistant where we are” (one of the demo intents)
  2. This triggers the “WhereAreWeIntent” in alexa which calls the intent of the same name in home assistant
  3. Alexa responds “This intent is not yet configured within Home Assistant.”
  4. HA writes in its log “[homeassistant.components.alexa] Received unknown intent WhereAreWeIntent”
  5. But the Intent in Alexa is called “WhereAreWeIntent” the same as in HA “WhereAreWeIntent” so it should work right?

So they are both talking to each other but the intents aren’t getting matched up. I figured it was a config issue but I’ve tried everything including stripping it back to a hello world intent in the main config.

Can someone fill me in on what im missing?

Request part of Alexas message to HA
“request”: {
“type”: “IntentRequest”,
“requestId”: “EdwRequestId.53bfa71c-6fa3-4901-aef0-6b3243d68450”,
“intent”: {
“name”: “WhereAreWeIntent”,
“slots”: {}
},

Configuration.yaml
alexa: !include alexa.yaml

Alexa.yaml

intents:
WhereAreWeIntent:
  speech:
    type: plaintext
    text: >
      {%- if is_state('device_tracker.fletch_kenzo', 'home') and
             is_state('device_tracker.haylee_s8', 'on') -%}
        You are both home, you silly
      {%- else -%}
        Haylee is at {{ states.device_tracker.haylee_s8.state.replace('_', ' ') }}.
        and Fletch is at {{ states.device_tracker.fletch_kenzo.state.replace('_', ' ') }}.
      {% endif %}
  card:
    type: simple
    title: Where are We?
    content: Ask Home Assistant about where everyone is

After a break I’ve solved it, so here’s the solution for anyone else that might hit the same issue.

  1. in the configuration.yaml you just want alexa: by it self - its not meant to reference anything.

  2. in the configuration.yaml you want to put all you intents under intent_script like so

    intent_script: !include intent_script.yaml

  3. in the intent_script.yaml here is some example code that works.

    WhereAreWeIntent:
    speech:
    text: >
    {%- if is_state(‘device_tracker.fletch_kenzo’, ‘home’) and
    is_state(‘device_tracker.haylee_s8’, ‘on’) -%}
    You are both home, you silly
    {%- else -%}
    Haylee is at {{ states.device_tracker.haylee_s8.state.replace(’’, ’ ‘) }}.
    and Fletch is at {{ states.device_tracker.fletch_kenzo.state.replace(’
    ’, ’ ') }}.
    {% endif %}
    card:
    type: simple
    title: Where are We?
    content: Ask Home Assistant about where everyone is

Also I found this persons example config super helpful

3 Likes

Hi there!

You are awesome! Thank you very much, I’ve same problem with you, and I’ve search in google for a long time… after see this post , my problem has solved! thanks again!

By the way, why the intents definition in alexa: component not work, but in intent_scripts is work? This is very strange.

Hey,
I’m happy to help and have a chance to give back to this awesome community.

To answer your question, I think thats the way they designed it. Alexa: to activate the component and Intent_scripts to list what it can do.

This works great with Haaska, set that up next if you haven’t.

2 Likes

OK, I get it:grin:

Thank you verymuch I solved my problem from your reference

Hey - I was having the same problem.

I guess it was my own fault for following the documentation…?

alexa:
  intents:
    LocateIntent:
      action:
        service: notify.pushover
        data:
          message: Your location has been queried via Alexa.
      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. Pootie! I do not know where {{User}} is.
          {%- endfor -%}
    WhereAreWeIntent:
      speech:
        type: plaintext
        text: >
          {%- if is_state('device_tracker.iphone', 'home') -%}
            iPhone is home.
          {%- else -%}
            iPhone is not home.
          {% endif %}

But your post suggests that this syntax is not correct and that “alexa:” should appear by itself without any sub-configuration? I’ve tried it your way - and it works of course - well, mostly. When I use the test-page in Amazon, my script runs - but when I ask my Alexa to do it - she responds with the correct text but for some reason doesn’t run the script….? Any ideas why that might be so?

In any case - you solved this problem in September and it’s now almost January and they haven’t updated the documentation to make this configuration more clear - and to remove the sample configuration that is actually wrong.

This is the 3rd or 4th thing that I’ve had to google in order to get working because the online documentation is either incomplete or incorrect. I hope that improves going forward. Very frustrating at times.

Thank you very much for posting this solution.

Hi - just as a follow up to my last message.

My scripts aren’t fully running when I speak directly to Alexa - but they do run properly when I use the Amazon test page.

I think I have Alexa set up correctly to run a script. Instead of “Ask Home Assistant”, I’ve configured it to use “Ask Gladys”. The test script just displays a notification on my Android TV and it’s called “Test_Notification”. I configured the “RunScriptIntent.yaml” file to respond with “Ok, Tenly” instead of just “Ok”

From the Amazon Skill creation test page, there is a spot where you can type your command - and then a button appears labeled “Ask Home Assistant”. If I type “Ask Gladys to run Test Notification” and then click the “Ask Home Assistant” button - the test notification gets displayed on my Android TV - and I see that the “Service Response” does say “Okay, Tenly”. So far - so good, right?

When I actually speak to Alexa in my house - I say “Ask Gladys to run Test Notification” - and Alexa responds by saying “Okay, Tenly” - but the notification does not actually get sent to the Android TV.

I have no idea why it would work using one mechanism - but not the other. The “Okay, Tenly” response confirms that it found the RunScriptIntent.yaml file. Why would the test page be able to trigger the script to execute - but the real Alexa can’t? Any ideas why this might be happening and how I might fix it or further troubleshoot it?

Thanks in advance.

I have this mostly working now. Still not sure exactly what fixed it but it may have to do with locale - or with the fact that I am in Canada and I have an Echo, Echo Dot and an Echo Show at home - and the Echo Show is not fully supported in Canada.

When I followed the Home Assistant documentation and launched the Alexa skills designer on the Amazon site - the default locale that I created everything under was “EN-US” and it was only kinda working (as described in previous message).

During troubleshooting - I noticed an option to create skills for alternate locales - so I recreated the skill using “EN-CA” - and now it seems to work UNLESS I am talking to the Echo Show - in which case it claims to have no knowledge of the skill. The Echo Show does work for controlling most of my smart home devices - and for streaming whole home audio - but has trouble executing some Alexa routines “sometimes” that the other 2 devices always execute flawlessly.

So anyhow - for now - I’m going to assume that my issue was being caused because the skill I created was in a locale that was different from my devices. It would be great if somone could confirm this.

If true - it would also be great if someone could update the documentation to point out that the Alexa Skill you create has to match the locale of your Alexa account since it appears that the skill creation page on Amazon always defaults to EN-US.

I think you’ll probably need to share more about what you’ve done so far if you want anyone to help spot what needs to change to get your setup working.

did you read my reply to your post on the other thread?

“plaintext” was removed and now you need to use “plain”.

try getting rid of the “intents:” at the beginning of your intent_script.yaml.

here is an intent that works for me:

NorthGarageDoorIntent:
  speech:
    type: plain
    text: >
      {%- if Operation.lower() == "open" and is_state("binary_sensor.garage_door_north_position_sensor", "off") -%}
        OK, opening the alley garage door.
      {%- elif Operation.lower() == "open" and is_state("binary_sensor.garage_door_north_position_sensor", "on") -%}
        The alley garage door is already open.
      {%- elif Operation.lower() == "close" and is_state("binary_sensor.garage_door_north_position_sensor", "on") -%}
        OK, closing the alley garage door.
      {%- elif Operation.lower() == "close" and is_state("binary_sensor.garage_door_north_position_sensor", "off") -%}
        The alley garage door is already closed.
      {%- endif -%}
  action:
    - service_template: >
        {%- if Operation.lower() == "open" and is_state("binary_sensor.garage_door_north_position_sensor", "off") -%}
          switch.turn_on
        {%- elif Operation.lower() == "close" and is_state("binary_sensor.garage_door_north_position_sensor", "on") -%}
          switch.turn_on
        {%- endif -%}
      data_template:
        entity_id: switch.garage_door_north_operator_switch

also try checking your home-assistant.log to see if there is anything there.

I used this so far -
{
“intents”: [
{
“intent”: “CloseNorthGarageDoorIntent”
},
{
“intent”: “OpenNorthGarageDoorIntent”
},
{
“intent”: “NorthGarageDoorStatusIntent”
},
{
“intent”: “NorthGarageDoorOperateIntent”
}
]
}

CloseNorthGarageDoorIntent close the alley garage door
CloseNorthGarageDoorIntent lower the alley garage door
OpenNorthGarageDoorIntent open the alley garage door
OpenNorthGarageDoorIntent raise the alley garage door
OpenNorthGarageDoorIntent lift the alley garage door
NorthGarageDoorStatusIntent is the alley garage door open
NorthGarageDoorStatusIntent is the alley garage door closed

and you should just be able to edit the skill you have already created.

that switches any intent from alexa to all lower case then does the comparison.

that should have prevented the errors that you were getting from happening. i think…

i’m a pretty noob user myself so i’m not sure where to tell you to go to learn more. i wish i knew the answer to that question myself. google is my best friend when it comes to figuring all this out.

Did you ever get your intent working? I’m having the same issue. Intent fully executes from Amazon Alexa Test page. In Home Assistant only the speech: text portion responds. Seems to jump over the action portion of the intent script.

Curious

Yes. I got mine working. I think it was a problem with the locale I selected on the Alexa site. My account is in Canada, but I had selected EN-US (the default) initially. After I recreated the skill for EN-CA, I stopped having problems.

From the description of your problem - my guess is that Alexa is not correctly decoding the name of the script you want to run. As a test - try renaming your script to something simple and see if Alexa finds it. My runscriptintent is below. It’s triggered when I ask HomeAssistant to “run” ‘something’ and without fail, if Alexa understood I said “run”, she responds with “something_something_something - executed.”. This lets me catch some of the misunderstandings. For example - suppose I had a script called “prepare_for_bed_time”. When I ask “Alexa, ask HomeAssistant to run prepare for bed time”, she would say “prepare underscore for underscore bed underscore time” if she heard me correctly and ran my script - but she might say “prepare underscore for underscore bedtime” instead - in which case, I know she misunderstood me and therefore wouldn’t find my script. If it wasn’t obvious, she confused “bed time” with “bedtime” in the example above. They sound the same but would actually need to point to two different scripts. (The actual script I use is now named “Time_For_Bed” which she seems to get right 95% of the time).

action:
  service: script.turn_on
  data_template:
    entity_id: script.{{ Script | replace(" ", "_") }}
speech:
  type: plain
  text: '{{ Script | replace(" ", "_") }} - executed'
1 Like

That was it! And a great trouble-shooting tip. Much appreciated. I was starting to go mad!
Thanks for the reply.