This commit is contained in:
Dave Horton
2024-08-20 21:22:33 -04:00
parent d6edb34f09
commit af958d0222

View File

@@ -91,7 +91,7 @@ class Dialogflow extends Task {
this.logger.info('Dialogflow:exec'); this.logger.info('Dialogflow:exec');
await this.init(cs, ep); await this.init(cs, ep);
this.logger.info('Dialogflow:exec - initialized'); this.logger.info('Dialogflow:exec - initialized');
await this.startBot(); await this.startBot(ep);
this.logger.info('Dialogflow:exec - started bot'); this.logger.info('Dialogflow:exec - started bot');
await this.awaitTaskDone(); await this.awaitTaskDone();
this.logger.info('Dialogflow:exec - done'); this.logger.info('Dialogflow:exec - done');
@@ -165,28 +165,28 @@ class Dialogflow extends Task {
} }
} }
async startBot() { async startBot(ep) {
const fn = this.isCX ? this.startBotCX : this.startBotES; const fn = this.isCX ? this.startBotCX : this.startBotES;
await fn(); await fn(ep);
} }
async startBotES() { async startBotES(ep) {
this.logger.info('starting dialogflow ES bot'); this.logger.info('starting dialogflow ES bot');
const baseArgs = `${this.ep.uuid} ${this.project} ${this.lang} ${this.welcomeEvent}`; const baseArgs = `${ep.uuid} ${this.project} ${this.lang} ${this.welcomeEvent}`;
if (this.welcomeEventParams) { if (this.welcomeEventParams) {
await this.ep.api(this.cmd, `${baseArgs} '${JSON.stringify(this.welcomeEventParams)}'`); await ep.api(this.cmd, `${baseArgs} '${JSON.stringify(this.welcomeEventParams)}'`);
} }
else if (this.welcomeEvent.length) { else if (this.welcomeEvent.length) {
await this.ep.api(this.cmd, baseArgs); await ep.api(this.cmd, baseArgs);
} }
else { else {
await this.ep.api(this.cmd, `${this.ep.uuid} ${this.project} ${this.lang}`); await ep.api(this.cmd, `${this.ep.uuid} ${this.project} ${this.lang}`);
} }
} }
async startBotCX() { async startBotCX(ep) {
const baseArgs = [ const baseArgs = [
this.ep.uuid, ep.uuid,
this.region, this.region,
this.project, this.project,
this.agent, this.agent,
@@ -198,7 +198,7 @@ class Dialogflow extends Task {
} }
this.logger.info({args: baseArgs}, 'starting dialogflow CX bot'); this.logger.info({args: baseArgs}, 'starting dialogflow CX bot');
await this.ep.api(this.cmd, `${baseArgs.join(' ')}`); await ep.api(this.cmd, `${baseArgs.join(' ')}`);
} }
/** /**