botkit
botkit copied to clipboard
bot change status go away after several hours
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?
same as https://github.com/howdyai/botkit/issues/442
@diaojunxian #261 might be helpful.
@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);
}
});```