Need help with API.AI

Hi guys
I have a problem configuring this component.
Everything is done exactly as described in the lesson. But regardless of the value of ‘async_action’ api.ai always falls on timeout.

api.ai
Fulfillment: webhook url is
https://{myhass}.duckdns.org/api/apiai?api_password={myhasspwd}

Values of Intent, Action and User says all set to Summary
Use webhook is checked

configuration.yaml

http:
base_url: {myhass}.duckdns.org

apiai:
intents:
Summary:
speech: Everything ok.

What could be the problem?

What happens if you visit https://{myhass}.duckdns.org/api/apiai?api_password={myhasspwd} in a browser?

~Cheers

GET gives 405: Method not alowed
POST with empty body falls with 500: server error

Thank you

Seems like the api is working to me. My guess is there is something wrong with the config you did on the api.ai site. My config is like the following:

Fullfillment -> Webhook
Enabled button on
URL: https://{{DOMAIN}}/api/apiai
BASIC AUTH: empty
HEADERS:  x-ha-access        {{PASSWORD}}
          Content-Type       application/json
DOMAINS: Disable webhook for all domains

In my Intents I have in the Response a Text Response “Cannot connect to HA or it is taking to long” and below that in the Fullfilment section I have the “Use Webhook” checkbox checked.

Does yours look like this as well?

~Cheers

Still the same result =(

It’s seems that api.ai can’t reach home assistant.

Response contains same status with or without authorization info

"status": {
    "code": 206,
    "errorType": "partial_content",
    "errorDetails": "Webhook call failed. Error: Request timeout."
  }

Do you have your SSL setup up in HA?

~Cheers

Yeah it’s configured.

I have the same issue, my HA version is 0.40

It’s not a general issue with 0.40 I have 0.40 and it’s working for me.

~Cheers

I had a similar issue. In my case it was Cloudflare causing the problem between api.ai and home assistant and was fixed by adding a page rule that turned “Browser Integrity Check” to Off.

1 Like

Many things have changed since the last attempt.
There was a complete reinstallation of HASS, installed a couple of updates, router was reset to factory defaults.
But now api.ai is working correctly.

Can you please share your configuration.yaml for api.ai?

I cant seem to get this working.

What is the error you are getting? It would be much easier to approach it this way :slight_smile: The configuration on the component page works perfectly fine.

~Cheers

I tried that, but get this error:
2017-08-23 07:00:35 ERROR (MainThread) [homeassistant.config] Invalid config for [apiai]: not a valid value for dictionary value @ data['apiai']. Got OrderedDict([('intent_script', OrderedDict([('Garage', OrderedDict([('speech', "The Status of Garage is {{states('cover.garage_door')}}")]))]))]). (See /home/homeassistant/.homeassistant/configuration.yaml, line 132). Please check the docs at https://home-assistant.io/components/apiai/

My configuration is simple, like below

  intent_script:
    Garage:
      speech: The Status of Garage is {{states('cover.garage_door')}}```

Same here… need help :slight_smile:
2017-08-22 23:45:58 ERROR (MainThread) [homeassistant.config] Invalid config for [apiai]: not a valid value for dictionary value @ data['apiai']. Got OrderedDict([('intents', OrderedDict([('GetTemperature', OrderedDict([('speech', "We have {{ states('sensor.citronnier_temperature') }} degrees"), ('async_action', False), ('action', OrderedDict([('service', 'notify.notify'), ('data_template', OrderedDict([('message', 'Api.ai has send a request')]))]))]))]))]). (See /home/homeassistant/.homeassistant/configuration.yaml, line 126). Please check the docs at https://home-assistant.io/components/apiai/

Configuration:

    apiai:
      intents:
        GetTemperature:
          speech: We have {{ states('sensor.citronnier_temperature') }} degrees
          async_action: False
          action:
            service: notify.notify
            data_template:
              message: Api.ai has send a request

Ok, I found it !

Example on API.AI component is wrong.

Check the Intent script page : https://home-assistant.io/components/intent_script/

Sorry but the example is NOT wrong.

First off you did put “intent” instead of “intent_script” like stated in the component page. Next you put it under apiai altough it clearly is next to it not indented in the example.

~Cheers

You are right. The example is correct, however, I can see how I got it wrong.
Pays to just copy and paste from the component page rather than typing it in.

1 Like

It also worked for me taking the example at home assistant api.ai component page.
The customizations I’ve made to make it work were:

  • My endpoint isn’t SSL secured. So I pointed to the unsecure address em added on headers KEY = x-ha-access, value = MYPASSWORD.
  • Changed the example to match the sensors I have in my setup.

At this point I can write asking the temperature of my house on api.ai console and the answer is returned.

Is anybody using this with Google Assistant? I would like to know how to connect this apiai project I’ve created with my google assistant instance running on my Raspberry Pi. As far as I remember in order to trigger this apiai project I have to say “hey google, test app”, and this is something I would like to avoid.

1 Like