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