botkit icon indicating copy to clipboard operation
botkit copied to clipboard

heard_trigger event throws error when the heard message is sent by another bot

Open gianniszach opened this issue 6 years ago • 1 comments

Hi all,

You can reproduce this issue with the following scenario:

BotA sends a message to a public channel. A BotB has a hear pattern configured which picks up the BotA's message and if we use the heard_trigger event on this message an error is thrown.

The error is caused by the md5 hash created by the botkit/lib/Studio.js (line 721). The heard_trigger is trying to md5(message.user) but since the message is sent by a bot the message.user property doesn't exist and the heard_trigger throws an error.

gianniszach avatar Dec 10 '17 10:12 gianniszach

I just came across this same issue where Studio.js is trying to md5(message.user) but in my case message is undefined. I am using a custom connector but when calling the spawn function (see below), CoreBot.js triggers the spawned event via botkit.trigger('spawned', [worker]); which as you can see only supplies the worker argument and no message argument.

controller.spawn({}, function (bot) {
    controller.ingest(bot, req.body, res);
});

A temporary solution for me to is just opt-out of studio stats, but I assume you guys probably don't want people to be opting out just to avoid a code bug.

LukeBaulch avatar Nov 05 '18 02:11 LukeBaulch