exec the tasks

This commit is contained in:
akirilyuk
2022-02-01 14:44:02 +01:00
parent c395109966
commit ed157c6aee

View File

@@ -256,9 +256,11 @@ class Cognigy extends Task {
const text = parseBotText(evt);
if (evt.data) this.config.update(evt.data);
if (text) {
this.logger.info({text}, "received text");
await this._enqueueTask((async() => {
await this._makeSayTask(text);
this.logger.info({text}, "received text");
const sayTask = this._makeSayTask(text).exec();
await sayTask.exec(cs, ep, this);
}).bind(this));
}
@@ -268,7 +270,8 @@ class Cognigy extends Task {
switch (evt.data.type) {
case 'hangup':
await this._enqueueTask((async() => {
await this._makeHangupTask(evt.data.reason);
const hangupTask = this._makeHangupTask(evt.data.reason);
await hangupTask.exec(cs, ep, this);
this.performAction({cognigyResult: 'hangup Succeeded'});
this.reportedFinalAction = true;
this.notifyTaskDone();
@@ -278,7 +281,8 @@ class Cognigy extends Task {
return;
case 'refer':
await this._enqueueTask(async() => {
await this._makeReferTask(evt.data.number);
const referTask = this._makeReferTask(evt.data.number);
await referTask.exect(cs, ep, this);
this.performAction({cognigyResult: 'refer succeeded'});
this.reportedFinalAction = true;
this.notifyTaskDone();