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

migrate code from googleapis/nodejs-dialogflow #2873

Merged
merged 142 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
00fbbdc
Dialogflow API (#5)
lukesneeringer Nov 15, 2017
fe98017
Fix test cleanup and flaky test (#7)
Nov 15, 2017
d390561
docs: regenerated scaffolding (#31)
alexander-fenster Mar 29, 2018
af84842
chore: release v0.2.0 (#33)
alexander-fenster Mar 29, 2018
225f822
chore: update dependency for google-gax (#38)
alexander-fenster Apr 6, 2018
d0550ac
chore: bump version to 0.2.1 (#39)
alexander-fenster Apr 6, 2018
aec1922
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v1.…
renovate[bot] Apr 8, 2018
6385bcf
chore(deps): update lock file (#51)
renovate[bot] Apr 10, 2018
c73f2c9
bump version to 0.3.0 (#61)
crwilcox Apr 16, 2018
f593585
chore(deps): update dependency ava to ^0.25.0 (#42)
renovate[bot] May 2, 2018
12cb3c4
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v2 …
renovate[bot] May 2, 2018
c99611e
fix(deps): update dependency @google-cloud/common to ^0.18.0 (#43)
renovate[bot] May 2, 2018
9a0c8f2
fix(deps): update dependency uuid to v3.2.1 (#44)
renovate[bot] May 2, 2018
62c5c80
fix(deps): update dependency pump to v3 (#48)
renovate[bot] May 2, 2018
2ce36a7
fix(deps): update dependency yargs to v11 (#49)
renovate[bot] May 2, 2018
02354cc
chore(deps): lock file maintenance (#78)
renovate[bot] May 8, 2018
fd1255c
bump version to 0.4.0 (#73)
crwilcox May 11, 2018
d4f08ac
chore(deps): lock file maintenance (#84)
renovate[bot] May 15, 2018
02e5a53
chore(deps): lock file maintenance (#88)
renovate[bot] May 22, 2018
80bb3c0
bump version to 0.5.0 (#90)
crwilcox May 24, 2018
a9e81cc
chore(deps): lock file maintenance (#93)
renovate[bot] May 29, 2018
00ff8f6
fix(deps): update dependency @google-cloud/common to ^0.20.0 (#98)
renovate[bot] Jun 22, 2018
5d622b5
chore(deps): lock file maintenance (#102)
renovate[bot] Jun 22, 2018
18aa47d
fix(deps): update dependency uuid to v3.3.0 (#118)
renovate[bot] Jun 27, 2018
1c3ffc1
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v2.…
renovate[bot] Jul 12, 2018
d830cf3
gen: fix synth.py to copy all versions and regenerate (#134)
jkwlui Jul 17, 2018
11d4999
fix(samples): update the type of Training phases per (#131)
Jul 17, 2018
38f66d7
fix(deps): update dependency yargs to v12 (edited) (#126)
renovate[bot] Jul 18, 2018
974b039
release: dialogflow-nodejs-client-v2 v0.6.0 (#137)
jkwlui Jul 18, 2018
bd6977d
chore(deps): update dependency eslint to v5 (#112)
renovate[bot] Jul 18, 2018
1f4cba3
fix(deps): update dependency uuid to v3.3.2 (#122)
renovate[bot] Jul 23, 2018
263c666
Beta features PR (#144)
CallistoCF Aug 8, 2018
d190568
Fix typo in word 'session' in detect sample comments (#147)
adamgauthier Aug 12, 2018
cb5ff6e
Run the synth generator and update config (#161)
JustinBeckwith Sep 19, 2018
eb9223a
BREAKING: Drop support for node.js 4.x (#164)
JustinBeckwith Sep 19, 2018
2cfd81d
Remove dependency on @google-cloud/common (#165)
JustinBeckwith Sep 19, 2018
340262a
fix(samples/resource): fix intent creation (#104)
bamaboy Sep 20, 2018
6bbee3a
Enable prefer-const in the eslint config (#167)
JustinBeckwith Sep 20, 2018
a143d54
Update old samples to new agent using Room Reservations and match can…
nnegrey Sep 21, 2018
7724208
Fix typo in comment (#168)
nnegrey Sep 21, 2018
20e3af1
Release v0.7.0 (#178)
JustinBeckwith Oct 2, 2018
ef91731
fix(samples): Fixed typo in example (#179)
arthurjdam Oct 3, 2018
d11ee1c
fix: use unique name for sample test knowledge base (#198)
JustinBeckwith Oct 26, 2018
6b7d55a
fix(deps): update dependency through2 to v3 (#209)
renovate[bot] Nov 7, 2018
fc62da3
chore: remove unused deps (#212)
JustinBeckwith Nov 9, 2018
a4cbac6
chore(deps): update dependency @google-cloud/nodejs-repo-tools to v3 …
renovate[bot] Nov 10, 2018
9a0ca02
refactor(samples): convert sample tests from ava to mocha (#222)
nareshqlogic Nov 19, 2018
236a6aa
docs(samples): updated samples to use async/await (#228)
vijay-qlogic Dec 3, 2018
83c9ce4
docs: improve the quickstart sample (#234)
JustinBeckwith Dec 4, 2018
08f701f
refactor: improve the sample tests (#251)
JustinBeckwith Dec 13, 2018
1f9c599
Release v0.8.0 (#264)
jkwlui Jan 28, 2019
53cfd71
Release v0.8.1 (#267)
jkwlui Jan 28, 2019
c5dcc84
fix(deps): update dependency yargs to v13 (#280)
renovate[bot] Feb 12, 2019
1c97973
chore(deps): update dependency mocha to v6
renovate[bot] Feb 19, 2019
39ab9cd
Release v0.8.2 (#300)
JustinBeckwith Mar 14, 2019
d322dd7
refactor(samples): use pb-util to encode/decode structs (#311)
callmehiphop Mar 28, 2019
b0edf76
docs: fix docs 404 in samples/docs (#316)
bcoe Apr 3, 2019
54bac65
chore: release 0.9.0 (#337)
jkwlui May 8, 2019
32e8ab4
docs(samples): fix description typo (#344)
0xflotus May 16, 2019
301906a
chore: release 0.9.1 (#351)
yoshi-automation May 20, 2019
b717aff
TTS / Sentiment GA (handoff from Nirupa) (#353)
nnegrey May 20, 2019
5d34a68
chore: release 0.10.0 (#364)
yoshi-automation Jun 5, 2019
6d93005
refactor: changes formatting of various statements
yoshi-automation Jun 7, 2019
900a03f
chore: release 0.10.1 (#369)
yoshi-automation Jun 14, 2019
df9be01
chore: release 0.10.2 (#376)
yoshi-automation Jul 1, 2019
34646bf
refactor: replace `execa` with `execSync` in sample tests (#372)
jbdoster Jul 15, 2019
cd680c9
chore: update format and sample tests (#383)
JustinBeckwith Jul 15, 2019
d0205bb
fix(deps): drop dependency on through2 (#388)
JustinBeckwith Jul 22, 2019
f580498
chore: release 0.10.3 (#389)
yoshi-automation Jul 23, 2019
4f3b8fe
fix(deps): update dependency yargs to v14
renovate-bot Aug 20, 2019
782d36d
chore: release 0.11.0 (#420)
yoshi-automation Sep 9, 2019
748a396
docs(samples): remove session option from query params (#427)
callmehiphop Sep 10, 2019
6e0734b
docs: update 'Quickstart: Agent interaction using the API' (#404)
felimartina Sep 12, 2019
28e5d9c
chore: release 0.12.0 (#431)
yoshi-automation Sep 16, 2019
422416b
chore: release 0.12.2 (#452)
release-please[bot] Oct 22, 2019
e64af5c
chore: release 0.13.0 (#454)
release-please[bot] Nov 5, 2019
35e2c3c
chore: release 0.14.0 (#459)
release-please[bot] Nov 8, 2019
9aadadc
chore: release 0.14.1 (#464)
release-please[bot] Nov 15, 2019
21f6244
fix(deps): update dependency yargs to v15 (#469)
renovate-bot Nov 18, 2019
878147b
docs: move code outside of region tags (#473)
nnegrey Nov 20, 2019
8ffb6fd
chore: update license headers
JustinBeckwith Nov 25, 2019
24273ee
chore: release 1.0.0 (#482)
release-please[bot] Dec 5, 2019
214f1e1
fix typo (#485)
sirtorry Dec 12, 2019
b70649b
refactor: use explicit mocha imports (#497)
JustinBeckwith Dec 30, 2019
5f0eeff
chore(deps): update dependency mocha to v7 (#499)
renovate-bot Jan 6, 2020
a78681c
chore: release 1.1.0
release-please[bot] Jan 6, 2020
cf05d6a
chore: release 1.1.1 (#501)
release-please[bot] Jan 9, 2020
f995374
chore: release 1.1.2 (#512)
release-please[bot] Jan 30, 2020
024dd8c
chore: release 1.2.0 (#527)
release-please[bot] Feb 7, 2020
3733761
docs: correct typo in comment (#568)
vernig Mar 24, 2020
9aeb067
docs: remove unused dialogflow code samples (#563)
Strykrol Mar 30, 2020
033d756
feat!: drop node8 support, support for async iterators (#574)
alexander-fenster Mar 31, 2020
2dfc0bc
feat!: regenerate library based on dialogflow/v2 proto changes (#569)
xiaozhenliu-gg5 Apr 6, 2020
841ddea
chore: don't enforce count (#582)
bcoe Apr 13, 2020
8da02c5
fix: bump min version of dependencies (#589)
JustinBeckwith Apr 13, 2020
8d0fd4e
chore: release 2.0.0 (#532)
release-please[bot] Apr 23, 2020
a18943a
fix(deps): update dependency uuid to v8 (#602)
renovate-bot May 1, 2020
d1dbeda
chore: split samples into individual files (#622)
munkhuushmgl Jun 10, 2020
3558f9d
chore(deps): update dependency mocha to v8 (#625)
renovate-bot Jun 11, 2020
6955122
test: added an expo back off to prevent RESOURCE_EXHAUSTED exception …
munkhuushmgl Jun 23, 2020
7587778
chore: release 3.0.0 (#631)
release-please[bot] Jul 7, 2020
d73ad2f
chore: release 3.1.0 (#637)
release-please[bot] Jul 11, 2020
79c26f6
chore: release 3.1.1 (#655)
release-please[bot] Jul 23, 2020
5ee52a6
chore: release 3.2.0 (#661)
release-please[bot] Jul 30, 2020
2e455c0
build: update config for node12 (#679)
bcoe Sep 9, 2020
23dbdcc
fix(deps): update dependency yargs to v16 (#676)
renovate-bot Sep 9, 2020
396d729
chore: release 3.3.0 (#684)
release-please[bot] Sep 17, 2020
0e1e4f0
chore: removed singleutterance flag (#739)
b-loved-dreamer Feb 5, 2021
f50fda9
chore: release 3.4.0 (#782)
release-please[bot] Mar 15, 2021
fd3b244
chore: release 3.5.0 (#794)
release-please[bot] Apr 7, 2021
0f23191
chore(nodejs): remove api-extractor dependencies (#821)
fhinkel Jun 10, 2021
49cf0cc
chore(deps): update dependency pb-util to v1 (#817)
renovate-bot Jun 14, 2021
32789fe
meta: multiple commits (#823)
bcoe Jun 15, 2021
87f0967
chore: release 4.0.0 (#805)
release-please[bot] Jun 15, 2021
88e855b
chore: release 4.1.0 (#826)
release-please[bot] Jun 15, 2021
955908c
chore: release 4.1.1 (#832)
release-please[bot] Jun 30, 2021
d0bdc51
chore: release 4.1.2 (#841)
release-please[bot] Jul 12, 2021
7e65724
chore: release 4.1.3 (#843)
release-please[bot] Jul 21, 2021
cf41d4e
chore: release 4.1.4 (#855)
release-please[bot] Aug 4, 2021
7c923f4
chore: release 4.2.0 (#858)
release-please[bot] Aug 10, 2021
da72c95
docs: add update intent code sample (#852)
galz10 Aug 16, 2021
168d263
chore: release 4.3.0 (#861)
release-please[bot] Aug 16, 2021
541d58b
chore: release 4.3.1 (#865)
release-please[bot] Aug 17, 2021
fdc7de1
docs: add set agent code sample (#866)
galz10 Sep 2, 2021
86a7ad0
docs: added region tags (#873)
galz10 Sep 15, 2021
3503080
chore: release 4.4.0 (#868)
release-please[bot] Sep 27, 2021
5f634da
docs: added webhook sample (#876)
galz10 Oct 1, 2021
cbd39d2
docs(samples): adds new list training sample (#883)
b-loved-dreamer Oct 11, 2021
a8a1ada
chore: release 4.5.0 (#881)
release-please[bot] Oct 11, 2021
cf2e5c5
samples: added comments (#889)
galz10 Oct 15, 2021
914e084
chore: release 4.6.0 (#896)
release-please[bot] Dec 13, 2021
4337581
chore(main): release 4.7.0 (#920)
release-please[bot] Mar 25, 2022
1907d9b
build!: update library to use Node 12 (#955)
sofisl May 19, 2022
3f8010d
samples: Update set-agent.js (#947)
Jun 20, 2022
0d3ae9a
chore(main): release 5.0.0 (#957)
release-please[bot] Jun 21, 2022
c667714
chore(main): release 5.1.0 (#963)
release-please[bot] Jul 5, 2022
b59a12c
chore(main): release 5.2.0 (#967)
release-please[bot] Aug 2, 2022
15442a3
chore(main): release 5.2.1 (#973)
release-please[bot] Sep 7, 2022
9a13e54
fix(deps): update dependency uuid to v9 (#977)
renovate-bot Sep 9, 2022
a9bd7e6
chore(main): release 5.3.0 (#978)
release-please[bot] Nov 11, 2022
86f0ac8
Merge remote-tracking branch 'migration/main' into nodejs-dialogflow-…
ahrarmonsur Nov 18, 2022
2973f8c
Adds workflow config for dialogflow/
ahrarmonsur Nov 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/dialogflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: dialogflow
on:
push:
branches:
- main
paths:
- 'dialogflow/**'
pull_request:
paths:
- 'dialogflow/**'
pull_request_target:
types: [labeled]
paths:
- 'dialogflow/**'
schedule:
- cron: '0 0 * * 0'
jobs:
test:
if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }}
runs-on: ubuntu-latest
timeout-minutes: 60
permissions:
contents: 'write'
pull-requests: 'write'
id-token: 'write'
steps:
- uses: actions/checkout@v3.1.0
with:
ref: ${{github.event.pull_request.head.sha}}
- uses: 'google-github-actions/auth@v1.0.0'
with:
workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider'
service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com'
create_credentials_file: 'true'
access_token_lifetime: 600s
- uses: actions/setup-node@v3.5.1
with:
node-version: 16
- run: npm install
working-directory: dialogflow
- run: npm test
working-directory: dialogflow
env:
MOCHA_REPORTER_SUITENAME: dialogflow
MOCHA_REPORTER_OUTPUT: dialogflow_sponge_log.xml
MOCHA_REPORTER: xunit
- if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }}
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.issues.removeLabel({
name: 'actions:force-run',
owner: 'GoogleCloudPlatform',
repo: 'nodejs-docs-samples',
issue_number: context.payload.pull_request.number
});
} catch (e) {
if (!e.message.includes('Label does not exist')) {
throw e;
}
}
- if: ${{ github.event_name == 'schedule'}}
run: |
curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L
chmod +x ./flakybot
./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}
1 change: 1 addition & 0 deletions .github/workflows/workflows.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"datalabeling",
"datastore/functions",
"datacatalog/quickstart",
"dialogflow",
"document-ai",
"endpoints/getting-started",
"endpoints/getting-started-grpc",
Expand Down
2 changes: 2 additions & 0 deletions dialogflow/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SampleAgent.zip
resources/pizza_order.wav
99 changes: 99 additions & 0 deletions dialogflow/create-intent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright 2020 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';

/**
* Create an intent.
* @param {string} projectId The project to be used
* @param {string} displayName Display Name
* @param {string} trainingPhrasesParts Training Phrases
* @param {string} messageTexts Message Texts
*/
function main(
projectId = 'YOUR_PROJECT_ID',
displayName = 'YOUR_INTENT_DISPLAY_NAME',
trainingPhrasesParts = [
'Hello, What is weather today?',
'How is the weather today?',
],
messageTexts = ['Rainy', 'Sunny']
) {
// [START dialogflow_create_intent]

/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = 'The Project ID to use, e.g. 'YOUR_GCP_ID';
// const displayName = 'The display name of the intent, e.g. 'MAKE_RESERVATION';
// const trainingPhrasesParts = 'Training phrases, e.g. 'How many people are staying?';
// const messageTexts = 'Message texts for the agent's response when the intent is detected, e.g. 'Your reservation has been confirmed';

// Imports the Dialogflow library
const dialogflow = require('@google-cloud/dialogflow');

// Instantiates the Intent Client
const intentsClient = new dialogflow.IntentsClient();

async function createIntent() {
// Construct request

// The path to identify the agent that owns the created intent.
const agentPath = intentsClient.projectAgentPath(projectId);

const trainingPhrases = [];

trainingPhrasesParts.forEach(trainingPhrasesPart => {
const part = {
text: trainingPhrasesPart,
};

// Here we create a new training phrase for each provided part.
const trainingPhrase = {
type: 'EXAMPLE',
parts: [part],
};

trainingPhrases.push(trainingPhrase);
});

const messageText = {
text: messageTexts,
};

const message = {
text: messageText,
};

const intent = {
displayName: displayName,
trainingPhrases: trainingPhrases,
messages: [message],
};

const createIntentRequest = {
parent: agentPath,
intent: intent,
};

// Create the intent
const [response] = await intentsClient.createIntent(createIntentRequest);
console.log(`Intent ${response.name} created`);
}

createIntent();

// [END dialogflow_create_intent]
}
main(...process.argv.slice(2));
72 changes: 72 additions & 0 deletions dialogflow/detect-intent-TTS-response.v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';
async function main(
projectId = 'YOUR_PROJECT_ID',
sessionId = 'YOUR_SESSION_ID',
query = 'YOUR_QUERY',
languageCode = 'YOUR_LANGUAGE_CODE',
outputFile = 'YOUR_OUTPUT_FILE'
) {
// [START dialogflow_detect_intent_with_texttospeech_response]
// Imports the Dialogflow client library
const dialogflow = require('@google-cloud/dialogflow').v2;

// Instantiate a DialogFlow client.
const sessionClient = new dialogflow.SessionsClient();

/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = 'ID of GCP project associated with your Dialogflow agent';
// const sessionId = `user specific ID of session, e.g. 12345`;
// const query = `phrase(s) to pass to detect, e.g. I'd like to reserve a room for six people`;
// const languageCode = 'BCP-47 language code, e.g. en-US';
// const outputFile = `path for audio output file, e.g. ./resources/myOutput.wav`;

// Define session path
const sessionPath = sessionClient.projectAgentSessionPath(
projectId,
sessionId
);
const fs = require('fs');
const util = require('util');

async function detectIntentwithTTSResponse() {
// The audio query request
const request = {
session: sessionPath,
queryInput: {
text: {
text: query,
languageCode: languageCode,
},
},
outputAudioConfig: {
audioEncoding: 'OUTPUT_AUDIO_ENCODING_LINEAR_16',
},
};
sessionClient.detectIntent(request).then(responses => {
console.log('Detected intent:');
const audioFile = responses[0].outputAudio;
util.promisify(fs.writeFile)(outputFile, audioFile, 'binary');
console.log(`Audio content written to file: ${outputFile}`);
});
}
detectIntentwithTTSResponse();
// [END dialogflow_detect_intent_with_texttospeech_response]
}

main(...process.argv.slice(2));
86 changes: 86 additions & 0 deletions dialogflow/detect-intent-sentiment.v2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

'use strict';
async function main(
projectId = 'YOUR_PROJECT_ID',
sessionId = 'YOUR_SESSION_ID',
query = 'YOUR_QUERY',
languageCode = 'YOUR_LANGUAGE_CODE'
) {
// [START dialogflow_detect_intent_with_sentiment_analysis]
// Imports the Dialogflow client library
const dialogflow = require('@google-cloud/dialogflow').v2;

// Instantiate a DialogFlow client.
const sessionClient = new dialogflow.SessionsClient();

/**
* TODO(developer): Uncomment the following lines before running the sample.
*/
// const projectId = 'ID of GCP project associated with your Dialogflow agent';
// const sessionId = `user specific ID of session, e.g. 12345`;
// const query = `phrase(s) to pass to detect, e.g. I'd like to reserve a room for six people`;
// const languageCode = 'BCP-47 language code, e.g. en-US';

// Define session path
const sessionPath = sessionClient.projectAgentSessionPath(
projectId,
sessionId
);

async function detectIntentandSentiment() {
// The text query request.
const request = {
session: sessionPath,
queryInput: {
text: {
text: query,
languageCode: languageCode,
},
},
queryParams: {
sentimentAnalysisRequestConfig: {
analyzeQueryTextSentiment: true,
},
},
};

// 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.');
}
if (result.sentimentAnalysisResult) {
console.log('Detected sentiment');
console.log(
` Score: ${result.sentimentAnalysisResult.queryTextSentiment.score}`
);
console.log(
` Magnitude: ${result.sentimentAnalysisResult.queryTextSentiment.magnitude}`
);
} else {
console.log('No sentiment Analysis Found');
}
// [END dialogflow_detect_intent_with_sentiment_analysis]
}
detectIntentandSentiment();
}
main(...process.argv.slice(2));
Loading