With version 1 this is how I used to communicate with DialogFlow Api!
fetch(configs.baseUrl + \"query?v=20150910\", {
body: JSON.stringify({query: text,
Below is another example of creating your DialogFlow V2 access token using Node.js. The library that is used in the code below is google-oauth-jwt.
const googleAuth = require('google-oauth-jwt');
function generateAccessToken() {
return new Promise((resolve) => {
googleAuth.authenticate(
{
email: ,
key: ,
scopes: 'https://www.googleapis.com/auth/cloud-platform',
},
(err, token) => {
resolve(token);
},
);
});
}
You may find your client_email and private_key from the JSON key file you have downloaded from your Google Cloud Platform project's service account page. If you are unsure how/where to download it, you may checkout my blog post here.
To find out which scope which scope you may need, you may checkout the DialogFlow V2 REST API documentation page.