From ac8827c885d6c64b9c683b4a7f92fb4b9b8e6de7 Mon Sep 17 00:00:00 2001 From: Dave Horton Date: Tue, 31 Aug 2021 20:31:16 -0400 Subject: [PATCH] dialogflow: support for regional endpoints --- lib/tasks/dialogflow/index.js | 18 +++++++++++++++--- lib/tasks/specs.json | 4 ++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/tasks/dialogflow/index.js b/lib/tasks/dialogflow/index.js index a80ae5c8..9dd624bd 100644 --- a/lib/tasks/dialogflow/index.js +++ b/lib/tasks/dialogflow/index.js @@ -9,10 +9,22 @@ class Dialogflow extends Task { constructor(logger, opts) { super(logger, opts); this.preconditions = TaskPreconditions.Endpoint; - this.credentials = this.data.credentials; - if (this.data.environment) this.project = `${this.data.project}:${this.data.environment}`; - else this.project = this.data.project; + + /* set project id with environment and region (optionally) */ + if (this.data.environment && this.data.region) { + this.project = `${this.data.project}:${this.data.environment}:${this.data.region}`; + } + else if (this.data.environment) { + this.project = `${this.data.project}:${this.data.environment}`; + } + else if (this.data.region) { + this.project = `${this.data.project}::${this.data.region}`; + } + else { + this.project = this.data.project; + } + this.lang = this.data.lang || 'en-US'; this.welcomeEvent = this.data.welcomeEvent || ''; if (this.welcomeEvent.length && this.data.welcomeEventParams && typeof this.data.welcomeEventParams === 'object') { diff --git a/lib/tasks/specs.json b/lib/tasks/specs.json index cf2b6965..1de348fe 100644 --- a/lib/tasks/specs.json +++ b/lib/tasks/specs.json @@ -124,6 +124,10 @@ "credentials": "object|string", "project": "string", "environment": "string", + "region": { + "type": "string", + "enum": ["europe-west1", "europe-west2", "australia-southeast1", "asia-northeast1"] + }, "lang": "string", "actionHook": "object|string", "eventHook": "object|string",