Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

dialogflow

googleapis19.7kApache-2.01.2.0TypeScript support: included

Dialogflow API client for Node.js

google apis client, google api client, google apis, google api, google, google cloud platform, google cloud, cloud, google dialogflow, dialogflow, Dialogflow API

readme

Google Cloud Platform logo

Dialogflow API: Node.js Client

release level npm version codecov

IMPORTANT NOTE

Version 2.0.0 renames dialogflow to @google-cloud/dialogflow on npm, along with introducing TypeScript types.

Dialogflow API client for Node.js

Read more about the client libraries for Cloud APIs, including the older Google APIs Client Libraries, in Client Libraries Explained.

Table of contents:

Quickstart

Before you begin

  1. Select or create a Cloud Platform project.
  2. Enable billing for your project.
  3. Enable the Dialogflow API.
  4. Set up authentication with a service account so you can access the API from your local workstation.

Installing the client library

npm install dialogflow

Using the client library


const dialogflow = require('dialogflow');
const uuid = require('uuid');

/**
 * Send a query to the dialogflow agent, and return the query result.
 * @param {string} projectId The project to be used
 */
async function runSample(projectId = 'your-project-id') {
  // A unique identifier for the given session
  const sessionId = uuid.v4();

  // Create a new session
  const sessionClient = new dialogflow.SessionsClient();
  const sessionPath = sessionClient.sessionPath(projectId, sessionId);

  // The text query request.
  const request = {
    session: sessionPath,
    queryInput: {
      text: {
        // The query to send to the dialogflow agent
        text: 'hello',
        // The language used by the client (en-US)
        languageCode: 'en-US',
      },
    },
  };

  // Send request and log result
  const responses = await sessionClient.detectIntent(request);
  console.log('Detected intent');
  const result = responses[0].queryResult;
  console.log(`  Query: ${result.queryText}`);
  console.log(`  Response: ${result.fulfillmentText}`);
  if (result.intent) {
    console.log(`  Intent: ${result.intent.displayName}`);
  } else {
    console.log(`  No intent matched.`);
  }
}

Samples

Samples are in the samples/ directory. The samples' README.md has instructions for running the samples.

Sample Source Code Try it
Detect Intent (Text) source code Open in Cloud Shell
Create Knowledge Base source code Open in Cloud Shell
Get Knowledge Base source code Open in Cloud Shell
list Knowledge Base source code Open in Cloud Shell
list Knowledge Base source code Open in Cloud Shell
create Document source code Open in Cloud Shell
list Documents source code Open in Cloud Shell
Get Document source code Open in Cloud Shell
delete Document source code Open in Cloud Shell
detect Intent with sentiment analysis source code Open in Cloud Shell
detect Intent with text-to-speech response source code Open in Cloud Shell
detect Intent with Knowledge Base source code Open in Cloud Shell
Detect Intent (Audio) source code Open in Cloud Shell
Detect Intent (Streaming) source code Open in Cloud Shell
Create Entity source code Open in Cloud Shell
Delete Entity source code Open in Cloud Shell
Create Intent source code Open in Cloud Shell
Delete Intent source code Open in Cloud Shell
Create Context source code Open in Cloud Shell
Delete Context source code Open in Cloud Shell
Create Session Entity Type source code Open in Cloud Shell
Delete Session Entity Type source code Open in Cloud Shell

The Dialogflow API Node.js Client API Reference documentation also contains samples.

Versioning

This library follows Semantic Versioning.

This library is considered to be General Availability (GA). This means it is stable; the code surface will not change in backwards-incompatible ways unless absolutely necessary (e.g. because of critical security issues) or with an extensive deprecation period. Issues and requests against GA libraries are addressed with the highest priority.

More Information: Google Cloud Platform Launch Stages

Contributing

Contributions welcome! See the Contributing Guide.

License

Apache Version 2.0

See LICENSE

changelog

Changelog

npm history

1.2.0 (2020-02-07)

