botkit icon indicating copy to clipboard operation
botkit copied to clipboard

bot change status go away after several hours

Open ryzn0518 opened this issue 10 years ago • 3 comments

I have created a bot which works fine for only some hours, but, with no reason, after several hours the bot status is go away and I cannot interact with it. The bot is still running in the server, it didn't crash and I don't see any error log?

ryzn0518 avatar Oct 14 '16 02:10 ryzn0518

same as https://github.com/howdyai/botkit/issues/442

peterswimm avatar Nov 11 '16 22:11 peterswimm

@diaojunxian #261 might be helpful.

garymoon avatar Nov 12 '16 04:11 garymoon

@diaojunxian

https://github.com/howdyai/botkit/pull/532 might solve your problem.

Below might help you keep track of rtm disconnects and reconnect failurs which can cause the bot to stop responding.

console.log('\n\n*** '+moment().tz('America/Los_Angeles').format()+' ** The RTM api just closed');

try {
controller.findTeamById('<SLACK_TEAM_ID_HERE>', function(err, team) {
var alertBot = controller.spawn(team);
alertBot.api.chat.postMessage(
{
channel : '<SLACK_CHANNEL_ID_HERE>',
text: 'GUYS!!! I just got an RTM Close event trigger for this team --> '+bot.team_info.id+' '+bot.team_info.name+' .',
attachments: [],
}, function (err, response) {
});
});
} catch (err) {
console.log('\n\n*** '+moment().tz('America/Los_Angeles').format()+' Tried to send alert for an rtm_close event but failed with this error: '+err);
}
});

controller.on('rtm_reconnect_failed',function(bot) {
console.log('\n\n*** '+moment().tz('America/Los_Angeles').format()+' ** Unable to automatically reconnect to rtm after a closed conection.');

try {
controller.findTeamById('<SLACK_TEAM_ID_HERE>', function(err, team) {
var alertBot = controller.spawn(team);
alertBot.api.chat.postMessage(
{
channel : '<SLACK_CHANNEL_ID_HERE>',
text: 'GUYS!!! I just got an RTM Reconnect Failed trigger for this team --> '+bot.team_info.id+' name: '+bot.team_info.name+'. The team either uninstalled the app or there was an issue which requires a resart of the bot.',
attachments: [],
}, function (err, response) {
});
});
} catch (err) {
console.log('\n\n*** '+moment().tz('America/Los_Angeles').format()+' Tried to send alert for an rtm_reconnect_failed event but failed with this error: '+err);
}
});```

inn0v8 avatar Dec 08 '16 01:12 inn0v8