r/GoogleAssistantDev • • 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

3 Upvotes

6 comments sorted by

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.

1

u/tomushky Jun 25 '19

Thank you very much for your reply. I'm only concerned about scalability. I'm using it for a job-board like web app. The VUI will be used as webapp guide and also as a booking form.

Zu

1

u/afirstenberg GDE Jun 25 '19

Definitely take a look at what u/RealBass posted as well.

The best thing I can come up with to deal with scalability is that the number used to connect the Action and web page could just be a number used to start the connection. Once started, it could get a longer, and more unique, number that could be stored as a cookie in the browser and as user information on the Action, so you don't need to do a link-up again.

1

u/polohero Jun 28 '19

You shouldn't have to store anything anywhere. DialogFlow has client SDKs where you can pass text to it and get a response that looks just like the request your action gets (tells you the entities and the intents etc..).

The tricky part is converting the voice to text. Chrome has built in JavaScript support to record and get text (I believe Firefox does too, but not Sarfari). Then hand that off to the Dialogflow client SDK.

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.

https://dialogflow.com/docs/sdks