Features

  • docs: add deprecation message to version 1.x.x README (#526) (5474ec1)

1.1.2 (2020-01-28)

Bug Fixes

  • enum, bytes, and Long types now accept strings (79bc7bc)

1.1.1 (2020-01-09)

Bug Fixes

  • proto updates, no code changes (1388648)

1.1.0 (2020-01-05)

Features

Bug Fixes

  • update proto annotations (142ff2b)

1.0.0 (2019-12-05)

Features

  • adds plural and singular resource descriptor (#471) (29e47a6)
  • process: library should be at 1.x (#481) (7d0df44)

Bug Fixes

  • deps: pin TypeScript below 3.7.0 (4dfa20f)
  • deps: update dependency yargs to v15 (#469) (74e847e)
  • docs: bump release level to GA (#475) (59b5d8c)

0.14.1 (2019-11-15)

Bug Fixes

  • import long in proto ts declaration file (#462) (cacd9c8)
  • docs: snippets are now replaced in jsdoc comments (#461) (029146e)

0.14.0 (2019-11-08)

Features

  • add webhooks, BrowseCarouselCard, TableCard and MediaContent (#458) (53051a8)

0.13.0 (2019-11-05)

Features

0.12.2 (2019-10-22)

Bug Fixes

0.12.1 (2019-10-09)

Bug Fixes

  • use compatible version of google-gax (9a0c16a)

0.12.0 (2019-09-16)

Features

  • fuzzy extraction and regexp entities (#430) (60aab0b)

0.11.0 (2019-09-09)

Bug Fixes

  • deps: update dependency yargs to v14 (a9458de)
  • add newlines to JSON protos (bc9bc73)

Features

  • load protos from JSON, grpc-fallback support (8683933)

0.10.3 (2019-07-23)

Bug Fixes

0.10.2 (2019-07-01)

Bug Fixes

0.10.1 (2019-06-14)

Bug Fixes

0.10.0 (2019-06-05)

Features

0.9.1 (2019-05-20)

Bug Fixes

  • DEADLINE_EXCEEDED retry code is idempotent (#343) (d1238f7)
  • remove DEADLINE_EXCEEDED from list of idempotent operations (871070f)
  • deps: update dependency google-gax to v1 (#342) (dead90b)

0.9.0 (2019-05-07)

BREAKING CHANGE

This release drops support for node versions below v8.10.0.

Bug Fixes

  • include 'x-goog-request-params' header in requests (#310) (479defe)
  • deps: update dependency google-gax to ^0.26.0 (#326) (7541e5f)

Build System

Features

  • add the updateDocument andreloadDocument` methods (#315) (6e2defe)
  • support audio config (4ecea0e)

BREAKING CHANGES

  • upgrade engines field to >=8.10.0 (#328)

v0.8.2

03-13-2019 16:30 PDT

Bug Fixes

  • fix: throw on invalid credentials (#281)

Dependencies

  • fix(deps): update dependency google-gax to ^0.25.0 (#269)

Documentation

  • docs: use backticks for JS values (#299)
  • docs: update jsdoc strings and import paths (#298)
  • docs: update links in contrib guide (#283)
  • docs: update contributing path in README (#275)
  • docs: move CONTRIBUTING.md to root (#274)
  • docs: add lint/fix example to contributing guide (#272)
  • docs: fix example comments (#271)

Internal / Testing Changes

  • build: Add docuploader credentials to node publish jobs (#296)
  • build: use node10 to run samples-test, system-test etc (#295)
  • build: update release configuration
  • chore: sync latest proto docs
  • chore(deps): update dependency mocha to v6
  • build: use linkinator for docs test (#282)
  • fix(deps): update dependency yargs to v13 (#280)
  • build: create docs test npm scripts (#279)
  • build: test using @grpc/grpc-js in CI (#276)
  • refactor: improve generated code style. (#270)

v0.8.1

01-28-2019 13:24 PST

Documentation

  • fix(docs): dialogflow isnt published under @google-cloud scope (#266)

v0.8.0

01-28-2019 11:05 PST

Dependencies

  • chore(deps): update dependency eslint-config-prettier to v4 (#261)
  • fix(deps): update dependency google-gax to ^0.24.0 (#260)
  • fix(deps): update dependency google-gax to ^0.23.0 (#256)
  • fix(deps): update dependency google-gax to ^0.22.0 (#217)
  • fix(deps): update dependency google-gax to ^0.21.0 (#215)
  • chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 (#214)
  • chore: remove unused deps (#212)
  • fix(deps): update dependency through2 to v3 (#209)
  • chore(deps): update dependency eslint-plugin-node to v8 (#199)
  • chore(deps): update dependency eslint-plugin-prettier to v3 (#191)

Documentation

  • refactor(samples): convert sample tests from ava to mocha (#222)
  • fix(docs): properly show how to require this module (#263)
  • fix(samples): Fixed typo in example (#179)
  • build: ignore googleapis.com in doc link check (#259)
  • chore: update license year
  • build: check broken links in generated docs (#254)
  • fix(docs): remove unused long running operations types
  • docs: improve the quickstart sample (#234)
  • docs: update the readme (#232)
  • docs(samples): updated samples to use async/await (#228)
  • docs: Strip dynamic badges from README (#184)

Internal / Testing Changes

  • refactor: improve the sample tests (#251)
  • chore(build): inject yoshi automation key (#249)
  • chore: update nyc and eslint configs (#248)
  • chore: fix publish.sh permission +x (#245)
  • fix(build): fix Kokoro release script (#244)
  • build: add Kokoro configs for autorelease (#243)
  • chore: always nyc report before calling codecov (#241)
  • chore: nyc ignore build/test by default (#240)
  • chore: update the renovate config (#237)
  • fix(build): fix system key decryption (#230)
  • chore: add a synth.metadata
  • chore: update eslintignore config (#216)
  • chore: drop contributors from multiple places (#213)
  • chore: use latest npm on Windows (#210)
  • fix: update gRPC timeouts (#208)
  • chore: update CircleCI config (#207)
  • chore: include build in eslintignore (#204)
  • fix: use unique name for sample test knowledge base (#198)
  • chore: update issue templates (#197)
  • chore: remove old issue template (#195)
  • build: run tests on node11 (#194)
  • chores(build): run codecov on continuous builds (#190)
  • chores(build): do not collect sponge.xml from windows builds (#192)
  • chore: update new issue template (#189)
  • build: fix codecov uploading on Kokoro (#183)
  • Update CI config (#180)

v0.7.0

Breaking Changes

  • BREAKING: Drop support for node.js 4.x (#164)

Bug fixes

  • Fix typo in comment (#168)
  • Update old samples to new agent using Room Reservations and match can… (#162)
  • fix(samples/resource): fix intent creation (#104)
  • fix(deps): update dependency google-gax to ^0.20.0 (#142)
  • Remove dependency on @google-cloud/common (#165)
  • Fix typo in word 'session' in detect sample comments (#147)
  • fix(deps): update dependency uuid to v3.3.2 (#122)

New Features

  • Run the synth generator and update config (#161)

Documentation

  • feat(samples): Beta features PR (#144)

Internal / Testing Changes

  • Update kokoro config (#173)
  • test: remove appveyor config (#172)
  • Configure kokoro CI (#171)
  • Enable prefer-const in the eslint config (#167)
  • chore(deps): update dependency eslint-config-prettier to v3 (#148)
  • chore(deps): update dependency eslint-plugin-node to v7 (#135)
  • Ignore package-lock.json (#163)
  • chore(deps): update dependency nyc to v13 (#154)
  • chore: assert.equal => assert.strictEqual (#139)
  • chore(deps): update dependency eslint to v5 (#112)

v0.6.0

New Features

Version v0.6.0 of the Dialogflow NodeJS Client Library brings with it these changes:

  • management of Knowledge base Documents support
  • AudioConfig
  • Intent: Telephony Gateway, supporting
    • TelephonyPlayAudio - plays audio from a file in Telephony Gateway
    • TelephonySynthesizeSpeech - synthesizes speech and plays back the audio to the caller
    • TelephonyTransferCall - transfers the call in Telephony Gateway
  • end_interaction option for Intent and Webhook - indicates that the intent ends an interaction
  • supports alternative query results from KnowledgeService
  • deprecation: Intent: ml_enabled option
  • protos documentation changes

..generated against googleapis/googleapis@9c3174a

Dependencies

  • fix(deps): update dependency yargs to v12 (edited) (#126)
  • chore(deps): update dependency @google-cloud/nodejs-repo-tools to v2.3.1 (#129)
  • fix(deps): update dependency uuid to v3.3.0 (#118)
  • chore(deps): update dependency nyc to v12 (#99)
  • fix(deps): update dependency @google-cloud/common to ^0.20.0 (#98)
  • chore(deps): update node:10 docker digest to 055fe4 (#91)

Documentation

  • fix(samples): update the type of Training phases per (#131)

Internal / Testing Changes

  • chore: drop repo-tools as an exec wrapper (#136)
  • gen: fix synth.py to copy all versions and regenerate (#134)
  • chore(build): synth.py: npm ci; node templates
  • chore(deps): update node:10 docker digest to 1201e1 (#96)
  • Regenerate GAPIC for V1 and V2Beta1 using synth.py (#110)