Understanding Actions on Google and GCP Datastore Collaboration

Asked 2 years ago, Updated 2 years ago, 56 views

I am a beginner at Actions on Google.
I would like to collaborate between Actions on Google and the GCP datastore.
Specifically, we would like to take the opportunity to retrieve the data in the GCP datastore and respond to the results.

In that case, is it correct to use Dialogflow (Fulfillment)?
Please let me know if there is the easiest way.

Also, I would appreciate it if you could provide me with a sample code.

Thank you for your cooperation.

google-cloud

2022-09-30 20:12

1 Answers

Using Dialogflow's Fulfillment, Actions on Google can easily work with GCP datastores.The Fulfillment configuration allows you to work with datastores using the Inline Editor.

The connection to the datastore remains the same as it is normally used by Node.js.Connecting to the datastore requires a package called @google-cloud/datastore, so add it to dependencies in package.json.

If your datastore is the same as the project that Dialogflow uses, you can connect without authentication.In that case, if you are searching by key, you can write:

const Datastore=require('@Google-cloud/datastore');
const datastore=Datastore()


const taskKey=datastore.key(['kind','name']);
datastore.get(taskKey).then(results=>{
    constancy=results[0];
    // Write Processing
});

If you use the Inline Editor, you will be using Cloud Functions for Firebase, so I think the one you created in the Inline Editor will work with Cloud Functions for Firebase.I think the Cloud Functions of GCP will work with just a few modifications.


2022-09-30 20:12

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.