Smart home google action not responding and device is always offline - node.js

I created a smart home action using action-on-google and nodeJs, and it works fine. When you say turn on switch off, it sends MQTT request to my server, means that onExecute function works fine but the problem is that google doesn't respond to my command by OK it says "sorry it looks like your device not available right now", I observed also that my device is always offline in Google home app. Is it required to work with firebase and get device state from there?

Firebase is one of web services allowed to store a device's states. You can feel free to use other web services.
If your device is offline, it may be because your Google Home App hasn't received your device's states.
Here are two paths for Google Home App receiving your device's data:
Google Server will send a action.devices.QUERY intent and callback your function (e.g. onQuery) to get the data of your device through your fulfillment, see action.devices.QUERY.
Thus, please print logs in the onQuery function and make sure that your function works fine.
Your smart home action must use the API of reportStateAndNotification to update your device's data in the Home Graph, see Method: devices.reportStateAndNotification.
If Google Assistant gives you "Sorry, device is not available right now", it probably is because the Google server hasn't received correct information from your fulfillment. Please follow the suggestions above and try it again.
If you're still having issues, check your logs to identify the particular issue for that device.

Related

Google Assistant Personal Actions

I have created an action inside google, connected it to dialogflow, connected in byt fulfillment to my own home network.
Now I would like to be able to use this on my phone, raspberry, etc. But I don`t want to deploy this to the whole world (because then they can turn off my lights).
How should I do this?
You can release your action to an Alpha channel, which let's you control who can access your action, which is just yourself by default. But you can also add up to twenty accounts.
https://developers.google.com/actions/deploy/release-environments

How to answer a user in Home device and send a notification to user's phone

Is there any way to answer a user question in the Home device and at the same time, send a notification to another device?
For example, if the user ask for a direction, answer with the location (voice) and finish saying to the user:"I've sent you the location to your phone" and send him a map...
I know there is a way to switch conversation to another device (say, for example, one with screen) but I don't want to finish it in Home device.
Thanks in advance.
Not in a straightforward way, no, but there are a few options that you have that may do what you want.
You can try to use Assistant Notifications. Right now, notifications only appear on mobile devices, but even if/when they allow speaker notifications in the future, your user could still open it on a mobile device. You need to ask for permission to send a notification, and when they trigger the notification, an Intent in your Action will be triggered to actually show what you want to show.
You can also look into using a more standard notification channel such as Firebase Cloud Messaging. This does require you to have your own app on the mobile device, and it works outside of the Assistant, but may be a good choice if it meets your needs.

Return response to Google Assistant via API

I have a Actions on Google project that uses api.ai for its actions. This is working well and I can see request/responses appear on the google assistant interface (On mobiles and simulator)
One of my usecases for api.ai needs to broken into 2 parts, in that we have to inform the user that the processing has started and then inform them again once its completed (without them reprompting for the output).
Im trying for a way to inform the user who is using the Google assistant when the processing is completed, but have failed so far. Something like this
User: I would like to see if my loan request is approved
Google Assistant: Hold on, let me check and let u know .
.... (Makes a webservice call to the backend asynchronously)
.... After few seconds ...
.... Postback to google assistant from the webservice
Google Assistant: Thanks for holding, your request is approved.
Im not sure how to do the "postback to google assistant" call. I have tried to get the SessionId from the Api.AI call and then use that to make a event request , but that doesnt seem to send the response to the assistant. Google Assistant seems to be using the formats defined in https://developers.google.com/actions/reference/rest/Shared.Types/AppRequest, but Im unsure how to get the ConversationToken and use that for sending the response back to the user.
Short answer: you can't do that.
Slightly longer answer: At least right now, there is no good way to send a notification. Your Action can only respond to a specific statement from the user. You can say something like "ask again in a minute and I should have a result for you", but that isn't a great experience. At Google I/O 2017, they announced that notifications would be coming to the Google Home at some point... but gave neither a time frame nor any information about an API.
Long, but probably still unsatisfying answer: You can look into Transactions which let them initiate purchase or request of some sort and then "check out". Once they have checked out, you would confirm that a transaction is being processed with an OrderUpdates and then can send updates with the status of the "order". These status updates can turn into notifications or user's can query the state of the order at any time. Transactions don't require payment, so this may work depending on your needs.
However, there are a few things to note. This is still in developer preview, so things may change in the future. It also doesn't work on all surfaces where the Assistant runs, so while it does work on Assistant on phones, it does not work on the Google Home right now.

Hooking up a web service, which can ask things back and receives answers?

Is it somehow possible to call a web service which can ask things back and receives the answer?
Let me explain:
At home, I have a media center with some movies on it. It's content changes over time of course: Files get added, removed, renamed and so on.
Now I’d like to say for example “Hey Google, play wizard of oz” and then wizard of oz should played on my tv.
Since I know how to develop things in .NET, the web service running at home already exists and works fine, movies start. And I guess thanks to API.ai, I should be able connect it via the webhook function to Google Home.
But what if there are multiple results and I want to ask, which result should be picked? For example:
User says "Play Star Wars"
Google Home calls my web service, which checks my disk and finds out that there are multiple Star Wars movies.
Now, the user needs to be asked "There are multiple results. Which one would you like to see? Star Wars: A new hope, Star Wars: The empire strikes back, ..."
The user now answers "Star Wars: A new hope"
Google Home calls the web service again with that info and after success it replies "Okay, playing Star Wars: A new hope."
I haven't found out how to do that with API.ai. As I understand, API.ai calls the web service with some parameters (JSON), sends the response text received from the web service back to Google Home and then just ends.
Or did I miss something? Do you guys have any idea how I could achieve this scenario?
Or can we somehow develop our private services, like the ones listed in the Google Home app (Akinator, Dominos, CNBC, ...) or is that only possible as a partner? Would be nice actually.
Thanks in advance!
As I understand, API.ai calls the web service with some parameters
(JSON), sends the response text received from the web service back to
Google Home and then just ends.
The bot is still in control unless you send from your web service:
data: {
google: {
expect_user_response: false,
}
}
or check this box in API.AI in the intent pane
If you are using the ActionsSDKAssistant, make sure that you are using the right method. Ask vs. Tell
https://developers.google.com/actions/reference/ActionsSdkAssistant#ask
https://developers.google.com/actions/reference/ActionsSdkAssistant#tell
You need to study the API, the api.ai webhook request/response format and implement it. Take a look at this tutorial. Then, of course, you will have to poke a hole in your firewall to be able to receive the calls from Google or use ngrok or the BST proxy.

Custom receiver application doesn't work with whitelisted device

I'm just starting to play with Google Cast, so I downloaded the hellotext Chrome example app. If I open the sender that comes with it, everything works. However, if I take the receiver.html file, upload a copy of my own somewhere, create an app, and then replace the app id in the sender.html, it doesn't work.
The console log says "receiver list empty". I do have my Chromecast (both of them actually) added to my account as test devices. I reset them, both via software and by unplugging and replugging them. I even did a factory reset on one of them, but still no luck.
Googling got me to this response: How to launch a receiver app in Chrome once Chromecast device has been whitelisted?
However, the option to enable (or disable) sending the serial number on update check doesn't seem to exist anymore.
Any ideas?
Thanks!

Resources