This commit is contained in:
Dave Horton
2024-08-28 15:08:46 -04:00
parent f65506a905
commit fd1e1ecefc

View File

@@ -94,7 +94,7 @@ class Dialogflow extends Task {
try {
await this.init(cs, ep);
await this.startBot();
await this.startBot('default');
await this.awaitTaskDone();
} catch (err) {
this.logger.error({err}, 'Dialogflow:exec error');
@@ -166,12 +166,12 @@ class Dialogflow extends Task {
}
}
async startBot() {
async startBot(intent) {
if (this.isCX) {
await this.startBotCX();
await this.startBotCX(intent);
}
else {
await this.startBotES();
await this.startBotES(intent);
}
}
@@ -189,7 +189,7 @@ class Dialogflow extends Task {
}
}
async startBotCX() {
async startBotCX(intent) {
const baseArgs = [
this.ep.uuid,
this.region,
@@ -198,9 +198,14 @@ class Dialogflow extends Task {
this.environment,
this.lang,
];
if (intent) {
baseArgs.push(intent);
}
/*
if (Object.keys(this.queryInput).length > 0) {
baseArgs.push(`'${JSON.stringify(this.queryInput)}'`);
}
*/
this.logger.info({args: baseArgs}, 'starting dialogflow CX bot');
await this.ep.api(this.cmd, `${baseArgs.join(' ')}`);
@@ -444,8 +449,9 @@ class Dialogflow extends Task {
// if ES start a new intent (for CX we do not set single_utterance on),
// (we want to continue to listen during the audio playback)
// _unless_ we are transferring or ending the session
if (this.isES && !this.hangupAfterPlayDone) {
ep.api(this.cmd, `${ep.uuid} ${this.project} ${this.lang}`);
if (!this.hangupAfterPlayDone) {
this.startBot();
//ep.api(this.cmd, `${ep.uuid} ${this.project} ${this.lang}`);
}
this.playInProgress = true;