@onereach/step-voice
Version:
Onereach.ai Voice Steps
51 lines (50 loc) • 1.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const lodash_1 = tslib_1.__importDefault(require("lodash"));
const voice_1 = tslib_1.__importDefault(require("./voice"));
class KickFromConference extends voice_1.default {
async runStep() {
const call = await this.fetchData();
if (call.conference == null) {
this.log.debug('already not in conference');
return this.exitStep('next');
}
const { room, user } = call.conference;
this.triggers.local(`in/voice/${call.id}`, async (event) => {
switch (event.params.type) {
case 'hangup':
await this.handleHangup(call);
return await this.waitConvEnd();
case 'conference-end':
call.conference = undefined;
await this.transcript(call, {
conferenceId: room,
reportingSettingsKey: 'transcript',
action: 'Conference Leave',
actionFromBot: true
});
return this.exitStep('next', lodash_1.default.omit(event.params, ['type']));
case 'error':
return this.throwError(event.params.error);
default:
return this.exitFlow();
}
});
this.triggers.otherwise(async () => {
const command = {
name: 'conference.kick',
params: {
room,
user
}
};
await this.sendCommands(call, [command]);
return this.exitFlow();
// Temporary fix till Kostya fixes voicer to return kick callback
// await Promise.delay(1000)
// return this.exitStep('next')
});
}
}
exports.default = KickFromConference;