Google Assistant SDK - Actions get information from SQL Server - actions-on-google

I'm trying to make my own Google Assistant Actions.
I would like to ask a question. SQL Server is the data source for this. Google Assistant is searching my SQL Server for results. When it finds the result, it reads out the result. Would this be possible? Where can I search or read for more information about how to do this?

What you are looking for is called Actions on Google broadly. Specifically, you're looking to build a conversational action where the user can ask questions that match Intents that you provide to the Assistant to match. When an Intent is matched, the information is passed to your code, which is running as a webhook, to generate a response.
Your webhook can do pretty much whatever you want, as long as you do it quickly enough (in about 5 seconds) and return a response. This can include database queries or any other processing or business logic necessary. Details about doing so for SQL Server are out of the scope for this particular question - but it should be very similar to doing SQL Server queries from any other server you're running.

Related

How to use Google Action Builder with my own server

I want to develop an action to google assistant. So i red the documentation here https://developers.google.com/assistant/conversational/overview and i followed this tutorial https://www.youtube.com/watch?v=Z1hxvniJ18s
It s worked and i was allow to develop and test my app in the simulator. The problem is that when it's come to webhook i don't totaly understand how it's work. On the webhook icon i got this
The seconde one allow me to use Google cloud function and firebase but i had to add my billing account to make it available. I also get a console where i can code my fonctions and my responses.
And if i am correct, the first one allow me to connect to my own Api. But i can only enter one field that is the URL adresse and nothing else so how do i code it? Also i see everywhere people using node.js and i would like to use php is it possible?
To sum up my problem, i would like to know how i could connect my action builder to an other service(Api) than google ones? If it's possible to run my server in php and how do i interact with my google action?(I think it's by sending json back and forth but i'am not sure how to do it?) Finally i would like to know if it's possible to test it in local server with mamp and phpmyadmin for exemple to test the answer of the server?
I would be very grateful if someone could help me, show me how to set up all this.
But i can only enter one field that is the URL adresse and nothing else so how do i code it?
When you develop your webhook, you will need to have a single publicly accessible endpoint to connect with. This endpoint will receive an HTTP POST request and you will need to respond with an appropriate response.
Also i see everywhere people using node.js and i would like to use php is it possible?
Any language that can run on a web server can work. Node.js is one that is used a lot, but PHP can work just as well. You can create an actions.php file and then enter an endpoint address https://example.com/actions.php that will be called. You may need to refer to the Request and Response reference for the expected format.
if it's possible to test it in local server with mamp and phpmyadmin for exemple to test the answer of the server?
It's somewhat possible. You'll need to have some method of sending mock requests to your local server, which might be as easy as using cURL or other tools like Postman.
Unfortunately my personal experience with PHP tools is limited, so I can't necessarily walk-through the specifics. But it does seem like you know these tools a bit more and should be familiar enough to be able to get started.

Emit data to all clients on a Google Web App

I have a Google Apps Script bound to a Google Sheet, and have published that as a Web App. It is restricted to a certain Google Workspace. That Google Sheet is kind of an improvised database for that web app and changes over time. I would like to send the updated data to all clients once the Google sheet gets changed. Is that possible? I don't need a trigger for the edit, since I know in the script when I add new data, so this is the time to send the new data.
Basically the same question can be formulated as follows: We know that we can execute a server-side function from the client with google.script.run, but is it also possible to execute a client-side function from the server i.e. the apps script?
My current workaround is a client-side setInterval which checks for server-side updates (and fetches them using successHandler) every 30 seconds or so. It works, but is not optimal.
Just to mark this one as answered. Cooper writes in the comments:
"It's not possible to execute a client side function from the server unless it has been first initiated by the client and it's responding with a callback. Polling is your only option I think."

How exactly does backend work from a developer perspective?

