mirror of
https://github.com/jambonz/jambonz-feature-server.git
synced 2025-12-22 01:27:55 +00:00
initial support for Rasa
This commit is contained in:
@@ -10,7 +10,7 @@ const makeTask = require('./make_task');
|
||||
const assert = require('assert');
|
||||
|
||||
class TaskGather extends Task {
|
||||
constructor(logger, opts) {
|
||||
constructor(logger, opts, parentTask) {
|
||||
super(logger, opts);
|
||||
this.preconditions = TaskPreconditions.Endpoint;
|
||||
|
||||
@@ -40,6 +40,8 @@ class TaskGather extends Task {
|
||||
|
||||
if (this.say) this.sayTask = makeTask(this.logger, {say: this.say}, this);
|
||||
if (this.play) this.playTask = makeTask(this.logger, {play: this.play}, this);
|
||||
|
||||
this.parentTask = parentTask;
|
||||
}
|
||||
|
||||
get name() { return TaskName.Gather; }
|
||||
@@ -154,7 +156,6 @@ class TaskGather extends Task {
|
||||
});
|
||||
ep.addCustomEventListener(AwsTranscriptionEvents.Transcription, this._onTranscription.bind(this, cs, ep));
|
||||
}
|
||||
this.logger.debug({vars: opts}, 'setting freeswitch vars');
|
||||
await ep.set(opts)
|
||||
.catch((err) => this.logger.info(err, 'Error setting channel variables'));
|
||||
|
||||
@@ -235,7 +236,11 @@ class TaskGather extends Task {
|
||||
await this.performAction({digits: this.digitBuffer});
|
||||
}
|
||||
else if (reason.startsWith('speech')) {
|
||||
await this.performAction({speech: evt});
|
||||
if (this.parentTask) this.parentTask.emit('transcription', evt);
|
||||
else await this.performAction({speech: evt});
|
||||
}
|
||||
else if (reason.startsWith('timeout') && this.parentTask) {
|
||||
this.parentTask.emit('timeout', evt);
|
||||
}
|
||||
this.notifyTaskDone();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user