Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dialogflow V2 API sample #1200

Closed
joseparoli opened this issue Jun 1, 2018 · 3 comments
Closed

Dialogflow V2 API sample #1200

joseparoli opened this issue Jun 1, 2018 · 3 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue. web

Comments

@joseparoli
Copy link

Hi!
Can we have a Dialogflow V2 API sample?
Thanks!

@JustinBeckwith
Copy link
Contributor

Greetings! If you're using Dialogflow, I would highly recommend using this library instead :)
https://github.com/dialogflow/dialogflow-nodejs-client-v2

@JustinBeckwith JustinBeckwith added the type: question Request for information or clarification. Not an issue. label Jun 1, 2018
@ballwood
Copy link

ballwood commented Jun 6, 2018

@JustinBeckwith there's issues with the dialogflow-nodejs-client-v2, one we found is we can't use it on AWS Lambda without loads of workarounds as we're webpacking our deps to minimize the size of them.

google-api-nodejs-client is all Axios REST so doesn't require dynamically loaded protobuf files from locations on the filesystem, so makes sense to use it instead of complex Webpack configurations/file copying.

@joseparoli Here's simple example. Took me ages to work out how to do it - the path parameters were confusing as you expect it to just be [projectId] (see the parent param)...but its more like a url path: /projects/[projectId]. Once you've got that down you can always find them at the top of the docs e.g. here

'use strict';

const {google} = require('googleapis');
const path = require('path');

async function runSample () {

  const client = await google.auth.getClient({
    keyFile: path.join(__dirname, 'key.json'),
    scopes: 'https://www.googleapis.com/auth/cloud-platform'
  });

  const dialogflow = google.dialogflow({
    version: 'v2',
    auth: client
  });

  const result = await dialogflow.projects.getAgent({
    parent: 'projects/<your-project-id>'
  });

  console.log(result.data);

}

if (module === require.main) {
  runSample().catch(console.error);
}

// Exports for unit testing purposes
module.exports = { runSample };

@JustinBeckwith
Copy link
Contributor

Thanks for sharing the code sample, and thanks for sharing your reasoning. Just as a heads up - now that we ship TypeScript types, you can always look at the typed parameter object to figure out what you're supposed to pass into these methods :)

@joseparoli I'm going to close this out for now. If you need any other help... please do let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue. web
Projects
None yet
Development

No branches or pull requests

3 participants