Google's documentation is like an ocean. It's not easy to find a right one to start. This note contains only basic things that I've already worked with. Try your own hand at Google's APIs will help you understand more.

👉 Github repo: dinhanhthi/google-api-playground

<aside> ☝️ This note is mainly for Dialogflow APIs. However, I mention also the other services of Google.

</aside>

Official documentation

Some services

<aside> ⚠️ When you use any NodeJS service, for example,

const client = new library.SampleClient(opts?: ClientOptions);

The opts is described here.

</aside>

Wanna run the Node.js samples?{:#run-samples}

👉 Link of all (dialogflow nodejs) samples on github.

<aside> ⚠️ The old version uses [dialogflow](<https://www.npmjs.com/package/dialogflow>) and [@type/dialogflow](<https://www.npmjs.com/package/@types/dialogflow>). The new version uses only one [@google-cloud/dialogflow](<https://www.npmjs.com/package/@google-cloud/dialogflow>)!

</aside>

<aside> ⚠️ On SDK documentation, they don't mention about the location in the parent property. For example, they say "parent can be projects/<Project ID or '-'>", but you can add the location information inside it like that

const parent = (location) => "projects/-" + "/locations/" + location;

</aside>

<aside> ☝️ You have to enable the Dialogflow API in the current project. Other wise, we meet below problem.

7 PERMISSION_DENIED: Dialogflow API has not been used in project 284022294153 before or it is disabled. Enable it by visiting <https://console.developers.google.com/apis/api/dialogflow.googleapis.com/overview?project=284022294153> then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

You can use Service Usage to enable a service on some project programmatically or go to beflow url to active it visually,

<https://console.developers.google.com/apis/api/cloudresourcemanager.googleapis.com/overview?project=><projectId>

</aside>

Wanna try gapi (JS client)?

<aside> ⚠️ Google has announced that they will be discontinuing the Google Sign-In JavaScript Platform Library for web. You will have to switch to using Google Identity Services (or Sign In With Google or gsi). The old service will be completely discontinued on March 31, 2023.

<!-- OLD -->
<script src="<https://apis.google.com/js/platform.js>" async defer></script>

<!-- NEW -->
<script src="<https://accounts.google.com/gsi/client>" async defer></script>

</aside>