Botkit- controller.trigger() function is crashing the node.js app

93 Views Asked by At
    controller.hears('hi', 'direct_message', async(bot, message) => {
        controller.trigger('test', bot, message);
    });
    controller.on('test', async (bot,message) => {
        await bot.reply(message, 'triggerd test');
    });

The above code is working as expected but as soon as I get a reply 'triggered test' on Slack after that the app crashes with this error

C:\Users\Lenovo\Documents\Nodejs Project\chatbots\slackbot\node_modules\botbuilder-core\lib\turnContext.js:387
                    this.responded = true;
                                   ^

TypeError: Cannot perform 'set' on a proxy that has been revoked
    at Proxy.<anonymous> (C:\Users\Lenovo\Documents\Nodejs Project\chatbots\slackbot\node_modules\botbuilder-core\lib\turnContext.js:387:36)
    at Generator.next (<anonymous>)
    at fulfilled (C:\Users\Lenovo\Documents\Nodejs Project\chatbots\slackbot\node_modules\botbuilder-core\lib\turnContext.js:9:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

when I use this code then app doesn't crash

controller.hears('hi', 'direct_message', async(bot, message) => {
        await bot.reply(message, 'triggerd test');
    });

What am I missing in my code?

1

There are 1 best solutions below

0
samsonmarandi On

This can be fixed by using similar code in this link https://github.com/howdyai/botkit/issues/1856

controller.on('test', async (bot,message) => {
  await bot.changeContext(message.reference)
  await bot.reply(message, 'triggerd test');
});