r/GoogleAssistantDev • u/tomushky • Jun 23 '19
As a Developer, how to use Google Assistant to navigate a web app?
I saw an article showing how to program a Google Home Assistant to navigate a photos site ( https://blog.prototypr.io/using-voice-to-control-a-website-with-google-home-part-1-3-d2355327f250 ) but as a developer, how can I use Google Actions to add navigation controls to my web app? Kind of a Assistant Action specifically made to navigate a site. Can you please help me to find some useful info about this topic? Thank you
2
u/polohero Jun 28 '19 edited Jun 28 '19
Use the dialogflow SDK for whatever back end service you're using (I think there's even a JavaScript SDK) and you can return the results to the JavaScript to handle it.
The have client libraries. So, you use the recording feature inside Chrome (https://developers.google.com/web/updates/2013/01/Voice-Driven-Web-Apps-Introduction-to-the-Web-Speech-API) then hand off the text to the dialog flow to parse it and return the intents/entities and handle it.
3
u/afirstenberg GDE Jun 24 '19
Well, the article you pointed to provides a bunch of useful information about the topic. Was there something about it that didn't make sense to you or that you wanted to clarify?
The underlying principle of it is:
You use the Action to set some value in a database
The webapp listens for a change in the database
When it detects a change, it changes what is shown
If you're using a React app, for example, this would just be a change in state that triggers the appropriate re-rendering based on the new state. But no matter how you've implemented the webapp, it boils down to getting the update from the database, and changing something.
The biggest issue is doing this securely. As the article writer notes, what they propose isn't secure, since it only saves the value in one place, and every viewer accesses the same field. You need some way so that each person that starts the Action updates a different field, and the same person can look at the web page that accesses that field.
I'm sure there are a few ways to do it - one way is to have the Action give a unique number you enter into the web page. Another is to have the web page report the number that you use to start the action. Neither way scales well, however, and I'd love to find a better solution.