I am building a Google Smart Home action with fulfillment hosted on AWS as a lambda function in node.js with the node implementation for Google Smart Home actions, exposed via AWS API gateway and an external OAuth 2 provider serving as authorizer for API gateway. My fulfilment includes SYNC, QUERY and EXECUTE methods and returns valid JSON responses including all required attributes from what I can see in the docs. I set up everything in the Actions on Google console including fulfillment URL pointing to my method on AWS API gateway and account linking details. Afterwards I clicked on "Test" in order to make the Smart Home action testable in the Google Home companion app.
I can see my Smart Home action "[test] ACTIONNAME" in the Google Home companion app when trying to add new devices. When I click on the action, I get redirected correctly to my OAuth 2 provider, log in and get redirected to the Google Home app. It then shows a notification on the bottom "[test] ist verknüpft" (German saying "[test] ACTIONNAME got linked"). Shortly after that, it shows a second notification "Ein Fehler ist aufgetreten. Bitte versuche es noch einmal" (German saying "An error occured. Please try again". When I click the action again, it says again "[test] ACTIONNAME got linked" followed by the second notification "An error occured. Please try again", so no need to login again as Google Home obviously already got a token successfully.
I already checked my AWS Cloud Watch logs and I can see that whenever I click on the action in the "Add new device" dialog of the Google Home companion app, Google successfully calls my fulfillment, receiving a SYNC response with 200 status code which looks like the following (anonymized):
{
"statusCode": 200,
"body": "{\"requestId\":\"6541496806317265099\",\"payload\":{\"agentUserId\":\"1234\",\"devices\":[{\"id\":\device_id",\"type\":\"action.devices.types.SHUTTER\",\"traits\":[\"action.devices.traits.OpenClose\"],\"name\":{\"name\":\"Device Name\"},\"willReportState\":false,\"attributes\":{\"openDirection\":[\"UP\",\"DOWN\"]}}]}}",
"headers": {
"content-type": "application/json;charset=utf-8"
}
}
So it seems to me that Google Home got successfully authorized and receives a SYNC response but somehow can not process it. But it should be correct, isn't it?
What I also tried is using the Google Smart Home test suite but when doing that, after typing in my AgentUserId and attaching my token receiver service account certificate, It shows a notification that the requestSync method receives a 404 status code with the message "Requested entity was not found.". That also happens, when I try to call the Homegraph API myself via a POST request as in the following:
curl -i -s -X POST -H "Content-Type: application/json" -d "{agentUserId: \"1234\", async: true}" "https://homegraph.googleapis.com/v1/devices:requestSync?key=MYAPIKEY"
I guess thats because Homegraph does not yet know which devices the user with AgentUserId 1234 has as the SYNC message was never processed correctly by Google home.
I am pretty lost and do not know how to gather further information on where the problem sits. Does anyone have an idea on how to get this solved?
Edit: Further pieces of information - I have tried the following additional things: 1. I created a new Actions on Google project with the same configuration - same problem here, did not help. 2. I had a look into the Stackdriver logs for the smart home project on GCP and what is really strange is that there are no logs at all for resource Google Assistant but also no logs in general for the timeslot when I try to link the smart home action in the Google Home app. Shouldn’t it at least log the oauth flow (which seems to work as expected) as well as the SYNC request sent to my fulfillment?
I got it - the simple solution was that the node.js implementation for Google actions expects the AWS API integration to be a lambda PROXY integration which I had not configured like that as one can also see in the SYNC response stated in the question. So just switching to AWS lambda proxy integration solved the problem.