Détail du package

@google-cloud/dialogflow-cx

googleapis46.7kApache-2.05.1.0

Cx client for Node.js

google apis client, google api client, google apis, google api

readme

Google Cloud Platform logo

Dialogflow CX API: Node.js Client

release level npm version

Cx client for Node.js

A comprehensive list of changes in each version may be found in the CHANGELOG.

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][projects].
  2. [Enable billing for your project][billing].
  3. [Enable the Dialogflow CX API API][enable_api].
  4. [Set up authentication][auth] so you can access the API from your local workstation.

Installing the client library

npm install @google-cloud/dialogflow-cx

Using the client library

/**
 * TODO(developer): Uncomment these variables before running the sample.
 */
// const projectId = 'my-project';
// const location = 'global';
// const agentId = 'my-agent';
// const audioFileName = '/path/to/audio.raw';
// const encoding = 'AUDIO_ENCODING_LINEAR_16';
// const sampleRateHertz = 16000;
// const languageCode = 'en'

// Imports the Google Cloud Some API library
const {SessionsClient} = require('@google-cloud/dialogflow-cx');
/**
 * Example for regional endpoint:
 *   const location = 'us-central1'
 *   const client = new SessionsClient({apiEndpoint: 'us-central1-dialogflow.googleapis.com'})
 */
const client = new SessionsClient();

const fs = require('fs');
const util = require('util');
// Assumes uuid module has been installed from npm,
// npm i uuid:
const {v4} = require('uuid');

async function detectIntentAudio() {
  const sessionId = v4();
  const sessionPath = client.projectLocationAgentSessionPath(
    projectId,
    location,
    agentId,
    sessionId
  );

  // Read the content of the audio file and send it as part of the request.
  const readFile = util.promisify(fs.readFile);
  const inputAudio = await readFile(audioFileName);

  const request = {
    session: sessionPath,
    queryInput: {
      audio: {
        config: {
          audioEncoding: encoding,
          sampleRateHertz: sampleRateHertz,
        },
        audio: inputAudio,
      },
      languageCode,
    },
  };
  const [response] = await client.detectIntent(request);
  console.log(`User Query: ${response.queryResult.transcript}`);
  for (const message of response.queryResult.responseMessages) {
    if (message.text) {
      console.log(`Agent Response: ${message.text.text}`);
    }
  }
  if (response.queryResult.match.intent) {
    console.log(
      `Matched Intent: ${response.queryResult.match.intent.displayName}`
    );
  }
  console.log(
    `Current Page: ${response.queryResult.currentPage.displayName}`
  );
}

detectIntentAudio();

Samples

Samples are in the samples/ directory. Each sample's README.md has instructions for running its sample.

