0

The user sends Hi there ! (stored in message.text) from the chatbot UI; However, the ConversationPlugin's ingest middleware mutates message.text  to the value Hello. My question is : why isn't this value kept by the time the receive  middleware runs ? (cf. logs below) This behaviour is crucial for my app. I need to make sure the botkit message remembers/keeps my mutations  all along the way (all along the turn) !

[2020-05-16T11:23:47.130] [DEBUG] - [ConversationPlugin.ingest()] before triggering the event 'userMessage' => message.text ==> Hi there ! [2020-05-16T11:23:47.132] [DEBUG] - [ConversationPlugin.ingest()] after triggering the event 'userMessage' => message.text ==> Hello [2020-05-16T11:23:47.142] [DEBUG] - [ConversationPlugin.receive()] message.text => Hi there ! [2020-05-16T11:23:47.143] [DEBUG] - [ConversationPlugin.receive()] The message text is => Hi there !

Could you please help me understand/solve this ?

devio
  • 1,147
  • 5
  • 15
  • 41

1 Answers1

0

It is very difficult to say what is happening inside your code without seeing it.

This code works as expected - the ingest middleware changes the text, and that change is available inside the receive middleware:

module.exports = function(controller) {

  controller.middleware.ingest.use((bot, message, next) => {
    console.log('INGEST', message.text);
    message.text = 'INGESTING ' + message.text;
    next();
  });


controller.middleware.receive.use((bot, message, next) => {
  console.log('RECEIVED', message.text);
  next();
});


}```
Ben Brown
  • 71
  • 1