@onereach/step-voice
Version:
Onereach.ai Voice Steps
36 lines (35 loc) • 1.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const voice_1 = tslib_1.__importDefault(require("./voice"));
class VoiceCancel extends voice_1.default {
async runStep() {
// const conv = await this.getConversation()
// if (conv.lcl.length <= 1) {
// this.log.debug('nothing to cancel')
// this.exitStep('next')
// return
// }
const call = await this.fetchData();
this.triggers.local(`in/voice/${call.id}`, async (event) => {
switch (event.params.type) {
case 'hangup':
await this.handleHangup(call);
return await this.waitConvEnd();
case 'error':
return this.throwError(event.params.error);
case 'cancel': {
// await this.popConvStep() // pop current command (cancel)
await this.cancel(); // cancel previous command
return this.exitStep('next');
}
default:
return this.exitFlow();
}
});
this.triggers.otherwise(async () => {
await this.sendCommands(call, [{ name: 'cancel' }]);
});
}
}
exports.default = VoiceCancel;