Sample Source Code Try it
Agents.create_agent source code ![Open in Cloud Shell][shell_img]
Agents.delete_agent source code ![Open in Cloud Shell][shell_img]
Agents.export_agent source code ![Open in Cloud Shell][shell_img]
Agents.get_agent source code ![Open in Cloud Shell][shell_img]
Agents.get_agent_validation_result source code ![Open in Cloud Shell][shell_img]
Agents.get_generative_settings source code ![Open in Cloud Shell][shell_img]
Agents.list_agents source code ![Open in Cloud Shell][shell_img]
Agents.restore_agent source code ![Open in Cloud Shell][shell_img]
Agents.update_agent source code ![Open in Cloud Shell][shell_img]
Agents.update_generative_settings source code ![Open in Cloud Shell][shell_img]
Agents.validate_agent source code ![Open in Cloud Shell][shell_img]
Changelogs.get_changelog source code ![Open in Cloud Shell][shell_img]
Changelogs.list_changelogs source code ![Open in Cloud Shell][shell_img]
Deployments.get_deployment source code ![Open in Cloud Shell][shell_img]
Deployments.list_deployments source code ![Open in Cloud Shell][shell_img]
Entity_types.create_entity_type source code ![Open in Cloud Shell][shell_img]
Entity_types.delete_entity_type source code ![Open in Cloud Shell][shell_img]
Entity_types.export_entity_types source code ![Open in Cloud Shell][shell_img]
Entity_types.get_entity_type source code ![Open in Cloud Shell][shell_img]
Entity_types.import_entity_types source code ![Open in Cloud Shell][shell_img]
Entity_types.list_entity_types source code ![Open in Cloud Shell][shell_img]
Entity_types.update_entity_type source code ![Open in Cloud Shell][shell_img]
Environments.create_environment source code ![Open in Cloud Shell][shell_img]
Environments.delete_environment source code ![Open in Cloud Shell][shell_img]
Environments.deploy_flow source code ![Open in Cloud Shell][shell_img]
Environments.get_environment source code ![Open in Cloud Shell][shell_img]
Environments.list_continuous_test_results source code ![Open in Cloud Shell][shell_img]
Environments.list_environments source code ![Open in Cloud Shell][shell_img]
Environments.lookup_environment_history source code ![Open in Cloud Shell][shell_img]
Environments.run_continuous_test source code ![Open in Cloud Shell][shell_img]
Environments.update_environment source code ![Open in Cloud Shell][shell_img]
Experiments.create_experiment source code ![Open in Cloud Shell][shell_img]
Experiments.delete_experiment source code ![Open in Cloud Shell][shell_img]
Experiments.get_experiment source code ![Open in Cloud Shell][shell_img]
Experiments.list_experiments source code ![Open in Cloud Shell][shell_img]
Experiments.start_experiment source code ![Open in Cloud Shell][shell_img]
Experiments.stop_experiment source code ![Open in Cloud Shell][shell_img]
Experiments.update_experiment source code ![Open in Cloud Shell][shell_img]
Flows.create_flow source code ![Open in Cloud Shell][shell_img]
Flows.delete_flow source code ![Open in Cloud Shell][shell_img]
Flows.export_flow source code ![Open in Cloud Shell][shell_img]
Flows.get_flow source code ![Open in Cloud Shell][shell_img]
Flows.get_flow_validation_result source code ![Open in Cloud Shell][shell_img]
Flows.import_flow source code ![Open in Cloud Shell][shell_img]
Flows.list_flows source code ![Open in Cloud Shell][shell_img]
Flows.train_flow source code ![Open in Cloud Shell][shell_img]
Flows.update_flow source code ![Open in Cloud Shell][shell_img]
Flows.validate_flow source code ![Open in Cloud Shell][shell_img]
Generators.create_generator source code ![Open in Cloud Shell][shell_img]
Generators.delete_generator source code ![Open in Cloud Shell][shell_img]
Generators.get_generator source code ![Open in Cloud Shell][shell_img]
Generators.list_generators source code ![Open in Cloud Shell][shell_img]
Generators.update_generator source code ![Open in Cloud Shell][shell_img]
Intents.create_intent source code ![Open in Cloud Shell][shell_img]
Intents.delete_intent source code ![Open in Cloud Shell][shell_img]
Intents.export_intents source code ![Open in Cloud Shell][shell_img]
Intents.get_intent source code ![Open in Cloud Shell][shell_img]
Intents.import_intents source code ![Open in Cloud Shell][shell_img]
Intents.list_intents source code ![Open in Cloud Shell][shell_img]
Intents.update_intent source code ![Open in Cloud Shell][shell_img]
Pages.create_page source code ![Open in Cloud Shell][shell_img]
Pages.delete_page source code ![Open in Cloud Shell][shell_img]
Pages.get_page source code ![Open in Cloud Shell][shell_img]
Pages.list_pages source code ![Open in Cloud Shell][shell_img]
Pages.update_page source code ![Open in Cloud Shell][shell_img]
Security_settings_service.create_security_settings source code ![Open in Cloud Shell][shell_img]
Security_settings_service.delete_security_settings source code ![Open in Cloud Shell][shell_img]
Security_settings_service.get_security_settings source code ![Open in Cloud Shell][shell_img]
Security_settings_service.list_security_settings source code ![Open in Cloud Shell][shell_img]
Security_settings_service.update_security_settings source code ![Open in Cloud Shell][shell_img]
Session_entity_types.create_session_entity_type source code ![Open in Cloud Shell][shell_img]
Session_entity_types.delete_session_entity_type source code ![Open in Cloud Shell][shell_img]
Session_entity_types.get_session_entity_type source code ![Open in Cloud Shell][shell_img]
Session_entity_types.list_session_entity_types source code ![Open in Cloud Shell][shell_img]
Session_entity_types.update_session_entity_type source code ![Open in Cloud Shell][shell_img]
Sessions.detect_intent source code ![Open in Cloud Shell][shell_img]
Sessions.fulfill_intent source code ![Open in Cloud Shell][shell_img]
Sessions.match_intent source code ![Open in Cloud Shell][shell_img]
Sessions.server_streaming_detect_intent source code ![Open in Cloud Shell][shell_img]
Sessions.streaming_detect_intent source code ![Open in Cloud Shell][shell_img]
Sessions.submit_answer_feedback source code ![Open in Cloud Shell][shell_img]
Test_cases.batch_delete_test_cases source code ![Open in Cloud Shell][shell_img]
Test_cases.batch_run_test_cases source code ![Open in Cloud Shell][shell_img]
Test_cases.calculate_coverage source code ![Open in Cloud Shell][shell_img]
Test_cases.create_test_case source code ![Open in Cloud Shell][shell_img]
Test_cases.export_test_cases source code ![Open in Cloud Shell][shell_img]
Test_cases.get_test_case source code ![Open in Cloud Shell][shell_img]
Test_cases.get_test_case_result source code ![Open in Cloud Shell][shell_img]
Test_cases.import_test_cases source code ![Open in Cloud Shell][shell_img]
Test_cases.list_test_case_results source code ![Open in Cloud Shell][shell_img]
Test_cases.list_test_cases source code ![Open in Cloud Shell][shell_img]
Test_cases.run_test_case source code ![Open in Cloud Shell][shell_img]
Test_cases.update_test_case source code ![Open in Cloud Shell][shell_img]
Transition_route_groups.create_transition_route_group source code ![Open in Cloud Shell][shell_img]
Transition_route_groups.delete_transition_route_group source code ![Open in Cloud Shell][shell_img]
Transition_route_groups.get_transition_route_group source code ![Open in Cloud Shell][shell_img]
Transition_route_groups.list_transition_route_groups source code ![Open in Cloud Shell][shell_img]
Transition_route_groups.update_transition_route_group source code ![Open in Cloud Shell][shell_img]
Versions.compare_versions source code ![Open in Cloud Shell][shell_img]
Versions.create_version source code ![Open in Cloud Shell][shell_img]
Versions.delete_version source code ![Open in Cloud Shell][shell_img]
Versions.get_version source code ![Open in Cloud Shell][shell_img]
Versions.list_versions source code ![Open in Cloud Shell][shell_img]
Versions.load_version source code ![Open in Cloud Shell][shell_img]
Versions.update_version source code ![Open in Cloud Shell][shell_img]
Webhooks.create_webhook source code ![Open in Cloud Shell][shell_img]
Webhooks.delete_webhook source code ![Open in Cloud Shell][shell_img]
Webhooks.get_webhook source code ![Open in Cloud Shell][shell_img]
Webhooks.list_webhooks source code ![Open in Cloud Shell][shell_img]
Webhooks.update_webhook source code ![Open in Cloud Shell][shell_img]
Agents.create_agent source code ![Open in Cloud Shell][shell_img]
Agents.delete_agent source code ![Open in Cloud Shell][shell_img]
Agents.export_agent source code ![Open in Cloud Shell][shell_img]
Agents.get_agent source code ![Open in Cloud Shell][shell_img]
Agents.get_agent_validation_result source code ![Open in Cloud Shell][shell_img]
Agents.get_generative_settings source code ![Open in Cloud Shell][shell_img]
Agents.list_agents source code ![Open in Cloud Shell][shell_img]
Agents.restore_agent source code ![Open in Cloud Shell][shell_img]
Agents.update_agent source code ![Open in Cloud Shell][shell_img]
Agents.update_generative_settings [source code](h

changelog

Changelog

5.1.0 (2025-06-03)

Features

  • Add protobufjs 2023 edition support (b3bd921)

5.0.1 (2025-03-21)

Bug Fixes

  • [Many APIs] await/catch promises, and update listOperationsAsync return type (#6185) (ab30412)

5.0.0 (2025-03-18)

⚠ BREAKING CHANGES

  • upgrade to Node 18 (#6096)

Features

  • [dialogflow-cx] Change client_secret in OAuthConfig from required to optional (#6119) (3f75a90)

Miscellaneous Chores

4.10.0 (2025-02-28)

Features

  • [dialogflow-cx] added support for handlers (#6055) (3773a8c)
  • [dialogflow-cx] exposed Zone Separation & Zone Isolation status of an agent (#6062) (9b7a778)

4.9.0 (2024-11-14)

Features

  • [dialogflow-cx] add options of client_certificate_settings, bigquery_export_settings, bearer_token_config and boost_control_spec; add support of ALAW encoding (#5787) (49e8cd1)

4.8.0 (2024-08-09)

Features

  • [dialogflow-cx] exposed DataStoreConnectionSignals (#5567) (b961ff9)

4.7.0 (2024-05-21)

Features

  • [dialogflow-cx] update Nodejs generator to send API versions in headers for GAPICs (#5331) (74a4454)
  • [Many APIs] update Nodejs generator to send API versions in headers for GAPICs (#5351) (01f48fc)
  • [Many APIs] update Nodejs generator to send API versions in headers for GAPICs (#5354) (a9784ed)

4.6.0 (2024-04-16)

Features

  • [Many APIs] add several fields to manage state of database encryption update (#5188) (c5ccdf9)

4.5.0 (2024-04-05)

Features

  • [dialogflow-cx] added support for DataStoreConnection, DataStoreConnectionSettings (#5196) (e81cd49)

4.4.0 (2024-02-09)

Features

  • [dialogflow-cx] A new field opt_out_conformer_model_migration is added to message .google.cloud.dialogflow.cx.v3.InputAudioConfig (#5034) (47fb485)

4.3.1 (2024-01-23)

Bug Fixes

  • [Many APIs] improve retry logic for streaming API calls (#4964) (34bd4e2)

4.3.0 (2023-11-30)

Features

4.2.0 (2023-10-18)

Features

  • [dialogflow-cx] add support for AdvancedSettings (#4718) (b94abd9)

4.1.0 (2023-09-06)

Features

  • [dialogflow-cx] added agent level route group (#4528) (79da1cb)
  • [dialogflow-cx] added generative AI, safety/security and speech endpointing settings (#4597) (684d671)

Bug Fixes

  • [Many APIs] simplify logic for HTTP/1.1 REST fallback option (#4585) (b6cea45)

4.0.0 (2023-08-06)

⚠ BREAKING CHANGES

  • migrate to Node 14 (#4443)

Bug Fixes

Miscellaneous Chores

3.8.0 (2023-07-11)

Features

  • [dialogflow-cx] added GitIntegrationSettings to the Agent (#4404) (88e5a03)

3.7.0 (2023-06-28)

Features

  • [dialogflow-cx] added include_bigquery_export_settings to ExportAgentRequest (7778345)
  • [dialogflow-cx] added include_bigquery_export_settings to ExportAgentRequest (#4357) (7778345)
  • Added session_ttl to SessionProto (7778345)
  • Added session_ttl to SessionProto (7778345)

3.6.0 (2023-06-14)

Features

  • [dialogflow-cx] add support for flexible webhook (64af37a)
  • [dialogflow-cx] add support for flexible webhook (#4334) (64af37a)

3.5.0 (2023-05-11)

Features

  • [dialogflow-cx] extended CreateAgent timeout to 180 seconds (22d6aa5)
  • [dialogflow-cx] extended CreateAgent timeout to 180 seconds (#4253) (22d6aa5)
  • Added debug info to StreamingDetectIntent (22d6aa5)
  • Added debug info to StreamingDetectIntent (22d6aa5)
  • Added dtmf digits to WebhookRequest (22d6aa5)
  • Added dtmf digits to WebhookRequest (22d6aa5)
  • Added FLOW as a new DiffType in TestRunDifference (22d6aa5)
  • Added FLOW as a new DiffType in TestRunDifference (22d6aa5)

3.4.2 (2023-04-13)

Bug Fixes

3.4.1 (2023-03-06)

Bug Fixes

  • [dialogflow-cx] change java package of Cloud Build v2 (#4055) (26e5144)

3.4.0 (2023-03-01)

Features

  • [dialogflow-cx] Added persist_parameter_changes field from query_params to MatchIntentRequest (#4031) (ebaed20)

3.3.0 (2023-02-23)

Features

  • [dialogflow-cx] added gcs.proto. added support for GcsDestination and TextToSpeechSettings (#3998) (f98ece2)

3.2.1 (2023-02-15)

Bug Fixes

  • [Many APIs] changing format of the jsdoc links (#3987) (07043a6)

3.2.0 (2023-01-28)

Features

  • Added JSON_PACKAGE field to ExportAgentRequest (#3876) (638ba10)
  • Added JSON_PACKAGE field to ExportAgentRequest (#3882) (cfe55a5)
  • ResponseMessage proto contains channel information (#3843) (fef1c23)
  • ResponseMessage proto contains channel information (#3848) (618fd54)

3.1.2 (2022-11-11)

Bug Fixes

3.1.1 (2022-09-14)

Bug Fixes

3.1.0 (2022-07-08)

Features

Bug Fixes

  • fixes for dynamic routing and streaming descriptors (03c33b8)

3.0.0 (2022-06-23)

⚠ BREAKING CHANGES

  • update library to use Node 12 (#288)

Features

  • add Webhook samples (#259) (709dc6d)
  • added audio_export_settings (#257) (39f1d1c)
  • added data format specification for export agent (361e7d9)
  • added data format specification for export agent (361e7d9)
  • added page in TestConfig (7adaf67)
  • added page in TestConfig (#239) (283c389)
  • added support for locking an agent for changes (361e7d9)
  • added support for locking an agent for changes (361e7d9)

Build System

2.15.0 (2022-01-19)

Features

  • added TelephonyTransferCall in response message (#207) (8859e3f)
  • added API for changelogs docs: clarified semantic of the streaming APIs (#197) (4f88255)
  • added API for changelogs docs: clarified semantic of the streaming APIs (#198) (9882149)
  • added deployment API feat: exposed DTMF input info in the query result docs: added notes on long running operation (#191) (5460ad4)
  • added support for TelephonyTransferCall (#206) (17089de)
  • added support for comparing between versions docs: clarified security settings API reference (#201) (f4ca7e2)
  • added support for DeployFlow api under Environments (5460ad4)
  • added support for Deployments with ListDeployments and GetDeployment apis (5460ad4)
  • added support for TestCasesConfig under Environment (5460ad4)
  • added the display name of the current page in webhook requests (#211) (ae9b5ee)
  • added the display name of the current page in webhook requests (#212) (349bc41)
  • allow setting custom CA for generic webhooks (#203) (f5d8155)
  • expose dtmf input info in the query result (5460ad4)

Bug Fixes

  • marked resource name of security setting as not-required (5460ad4)

2.14.0 (2021-09-21)

Features

  • turns on self-signed JWT feature flag (#167) (a474169)

2.13.0 (2021-08-17)

Features

  • add advanced settings for agent level feat: add rollout config, state and failure reason for experiment feat: add insights export settings for security setting feat: add language code for streaming recognition result and flow versions for query p... (#156) (80d2f94)
  • added support for DLP templates; expose Locations service to get/list avaliable locations of Dialogflow products (#162) (b77bde9)

Bug Fixes

2.12.1 (2021-07-21)

Bug Fixes

  • deps: google-gax v2.17.1 (#148) (5e1ec0a)
  • Updating WORKSPACE files to use the newest version of the Typescript generator. (#150) (8974183)

2.12.0 (2021-06-30)

Features

  • mark agent.default_language_code as required feat: add return_partial response to Fulfillment docs: add notes to train agent before sending queries (#140) (eae8f44)

Bug Fixes

2.11.0 (2021-06-21)

Features

  • v3beta1: Support partial response feature (ee8a24a)
  • v3beta1: support sentiment analysis in bot testing (#127) (2c45b2c)

Bug Fixes

  • v3beta1: set agent default language code as required (#134) (ee8a24a)

2.10.0 (2021-06-17)

Features

  • v3: support sentiment analysis in bot testing (#125) (d6d7684)

2.9.0 (2021-06-14)

Features

  • added API for running continuous test (#123) (248ae74)

2.8.1 (2021-06-10)

Bug Fixes

  • GoogleAdsError missing using generator version after 1.3.0 (#122) (af8ca45)

2.8.0 (2021-05-25)

Features

2.7.0 (2021-05-10)

Features

  • add support for service directory webhooks (#110) (d4b87a5)
  • add support for service directory webhooks (#113) (2ce89d5)

Bug Fixes

2.6.0 (2021-05-05)

Features

  • Expose supported languages of the agent; feat: add export / import flow API docs: Update docs on Pages, Session, Version, etc. (#104) (c7ac26e)

2.5.0 (2021-04-28)

Features

  • Expose supported languages of the agent; feat: add export / import flow API docs: Update docs on Pages, Session, Version, etc. (#103) (daa06ab)
  • include original user query in WebhookRequest; add GetTextCaseresult API. (528192e)
  • include original user query in WebhookRequest; add GetTextCaseresult API. doc: clarify resource format for session response. (#82) (ff13a97)
  • support setting current_page to resume sessions; expose transition_route_groups in flows and language_code in webhook (#90) (53f1e21)
  • support setting current_page to resume sessions; expose transition_route_groups in flows and language_code in webhook (#91) (cd125d3)

2.4.0 (2021-03-15)

Features

  • added fallback option when restoring an agent docs: clarified experiment length (f90bb9c)
  • added fallback option when restoring an agent docs: clarified experiment length (f90bb9c)
  • allow to disable webhook invocation per request (f90bb9c)
  • allow to disable webhook invocation per request (3b1b674)
  • supports SentimentAnalysisResult in webhook request, add http rules for long running operations docs: minor (3b1b674)

Bug Fixes

  • RunTestCase http template. PHP REST client lib can be generated. feat: Support transition route group coverage for Test Cases. feat: Support SentimentAnalysisResult input in the WebhookRequest. (3b1b674)

2.3.0 (2021-03-01)

Features

  • Add new Experiment service docs: minor doc update on redact field in intent.proto and page.proto (63933cd)
  • Add new Experiment service docs: minor doc update on redact field in intent.proto and page.proto (63933cd)
  • added support for test cases and agent validation (#53) (63933cd)
  • docs: promote to ga (#63) (38acf82)
  • supports SentimentAnalysisResult in webhook request docs: minor updates in wording (#62) (1e167ab)

2.2.0 (2021-01-09)

Features

  • adds style enumeration (#49) (6d65571)
  • allowed custom to specify webhook headers through query parameters docs: suggested to always use version for production traffic when calling DetectIntent (#44) (0ffd0b7)
  • expose Security Settings API. (#46) (f6460ce)

2.1.0 (2020-11-25)

Features

2.0.0 (2020-11-19)

⚠ BREAKING CHANGES

  • move to v3 API surface (#35)

Features

1.2.0 (2020-11-17)

Features

  • adds event to MessageType (999d156)

Bug Fixes

  • do not modify options object, use defaultScopes (#27) (a0124c7)

1.1.0 (2020-10-14)

Features

  • samples: examples of dialogflow-cx in action (8b7b018)

1.0.0 (2020-08-25)

⚠ BREAKING CHANGES

  • initial full generation of library (#1)

Features

  • initial full generation of library (#1) (f7dbf85)
  • initial library generation (37c6b13)