Theres a ton of videos and websites trying to explain backend vs frontend, but unfortunately none of them explains it in a way that you know how to develop a backend - driven website (at least I haven't found anything good).
So, I wanted to ensure that I understood it and kindly ask you to confirm or correct me on this topic.
Example:
I wanted to build Mini - Google. I have a Database containing 1000 stored websites.
Assumption #1:
Everytime I type something into the search bar, the autofill suggestions change. This means, everytime i type, another website / API gets called returning the current autofill suggestions. On a developer site, this means the website e.g. is a Python script which gets called with the current word typed in as a Parameter and is returning all suggestions as e.g. JSON:
// Client Side Script
function ontype(input):
suggestions = get("https://api.googlemini.com/suggestions?q=" + str(input))
show(suggestions)
Assumption #2:
This also means I could manually call the website containing the Python script, providing a random word and it would always return a JSON containing the autofill suggestions for that word.
Question #1:
If A#1 turns out true but A#2 turns out false, how could I prevent a user from randomly accessing the "API" while still returning results when called by a script?
Assumption #3:
After pressing enter, my website googlemini.com/search?... would be called. As google.com/search reloads everytime searching for a new query (or going to page 2 etc.), I assume, instead of calling an API, when the server gets the client request, it first searches through its database, sorts the results and then returns a whole html as a static webpage:
// Server Side Script
#app.route("/search")
function oncall():
query = getparam("q")
results = searchdatabase(query)
html = buildhtml(results)
return html
Question #2:
Often, I hear (or at least understand it this way) that database and webserver are 2 seperate servers. How would that work? Wouldn't that mean the database server needs to be accessible to the web too (of course it would have security layers etc., but technically it would)? How could I access the database server from the webserver?
Question #3:
Are there, on a technical basis, any other ways to build backend services?
That's it. I would also appreciate any recommendations like videos, websites or others to learn how to technically setup and / or secure backend servers.
Thanks in advance.
For your first question you can yes there is a way to prevent miss use.
What you can do is add identifier to api like Auth token to identify a user and every time a user access the api you can save the count on the server n whenever the count has exceeded a limit within a time span you can reject the call. And the limit can be set in such a way that it doesn't trouble the honest user and punishes the wrong one. There are even more complex and effective methods but this is the basic idea.
For question number to let me explain you a simple concept a database is a very efficient, resourcefull and expensive data storage solution we never want it to be used in a general sense as varible store or something. We always want to access the database in call get the data process the data update the data. So we do it data way and its not necessary you make sepreate server for data base. The thing is we mostly make databse to be accessible to various platforms android, ios, windows. So its better to add some abstraction and keep data base as a separte entity.
For the last, I am not well aware about what you meant by other but I am listing some backend teechnologies, some of these might be used in isolation some of these not some other tools as well.
Django
FLask
Djnago rest
GraphQL
SQL
PHP
Node
Deno

How to respond to "help" on Google Assistant?

I got the following feedback from Google team:
When a user says "help" to your agent, it does not actually provide any guidance for what a user can say or ask for, it just says "sure, assistants are here to help"
My webhook is implemented in Spring Boot. Any idea how my web service can respond to help requests?
Since you're using API.AI, that sounds like it might be one of the default responses that are built-in to the Small Talk Domain. You'll probably want to do two things:
Turn off the Small Talk Domain by clicking on the Domains menu on the left and then turning the switch on the Small Talk domain (it should be the first one) off.
Make your own Intent to handle the "help" command (and possibly a few other related statements) by setting these in the User Says section of the Intent. You can have this intent fulfilled by sending it to your webhook by checking the Use Webhook box in the Fulfillment section, but for simple text responses this probably isn't necessary. Just have the Intent return a short help message describing what can be done by adding text to the Response area.
Some suggestions and things to consider when writing your help intent or intents:
Make the response relatively short. This is text that, when read, can't be interrupted.
Consider context-sensitive help by using Input Contexts to determine the state of the conversation at that moment. A user asking for help after a particular prompt should get information that helps them at that prompt.
Allow for multiple ways to ask for help in the User Says section. Phrases like "I'm confused" may also be good to trigger help.
Allow for asking for help on specific topics by using multiple intents that provide different answers. These may be tied to the Contexts as well.

Google SQL Cloud operations callback?

I currently have an application which triggers import jobs to Google SQL Cloud using the their API:
https://cloud.google.com/sql/docs/admin-api/v1beta4/instances/import
This works great. However, this is only a request to import an SQL file. I have to check that the request was successful a minute or two afterwards.
What I would like, is to somehow register a callback to notify my application when the operation is complete. Then I can delete the bucket item and mark the data as persisted.
I have no idea if this is possible, but would be grateful for any advice. Perhaps the PubSub system API could be used for this, but so far have been unable to find any documentation on how this would be done.
There's currently no out of the box way to do this. You need to poll the operation status to determine when it's finished.