From 2781d1c8c1d54f16f375e7e0a19da4b823d98e73 Mon Sep 17 00:00:00 2001 From: aribray <45905583+aribray@users.noreply.github.com> Date: Wed, 27 Apr 2022 12:27:13 -0700 Subject: [PATCH 01/11] add webhook-configure-session-parameter-enable-agent-response sample and test Change-Id: Ia8593160ed33060eb497a15723b21c1221ce55c9 --- ...n-parameters-enable-agent-response-test.js | 90 +++++++++++++++++++ ...ession-parameters-enable-agent-response.js | 67 ++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 samples/test/webhook-configure-session-parameters-enable-agent-response-test.js create mode 100644 samples/webhook-configure-session-parameters-enable-agent-response.js diff --git a/samples/test/webhook-configure-session-parameters-enable-agent-response-test.js b/samples/test/webhook-configure-session-parameters-enable-agent-response-test.js new file mode 100644 index 00000000..de672f84 --- /dev/null +++ b/samples/test/webhook-configure-session-parameters-enable-agent-response-test.js @@ -0,0 +1,90 @@ +// Copyright 2022 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 +// +// https://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'; + +// Copyright 2021 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'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); +const webhook = require('../webhook-configure-session-parameters-enable-agent-response'); +const number = 100; + +describe('enable agent response', () => { + it('should test webhook increases value of session parameter', async () => { + const request = { + body: { + fulfillmentInfo: { + tag: 'increase number', + }, + sessionInfo: { + parameters: { + number: number, + }, + }, + }, + }; + const temp = JSON.stringify(request); + let response = ''; + + const res = { + send: function (s) { + response = JSON.stringify(s); + }, + }; + + webhook.enableAgentResponse(JSON.parse(temp), res); + assert.include(response, 'increased value'); + }); + + it('should test webhook decreases value of session parameter', async () => { + const request = { + body: { + fulfillmentInfo: { + tag: 'decrease number', + }, + sessionInfo: { + parameters: { + number: number, + }, + }, + }, + }; + const temp = JSON.stringify(request); + let response = ''; + + const res = { + send: function (s) { + response = JSON.stringify(s); + }, + }; + + webhook.enableAgentResponse(JSON.parse(temp), res); + assert.include(response, 'decreased value'); + }); +}); diff --git a/samples/webhook-configure-session-parameters-enable-agent-response.js b/samples/webhook-configure-session-parameters-enable-agent-response.js new file mode 100644 index 00000000..f80a102b --- /dev/null +++ b/samples/webhook-configure-session-parameters-enable-agent-response.js @@ -0,0 +1,67 @@ +// Copyright 2022 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 +// +// https://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. + +/** + * Configures a webhook to enable an agent response. + */ + +// [START dialogflow_cx_v3beta1_webhook_configure_session_parameters_enable_agent_response] + +// TODO (developer): change entry point to enableAgentResponse in Cloud Function + +exports.enableAgentResponse = (request, response) => { + const tag = request.body.fulfillmentInfo.tag; + // The value of the parameter used to enable agent response + let sessionParameter = request.body.sessionInfo.parameters.number; + let text = ''; + + if (tag === 'increase number') { + sessionParameter = sessionParameter += 100; + text = `The new increased value of the number parameter is ${sessionParameter}`; + } else if (tag === 'decrease number') { + sessionParameter -= 50; + text = `The new decreased value of the number parameter is ${sessionParameter}`; + } + + const jsonResponse = { + fulfillment_response: { + messages: [ + { + text: { + //fulfillment text response to be sent to the agent + text: [text], + }, + }, + ], + }, + // Webhook returns configured session parameter value + session_info: { + parameters: { + number: sessionParameter, + }, + }, + }; + + console.log( + 'Configured Parameter: ', + jsonResponse.session_info.parameters.number + ); + // Response message returned by the agent + console.log( + 'AGENT RESPONSE: ', + jsonResponse.fulfillment_response.messages[0].text.text + ); + response.send(jsonResponse); +}; +// [END dialogflow_cx_v3beta1_webhook_configure_session_parameters_enable_agent_response] From df98147b0e13ae247a257bec0a7d7c333f655f90 Mon Sep 17 00:00:00 2001 From: aribray <45905583+aribray@users.noreply.github.com> Date: Wed, 27 Apr 2022 13:21:50 -0700 Subject: [PATCH 02/11] add webhook-configure-session-parameter-trigger-transition sample and test Change-Id: I118abb59182879b6969018da97d04eea0b8daeb0 --- ...sion-parameters-trigger-transition-test.js | 60 +++++++++++++++++++ ...e-session-parameters-trigger-transition.js | 53 ++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 samples/test/webhook-configure-session-parameters-trigger-transition-test.js create mode 100644 samples/webhook-configure-session-parameters-trigger-transition.js diff --git a/samples/test/webhook-configure-session-parameters-trigger-transition-test.js b/samples/test/webhook-configure-session-parameters-trigger-transition-test.js new file mode 100644 index 00000000..d71f756c --- /dev/null +++ b/samples/test/webhook-configure-session-parameters-trigger-transition-test.js @@ -0,0 +1,60 @@ +// Copyright 2022 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 +// +// https://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'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); +const uuid = require('uuid'); +const webhook = require('../webhook-configure-session-parameters-trigger-transition.js'); + +// variables to construct path to target page +const location = 'global'; +const projectId = process.env.GCLOUD_PROJECT; +const flowId = '00000000-0000-0000-0000-000000000000'; +const pageId = `temp_page_${uuid.v4()}`; +const agentId = '4e2cb784-012c-48b2-9d8c-a877d3be3437'; +const targetPage = `projects/${projectId}/locations/${location}/agents/${agentId}/flows/${flowId}/pages/${pageId}`; + +const number = 100; + +const request = { + body: { + targetPage: targetPage, + fulfillmentInfo: { + tag: 'configure-session-parameter-trigger-transition', + }, + sessionInfo: { + parameters: { + number: number, + }, + }, + }, +}; + +describe('trigger transition', () => { + it('should test that webhook response contains target page', async () => { + const temp = JSON.stringify(request); + let response = ''; + + const res = { + send: function (s) { + response = JSON.stringify(s); + }, + }; + + webhook.triggerTransition(JSON.parse(temp), res); + assert.include(response, pageId); + }); +}); diff --git a/samples/webhook-configure-session-parameters-trigger-transition.js b/samples/webhook-configure-session-parameters-trigger-transition.js new file mode 100644 index 00000000..ee57a676 --- /dev/null +++ b/samples/webhook-configure-session-parameters-trigger-transition.js @@ -0,0 +1,53 @@ +// Copyright 2022 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 +// +// https://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. + +/** + * Configures a webhook to trigger a page transition. This is a simple example. + */ + +// [START dialogflow_cx_v3beta1_webhook_configure_session_parameters_trigger_transition] + +// TODO (developer): change entry point to triggerTransition in Cloud Function + +exports.triggerTransition = (request, response) => { + // The target page to transition to. + const targetPage = request.body.targetPage; // Must be format projects//locations//agents//flows//pages/ + // The value of the parameter used to trigger transition + let sessionParameter = request.body.sessionInfo.parameters.number; + + sessionParameter = sessionParameter *= 50; + const text = `We multiplied your input - the value is now ${sessionParameter}. Let's go the the next page.`; + const jsonResponse = { + target_page: targetPage, + fulfillment_response: { + messages: [ + { + text: { + //fulfillment text response to be sent to the agent + text: [text], + }, + }, + ], + }, + // Sets new value of the session parameter + session_info: { + parameters: { + number: sessionParameter, + }, + }, + }; + + response.send(jsonResponse); +}; +// [END dialogflow_cx_v3beta1_webhook_configure_session_parameters_trigger_transition] From e8114208c2189388df40ec74bb2379d0c578885d Mon Sep 17 00:00:00 2001 From: aribray <45905583+aribray@users.noreply.github.com> Date: Fri, 29 Apr 2022 09:54:16 -0700 Subject: [PATCH 03/11] add webhook-configure-optional-or-required-form-parameters sample and test Change-Id: I7cbfeb11cece7ccf873dbc7a6dd7cff9ae264ffe --- ...tional-or-required-form-parameters-test.js | 90 +++++++++++++++++++ ...re-optional-or-required-form-parameters.js | 71 +++++++++++++++ 2 files changed, 161 insertions(+) create mode 100644 samples/test/webhook-configure-optional-or-required-form-parameters-test.js create mode 100644 samples/webhook-configure-optional-or-required-form-parameters.js diff --git a/samples/test/webhook-configure-optional-or-required-form-parameters-test.js b/samples/test/webhook-configure-optional-or-required-form-parameters-test.js new file mode 100644 index 00000000..df986ee7 --- /dev/null +++ b/samples/test/webhook-configure-optional-or-required-form-parameters-test.js @@ -0,0 +1,90 @@ +// Copyright 2022 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 +// +// https://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'; + +// Copyright 2021 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'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); +const webhook = require('../webhook-configure-optional-or-required-form-parameters'); +const number = 100; + +describe('configure optional or required form parameter', () => { + it('should test that webhook sets parameter as required', async () => { + const request = { + body: { + fulfillmentInfo: { + tag: 'required', + }, + sessionInfo: { + parameters: { + number: number, + }, + }, + }, + }; + const temp = JSON.stringify(request); + let response = ''; + + const res = { + send: function (s) { + response = JSON.stringify(s); + }, + }; + + webhook.configureOptionalFormParam(JSON.parse(temp), res); + assert.include(response, 'This parameter is required.'); + }); + + it('should test that webhook sets parameter as optional', async () => { + const request = { + body: { + fulfillmentInfo: { + tag: 'optional', + }, + sessionInfo: { + parameters: { + number: number, + }, + }, + }, + }; + const temp = JSON.stringify(request); + let response = ''; + + const res = { + send: function (s) { + response = JSON.stringify(s); + }, + }; + + webhook.configureOptionalFormParam(JSON.parse(temp), res); + assert.include(response, 'This parameter is optional.'); + }); +}); diff --git a/samples/webhook-configure-optional-or-required-form-parameters.js b/samples/webhook-configure-optional-or-required-form-parameters.js new file mode 100644 index 00000000..6cbcb8a8 --- /dev/null +++ b/samples/webhook-configure-optional-or-required-form-parameters.js @@ -0,0 +1,71 @@ +// Copyright 2022 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 +// +// https://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. + +/** + * Configures a webhook to configure new session parameters + */ + +// [START dialogflow_cx_v3beta1_webhook_configure_optional_or_required_form_params] + +// TODO (developer): change entry point to configureOptionalFormParam in Cloud Function + +exports.configureOptionalFormParam = (request, response) => { + const tag = request.body.fulfillmentInfo.tag; + // The value of the parameter used to enable agent response + const formParameter = request.body.sessionInfo.parameters.number; + let isRequired; + let text = ''; + + if (tag === 'optional') { + isRequired = false; + text = 'This parameter is optional.'; + } else { + isRequired = true; + text = 'This parameter is required.'; + } + + const jsonResponse = { + fulfillment_response: { + messages: [ + { + text: { + //fulfillment text response to be sent to the agent + text: [text], + }, + }, + ], + }, + pageInfo: { + formInfo: { + parameterInfo: [ + { + displayName: formParameter, + // if required: false, the agent will not reprompt for this parameter, even if the state is 'INVALID' + required: isRequired, + state: 'VALID', + }, + ], + }, + }, + // Set session parameter to null if you want to reprompt the user to enter a required parameter + sessionInfo: { + parameterInfo: { + formParameter: formParameter, + }, + }, + }; + + response.send(jsonResponse); +}; +// [END dialogflow_cx_v3beta1_webhook_configure_optional_or_required_form_params] From 1bbca09741930188dd2d6362ee80072c978cac98 Mon Sep 17 00:00:00 2001 From: aribray <45905583+aribray@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:01:54 -0700 Subject: [PATCH 04/11] add configure-session-parameters sample and test Change-Id: Ib9f1a110473751508b50259c4696593580c64a91 --- ...bhook-configure-session-parameters-test.js | 79 +++++++++++++++++++ .../webhook-configure-session-parameters.js | 54 +++++++++++++ 2 files changed, 133 insertions(+) create mode 100644 samples/test/webhook-configure-session-parameters-test.js create mode 100644 samples/webhook-configure-session-parameters.js diff --git a/samples/test/webhook-configure-session-parameters-test.js b/samples/test/webhook-configure-session-parameters-test.js new file mode 100644 index 00000000..705c6449 --- /dev/null +++ b/samples/test/webhook-configure-session-parameters-test.js @@ -0,0 +1,79 @@ +// Copyright 2022 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 +// +// https://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'; + +// Copyright 2021 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'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); +const webhook = require('../webhook-configure-session-parameters'); + +describe('configure session parameters', () => { + it('should test that webhook adds new session parameter', async () => { + const request = { + body: { + fulfillmentInfo: { + tag: 'month', + }, + }, + }; + const temp = JSON.stringify(request); + let response = ''; + + const res = { + send: function (s) { + response = JSON.stringify(s); + }, + }; + + webhook.configureSessionParams(JSON.parse(temp), res); + assert.include(response, 'January'); + }); + + it('should test that webhook configures session parameter', async () => { + const request = { + body: { + fulfillmentInfo: { + tag: 'year', + }, + }, + }; + const temp = JSON.stringify(request); + let response = ''; + + const res = { + send: function (s) { + response = JSON.stringify(s); + }, + }; + + webhook.configureSessionParams(JSON.parse(temp), res); + assert.include(response, '1999'); + }); +}); diff --git a/samples/webhook-configure-session-parameters.js b/samples/webhook-configure-session-parameters.js new file mode 100644 index 00000000..e3f567ae --- /dev/null +++ b/samples/webhook-configure-session-parameters.js @@ -0,0 +1,54 @@ +// Copyright 2022 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 +// +// https://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. + +/** + * Configures a webhook to configure new session parameters + */ + +// [START dialogflow_cx_v3beta1_webhook_configure_session_parameters] + +// TODO (developer): change entry point to configureSessionParams in Cloud Function + +exports.configureSessionParams = (request, response) => { + const tag = request.body.fulfillmentInfo.tag; + let newSessionParameter; + const text = `${newSessionParameter}. I'm a session parameter configured by the webhook. The webhook's tag is ${tag}.`; + + if (tag === 'month') { + newSessionParameter = 'January'; + } else if (tag === 'year') { + newSessionParameter = '1999'; + } + + const jsonResponse = { + fulfillment_response: { + messages: [ + { + text: { + //fulfillment text response to be sent to the agent + text: [text], + }, + }, + ], + }, + sessionInfo: { + parameters: { + newSessionParameter: newSessionParameter, + }, + }, + }; + + response.send(jsonResponse); +}; +// [END dialogflow_cx_v3beta1_webhook_configure_session_parameters] From d347760555973ac5ec69a5afdfd8c100ee539789 Mon Sep 17 00:00:00 2001 From: aribray <45905583+aribray@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:04:29 -0700 Subject: [PATCH 05/11] fix form parameter path Change-Id: I6411000a7d0240d7552d725c2fd1049be781a9ab --- .../webhook-configure-optional-or-required-form-parameters.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/webhook-configure-optional-or-required-form-parameters.js b/samples/webhook-configure-optional-or-required-form-parameters.js index 6cbcb8a8..c8fd2996 100644 --- a/samples/webhook-configure-optional-or-required-form-parameters.js +++ b/samples/webhook-configure-optional-or-required-form-parameters.js @@ -23,7 +23,7 @@ exports.configureOptionalFormParam = (request, response) => { const tag = request.body.fulfillmentInfo.tag; // The value of the parameter used to enable agent response - const formParameter = request.body.sessionInfo.parameters.number; + const formParameter = request.body.pageInfo.formInfo.parameterInfo[0].number; let isRequired; let text = ''; From 8274de77152035429e90d92f4f94f8379d8f87f2 Mon Sep 17 00:00:00 2001 From: aribray <45905583+aribray@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:20:33 -0700 Subject: [PATCH 06/11] add webhook-validate-form-parameter sample and test Change-Id: I82097be3fc3f91651c88b99c7431ebb602c42c66 --- .../webhook-validate-form-parameter-test.js | 102 ++++++++++++++++++ samples/webhook-validate-form-parameter.js | 71 ++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 samples/test/webhook-validate-form-parameter-test.js create mode 100644 samples/webhook-validate-form-parameter.js diff --git a/samples/test/webhook-validate-form-parameter-test.js b/samples/test/webhook-validate-form-parameter-test.js new file mode 100644 index 00000000..63c916c8 --- /dev/null +++ b/samples/test/webhook-validate-form-parameter-test.js @@ -0,0 +1,102 @@ +// Copyright 2022 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 +// +// https://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'; + +// Copyright 2021 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'; + +const {assert} = require('chai'); +const {describe, it} = require('mocha'); +const webhook = require('../webhook-validate-form-parameter'); + +describe('configure session parameters', () => { + it('should test that webhook validates form parameter', async () => { + const number = 4; + const request = { + body: { + fulfillmentInfo: { + tag: 'valid-parameter', + }, + pageInfo: { + formInfo: { + parameterInfo: [ + { + displayName: 'number', + value: number, + }, + ], + }, + }, + }, + }; + const temp = JSON.stringify(request); + let response = ''; + + const res = { + send: function (s) { + response = JSON.stringify(s); + }, + }; + + webhook.validateParameter(JSON.parse(temp), res); + assert.include(response, 'VALID'); + }); + + it('should test that webhook invalidates form parameter', async () => { + const number = 150; + const request = { + body: { + fulfillmentInfo: { + tag: 'invalid-parameter', + }, + pageInfo: { + formInfo: { + parameterInfo: [ + { + displayName: 'number', + required: true, + value: number, + }, + ], + }, + }, + }, + }; + const temp = JSON.stringify(request); + let response = ''; + + const res = { + send: function (s) { + response = JSON.stringify(s); + }, + }; + + webhook.validateParameter(JSON.parse(temp), res); + assert.include(response, 'INVALID'); + }); +}); diff --git a/samples/webhook-validate-form-parameter.js b/samples/webhook-validate-form-parameter.js new file mode 100644 index 00000000..ab7e5e0e --- /dev/null +++ b/samples/webhook-validate-form-parameter.js @@ -0,0 +1,71 @@ +// Copyright 2022 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 +// +// https://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. + +/** + * Uses a webhook to validate or invalidate form parameters. + */ + +// [START dialogflow_v3beta1_webhook_validate_form_parameter] + +// TODO (developer): change entry point to validateParameter in Cloud Function + +exports.validateParameter = (request, response) => { + // The value of the parameter to validate + let paramToValidate = request.body.pageInfo.formInfo.parameterInfo[0].value; + let text = ''; + let paramState; + + // Webhook will validate or invalidate parameter based on conditions configured by the user + if (paramToValidate > 15) { + text = 'That is too many! Please pick another number.'; + paramState = 'INVALID'; + paramToValidate = null; + } else { + text = 'That is a number I can work with!'; + paramState = 'VALID'; + } + + const jsonResponse = { + fulfillment_response: { + messages: [ + { + text: { + //fulfillment text response to be sent to the agent + text: [text], + }, + }, + ], + }, + page_info: { + form_info: { + parameter_info: [ + { + displayName: 'paramToValidate', + required: true, + state: paramState, + }, + ], + }, + }, + sessionInfo: { + parameters: { + // Set session parameter to null if your agent needs to reprompt the user + paramToValidate: paramToValidate, + }, + }, + }; + + response.send(jsonResponse); +}; +// [END dialogflow_v3beta1_webhook_validate_form_parameter] From 3b76bb722ada777c1a119eea9863058c17eef652 Mon Sep 17 00:00:00 2001 From: aribray <45905583+aribray@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:29:52 -0700 Subject: [PATCH 07/11] add cx to region tag Change-Id: I6640604512c27a341ab8e26238bf8c3fbd1e77ef --- samples/webhook-validate-form-parameter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/webhook-validate-form-parameter.js b/samples/webhook-validate-form-parameter.js index ab7e5e0e..2f2598dc 100644 --- a/samples/webhook-validate-form-parameter.js +++ b/samples/webhook-validate-form-parameter.js @@ -16,7 +16,7 @@ * Uses a webhook to validate or invalidate form parameters. */ -// [START dialogflow_v3beta1_webhook_validate_form_parameter] +// [START dialogflow_cx_v3beta1_webhook_validate_form_parameter] // TODO (developer): change entry point to validateParameter in Cloud Function @@ -68,4 +68,4 @@ exports.validateParameter = (request, response) => { response.send(jsonResponse); }; -// [END dialogflow_v3beta1_webhook_validate_form_parameter] +// [END dialogflow_cx_v3beta1_webhook_validate_form_parameter] From bd52044c23549df198cd54110f36e4649b89929c Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 29 Apr 2022 17:30:57 +0000 Subject: [PATCH 08/11] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 5 +++ samples/README.md | 90 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/README.md b/README.md index a4ec0239..18e23c72 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,11 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-dialogflow- | Long-running-operation | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/long-running-operation.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/long-running-operation.js,samples/README.md) | | Quickstart | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | | Update-intent | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/update-intent.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/update-intent.js,samples/README.md) | +| Webhook-configure-optional-or-required-form-parameters | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-optional-or-required-form-parameters.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-optional-or-required-form-parameters.js,samples/README.md) | +| Webhook-configure-session-parameters-enable-agent-response | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters-enable-agent-response.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters-enable-agent-response.js,samples/README.md) | +| Webhook-configure-session-parameters-trigger-transition | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters-trigger-transition.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters-trigger-transition.js,samples/README.md) | +| Webhook-configure-session-parameters | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters.js,samples/README.md) | +| Webhook-validate-form-parameter | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-validate-form-parameter.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-validate-form-parameter.js,samples/README.md) | | Webhooks | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhooks.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhooks.js,samples/README.md) | diff --git a/samples/README.md b/samples/README.md index 902ca808..61638c58 100644 --- a/samples/README.md +++ b/samples/README.md @@ -25,6 +25,11 @@ * [Long-running-operation](#long-running-operation) * [Quickstart](#quickstart) * [Update-intent](#update-intent) + * [Webhook-configure-optional-or-required-form-parameters](#webhook-configure-optional-or-required-form-parameters) + * [Webhook-configure-session-parameters-enable-agent-response](#webhook-configure-session-parameters-enable-agent-response) + * [Webhook-configure-session-parameters-trigger-transition](#webhook-configure-session-parameters-trigger-transition) + * [Webhook-configure-session-parameters](#webhook-configure-session-parameters) + * [Webhook-validate-form-parameter](#webhook-validate-form-parameter) * [Webhooks](#webhooks) ## Before you begin @@ -263,6 +268,91 @@ __Usage:__ +### Webhook-configure-optional-or-required-form-parameters + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-optional-or-required-form-parameters.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-optional-or-required-form-parameters.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-configure-optional-or-required-form-parameters.js` + + +----- + + + + +### Webhook-configure-session-parameters-enable-agent-response + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters-enable-agent-response.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters-enable-agent-response.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-configure-session-parameters-enable-agent-response.js` + + +----- + + + + +### Webhook-configure-session-parameters-trigger-transition + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters-trigger-transition.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters-trigger-transition.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-configure-session-parameters-trigger-transition.js` + + +----- + + + + +### Webhook-configure-session-parameters + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-configure-session-parameters.js` + + +----- + + + + +### Webhook-validate-form-parameter + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-validate-form-parameter.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-validate-form-parameter.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-validate-form-parameter.js` + + +----- + + + + ### Webhooks View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhooks.js). From c32ae794e9b7758c8625ed888a9cb1479404cb0d Mon Sep 17 00:00:00 2001 From: Owl Bot Date: Fri, 29 Apr 2022 17:32:36 +0000 Subject: [PATCH 09/11] =?UTF-8?q?=F0=9F=A6=89=20Updates=20from=20OwlBot=20?= =?UTF-8?q?post-processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --- README.md | 5 +++ samples/README.md | 90 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/README.md b/README.md index a4ec0239..18e23c72 100644 --- a/README.md +++ b/README.md @@ -151,6 +151,11 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-dialogflow- | Long-running-operation | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/long-running-operation.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/long-running-operation.js,samples/README.md) | | Quickstart | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) | | Update-intent | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/update-intent.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/update-intent.js,samples/README.md) | +| Webhook-configure-optional-or-required-form-parameters | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-optional-or-required-form-parameters.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-optional-or-required-form-parameters.js,samples/README.md) | +| Webhook-configure-session-parameters-enable-agent-response | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters-enable-agent-response.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters-enable-agent-response.js,samples/README.md) | +| Webhook-configure-session-parameters-trigger-transition | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters-trigger-transition.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters-trigger-transition.js,samples/README.md) | +| Webhook-configure-session-parameters | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters.js,samples/README.md) | +| Webhook-validate-form-parameter | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-validate-form-parameter.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-validate-form-parameter.js,samples/README.md) | | Webhooks | [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhooks.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhooks.js,samples/README.md) | diff --git a/samples/README.md b/samples/README.md index 902ca808..61638c58 100644 --- a/samples/README.md +++ b/samples/README.md @@ -25,6 +25,11 @@ * [Long-running-operation](#long-running-operation) * [Quickstart](#quickstart) * [Update-intent](#update-intent) + * [Webhook-configure-optional-or-required-form-parameters](#webhook-configure-optional-or-required-form-parameters) + * [Webhook-configure-session-parameters-enable-agent-response](#webhook-configure-session-parameters-enable-agent-response) + * [Webhook-configure-session-parameters-trigger-transition](#webhook-configure-session-parameters-trigger-transition) + * [Webhook-configure-session-parameters](#webhook-configure-session-parameters) + * [Webhook-validate-form-parameter](#webhook-validate-form-parameter) * [Webhooks](#webhooks) ## Before you begin @@ -263,6 +268,91 @@ __Usage:__ +### Webhook-configure-optional-or-required-form-parameters + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-optional-or-required-form-parameters.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-optional-or-required-form-parameters.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-configure-optional-or-required-form-parameters.js` + + +----- + + + + +### Webhook-configure-session-parameters-enable-agent-response + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters-enable-agent-response.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters-enable-agent-response.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-configure-session-parameters-enable-agent-response.js` + + +----- + + + + +### Webhook-configure-session-parameters-trigger-transition + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters-trigger-transition.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters-trigger-transition.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-configure-session-parameters-trigger-transition.js` + + +----- + + + + +### Webhook-configure-session-parameters + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-configure-session-parameters.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-configure-session-parameters.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-configure-session-parameters.js` + + +----- + + + + +### Webhook-validate-form-parameter + +View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhook-validate-form-parameter.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-dialogflow-cx&page=editor&open_in_editor=samples/webhook-validate-form-parameter.js,samples/README.md) + +__Usage:__ + + +`node samples/webhook-validate-form-parameter.js` + + +----- + + + + ### Webhooks View the [source code](https://github.com/googleapis/nodejs-dialogflow-cx/blob/main/samples/webhooks.js). From 8ef7b409f7aa64021550712bd11df236628f45df Mon Sep 17 00:00:00 2001 From: aribray <45905583+aribray@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:49:40 -0700 Subject: [PATCH 10/11] fix test Change-Id: Icc70e18b40d8684c7909e8383b4c226fa94a162b --- ...tional-or-required-form-parameters-test.js | 22 ++++++++++++++----- ...re-optional-or-required-form-parameters.js | 2 +- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/samples/test/webhook-configure-optional-or-required-form-parameters-test.js b/samples/test/webhook-configure-optional-or-required-form-parameters-test.js index df986ee7..90b9db0d 100644 --- a/samples/test/webhook-configure-optional-or-required-form-parameters-test.js +++ b/samples/test/webhook-configure-optional-or-required-form-parameters-test.js @@ -42,9 +42,14 @@ describe('configure optional or required form parameter', () => { fulfillmentInfo: { tag: 'required', }, - sessionInfo: { - parameters: { - number: number, + pageInfo: { + formInfo: { + parameterInfo: [ + { + displayName: 'number', + value: number, + }, + ], }, }, }, @@ -68,9 +73,14 @@ describe('configure optional or required form parameter', () => { fulfillmentInfo: { tag: 'optional', }, - sessionInfo: { - parameters: { - number: number, + pageInfo: { + formInfo: { + parameterInfo: [ + { + displayName: 'number', + value: number, + }, + ], }, }, }, diff --git a/samples/webhook-configure-optional-or-required-form-parameters.js b/samples/webhook-configure-optional-or-required-form-parameters.js index c8fd2996..bd5ba7f2 100644 --- a/samples/webhook-configure-optional-or-required-form-parameters.js +++ b/samples/webhook-configure-optional-or-required-form-parameters.js @@ -23,7 +23,7 @@ exports.configureOptionalFormParam = (request, response) => { const tag = request.body.fulfillmentInfo.tag; // The value of the parameter used to enable agent response - const formParameter = request.body.pageInfo.formInfo.parameterInfo[0].number; + const formParameter = request.body.pageInfo.formInfo.parameterInfo[0].value; let isRequired; let text = ''; From 3efec6ce0146470db42df3d0aa8207595525a8f8 Mon Sep 17 00:00:00 2001 From: aribray <45905583+aribray@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:54:36 -0700 Subject: [PATCH 11/11] fix region tag Change-Id: I0fe3849c0eaf12eaf247088993898cbb47dace44 --- .../webhook-configure-optional-or-required-form-parameters.js | 4 ++-- ...hook-configure-session-parameters-enable-agent-response.js | 4 ++-- ...webhook-configure-session-parameters-trigger-transition.js | 4 ++-- samples/webhook-configure-session-parameters.js | 4 ++-- samples/webhook-validate-form-parameter.js | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/samples/webhook-configure-optional-or-required-form-parameters.js b/samples/webhook-configure-optional-or-required-form-parameters.js index bd5ba7f2..37a7b148 100644 --- a/samples/webhook-configure-optional-or-required-form-parameters.js +++ b/samples/webhook-configure-optional-or-required-form-parameters.js @@ -16,7 +16,7 @@ * Configures a webhook to configure new session parameters */ -// [START dialogflow_cx_v3beta1_webhook_configure_optional_or_required_form_params] +// [START dialogflow_cx_v3_webhook_configure_optional_or_required_form_params] // TODO (developer): change entry point to configureOptionalFormParam in Cloud Function @@ -68,4 +68,4 @@ exports.configureOptionalFormParam = (request, response) => { response.send(jsonResponse); }; -// [END dialogflow_cx_v3beta1_webhook_configure_optional_or_required_form_params] +// [END dialogflow_cx_v3_webhook_configure_optional_or_required_form_params] diff --git a/samples/webhook-configure-session-parameters-enable-agent-response.js b/samples/webhook-configure-session-parameters-enable-agent-response.js index f80a102b..7c361ee4 100644 --- a/samples/webhook-configure-session-parameters-enable-agent-response.js +++ b/samples/webhook-configure-session-parameters-enable-agent-response.js @@ -16,7 +16,7 @@ * Configures a webhook to enable an agent response. */ -// [START dialogflow_cx_v3beta1_webhook_configure_session_parameters_enable_agent_response] +// [START dialogflow_cx_v3_webhook_configure_session_parameters_enable_agent_response] // TODO (developer): change entry point to enableAgentResponse in Cloud Function @@ -64,4 +64,4 @@ exports.enableAgentResponse = (request, response) => { ); response.send(jsonResponse); }; -// [END dialogflow_cx_v3beta1_webhook_configure_session_parameters_enable_agent_response] +// [END dialogflow_cx_v3_webhook_configure_session_parameters_enable_agent_response] diff --git a/samples/webhook-configure-session-parameters-trigger-transition.js b/samples/webhook-configure-session-parameters-trigger-transition.js index ee57a676..e7a60166 100644 --- a/samples/webhook-configure-session-parameters-trigger-transition.js +++ b/samples/webhook-configure-session-parameters-trigger-transition.js @@ -16,7 +16,7 @@ * Configures a webhook to trigger a page transition. This is a simple example. */ -// [START dialogflow_cx_v3beta1_webhook_configure_session_parameters_trigger_transition] +// [START dialogflow_cx_v3_webhook_configure_session_parameters_trigger_transition] // TODO (developer): change entry point to triggerTransition in Cloud Function @@ -50,4 +50,4 @@ exports.triggerTransition = (request, response) => { response.send(jsonResponse); }; -// [END dialogflow_cx_v3beta1_webhook_configure_session_parameters_trigger_transition] +// [END dialogflow_cx_v3_webhook_configure_session_parameters_trigger_transition] diff --git a/samples/webhook-configure-session-parameters.js b/samples/webhook-configure-session-parameters.js index e3f567ae..9c9b704e 100644 --- a/samples/webhook-configure-session-parameters.js +++ b/samples/webhook-configure-session-parameters.js @@ -16,7 +16,7 @@ * Configures a webhook to configure new session parameters */ -// [START dialogflow_cx_v3beta1_webhook_configure_session_parameters] +// [START dialogflow_cx_v3_webhook_configure_session_parameters] // TODO (developer): change entry point to configureSessionParams in Cloud Function @@ -51,4 +51,4 @@ exports.configureSessionParams = (request, response) => { response.send(jsonResponse); }; -// [END dialogflow_cx_v3beta1_webhook_configure_session_parameters] +// [END dialogflow_cx_v3_webhook_configure_session_parameters] diff --git a/samples/webhook-validate-form-parameter.js b/samples/webhook-validate-form-parameter.js index 2f2598dc..517606dc 100644 --- a/samples/webhook-validate-form-parameter.js +++ b/samples/webhook-validate-form-parameter.js @@ -16,7 +16,7 @@ * Uses a webhook to validate or invalidate form parameters. */ -// [START dialogflow_cx_v3beta1_webhook_validate_form_parameter] +// [START dialogflow_cx_v3_webhook_validate_form_parameter] // TODO (developer): change entry point to validateParameter in Cloud Function @@ -68,4 +68,4 @@ exports.validateParameter = (request, response) => { response.send(jsonResponse); }; -// [END dialogflow_cx_v3beta1_webhook_validate_form_parameter] +// [END dialogflow_cx_v3_webhook_validate_form_parameter]