minor rasa fix

This commit is contained in:
Dave Horton
2021-09-07 13:38:22 -04:00
committed by Dave Horton
parent d15fdcf663
commit 05c5319cbc
2 changed files with 5 additions and 3 deletions

View File

@@ -111,7 +111,9 @@ class Rasa extends Task {
const response = await this.post(this.data.url, payload); const response = await this.post(this.data.url, payload);
this.logger.debug({response}, 'Rasa:_onTranscription - got response from Rasa'); this.logger.debug({response}, 'Rasa:_onTranscription - got response from Rasa');
const botUtterance = Array.isArray(response) ? const botUtterance = Array.isArray(response) ?
response.reduce((prev, current) => `${prev} ${current.text}`, '') : response.reduce((prev, current) => {
return current.text ? `${prev} ${current.text}` : '';
}, '') :
null; null;
if (botUtterance) { if (botUtterance) {
this.logger.debug({botUtterance}, 'Rasa:_onTranscription: got user utterance'); this.logger.debug({botUtterance}, 'Rasa:_onTranscription: got user utterance');
@@ -119,7 +121,7 @@ class Rasa extends Task {
this.gatherTask.exec(cs, ep, this) this.gatherTask.exec(cs, ep, this)
.catch((err) => this.logger.info({err}, 'Rasa gather task returned error')); .catch((err) => this.logger.info({err}, 'Rasa gather task returned error'));
if (this.eventHook) { if (this.eventHook) {
this.performHook(cs, this.eventHook, {event: 'botMessage', message: botUtterance}) this.performHook(cs, this.eventHook, {event: 'botMessage', message: response})
.then((redirected) => { .then((redirected) => {
if (redirected) { if (redirected) {
this.logger.info('Rasa_onTranscription: event handler for bot message redirected us to new webhook'); this.logger.info('Rasa_onTranscription: event handler for bot message redirected us to new webhook');

View File

@@ -1,6 +1,6 @@
{ {
"name": "jambonz-feature-server", "name": "jambonz-feature-server",
"version": "0.3.1", "version": "0.6.6",
"main": "app.js", "main": "app.js",
"engines": { "engines": {
"node": ">= 10.16.0" "node": ">= 10.16.0"