When I run the bot It gets stuck on this message:
token=my-real-slack-token node bot.js
** No persistent storage method specified! Data may be lost when process shuts down.
** Setting up custom handlers for processing Slack messages
** API CALL: https://slack.com/api/rtm.start
** BOT ID: catbot ...attempting to connect to RTM!
Here's the code:
var Botkit = require('botkit')
if (!process.env.token) {
console.log('Error: Specify token in environment')
process.exit(1)
}
var controller = Botkit.slackbot({
debug: false,
})
controller.spawn({
token: process.env.token
}).startRTM(function(err) {
if (err) {
throw new Error(err)
}
})
function rand(min, max) {
return Math.floor(Math.random() * (max - min)) + min;
}
var listeners = 'direct_message, direct_mention, mention'
controller.hears(['rand'], listeners, function(bot, message) {
bot.reply(message, rand(1,100))
})
What happens if you set debug to true?
Does your bot appear online in slack?
The bot does appear online when the server is running but doesn't respond to messages, maybe I'm not doing that right? I did successfully invite him to a channel though and he didn't reply to direct message or a mention in the channel he joined.
Here's the debug output with a redacted section that included a lot of private data in the form of JSON.
** No persistent storage method specified! Data may be lost when process shuts down.
** Setting up custom handlers for processing Slack messages
Setting up a handler for message_received
** API CALL: https://slack.com/api/rtm.start
rtm.start { no_unreads: true,
simple_latest: true,
token: 'xoxb-API_TOKEN' }
Setting up a handler for direct_mention
Setting up a handler for direct_mention
Setting up a handler for direct_mention
Got response null REDACTED
** BOT ID: catbot ...attempting to connect to RTM!
No handler for rtm_open
RECEIVED MESSAGE
CUSTOM FIND CONVO undefined undefined
DEFAULT SLACK MSG RECEIVED RESPONDER
No handler for hello
RECEIVED MESSAGE
CUSTOM FIND CONVO U0GUS7XTJ undefined
DEFAULT SLACK MSG RECEIVED RESPONDER
No handler for presence_change
RECEIVED MESSAGE
CUSTOM FIND CONVO U0GUS7XTJ undefined
DEFAULT SLACK MSG RECEIVED RESPONDER
No handler for presence_change
No handler for tick
No handler for tick
No handler for tick
No handler for tick
No handler for tick
No handler for tick
...
Not sure if this is related, but botkit doesn't seem to work behind a proxy, and we see the same message as the top comment.
I think that was the problem, as I was behind a proxy but when I put it in production it started to work.
@montanaflynn you let your bot token in your last log dump ;-) you should remove it from here and change the bot token!
@Deamon thanks!
Hey guys!
I'm getting the same response ("No handler for tick"), but I'm not using a proxy.
What it could be?
Could you help me?
Thanks!
:+1: any insight into this?
I just set up a bot for the first time myself.
Your code works. However, bot.reply wants a string, not the raw number rand is giving it. Thus, the undefined undefined. If you do:
bot.reply(message, ''+rand(1,100))
You'll see the random number.
No handler for tick is not an error, simply a notice when debugging is on.
I also hit this problem, and was puzzled since I wasn't using a proxy.
token=my_token node demo_bot.js produces the error for me on Mac, but token=my_token node demo_bot does not. Small silly error.
Just find the bot in the slack users list and "DM" it. It will only respond in a team chat if its invited. If not, no.
About the debug logs 'No handler for tick' - it probably means that it has nothing to do now.
@devaroop's solution worked for me, just remove the .js when starting the bot (e.g. node slack_bot instead of node slack_bot.js)
Hey guys/gals, here is my bot code, its called yden.js
on my local machine i execute 'node yden' in my terminal (windows).
var Botkit = require('botkit');
var controller = Botkit.slackbot();
var bot = controller.spawn({
token: 'xoxb-mytoken'
})
bot.startRTM(function(err,bot,payload) {
if (err) {
throw new Error('Could not connect to Slack');
}
});
var controller = Botkit.slackbot({
debug: true
//include "log: false" to disable logging
//or a "logLevel" integer from 0 to 7 to adjust logging verbosity
});
// give the bot something to listen for.
controller.hears('hello',['direct_message','direct_mention','mention'],function(bot,message) {
bot.reply(message,'Hello yourself.');
});
here is my terminal window.
C:\Users\andrew\hit\yden>node yden
info: ** No persistent storage method specified! Data may be lost when process shuts down.
info: ** Setting up custom handlers for processing Slack messages
info: ** API CALL: https://slack.com/api/rtm.start
info: ** No persistent storage method specified! Data may be lost when process shuts down.
info: ** Setting up custom handlers for processing Slack messages
debug: Setting up a handler for message_received
debug: Setting up a handler for direct_message
debug: Setting up a handler for direct_mention
debug: Setting up a handler for mention
notice: ** BOT ID: yden ...attempting to connect to RTM!
Looking at slack itself, i can see my bot user come online.
I have created a direct message with yden.
However when i talk to yden, it does not respond. I can type "hello", "@yden hello" or "hello @yden" and there is no response.
There is also no further output in my terminal window.
Ideas?
@ajhstn Can you turn debug: true and post the logs. Also remember - first step to check if your bot is working is to see if its online. It should have that green bulb against it.
Also, look at this thread above, it explains almost all the problems.
Hey think you for responding. I ended up copying another example from the same repo and that piece worked.
I would like to point out though I specifically mentioned and answered both of your questions in my original post already.
Sent from my iPhone
On 13 May 2016, at 13:07, Devaroop Bhattacharya <[email protected]notifications@github.com> wrote:
@ajhstnhttps://github.com/ajhstn Can you turn debug: true and post the logs. Also remember - first step to check if your bot is working is to see if its online. It should have that green bulb against it.
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHubhttps://github.com/howdyai/botkit/issues/17#issuecomment-218941506
IMPORTANT NOTICE: This email, including any attachments, may contain privileged, confidential, and/or proprietary information, or may be subject to copyright. This email is intended only to be seen and used by the named addressee(s). If you are not the intended recipient of this email, you must not disclose or use the information contained in this email. If you have received this email in error, please notify the sender immediately, and permanently delete the original and any copies. We do not guarantee that this email and any attachments are free from virus or other errors. We will not be responsible for loss or damage resulting (either directly or indirectly) from any such virus or error. The content of and opinions expressed in this email are not necessarily the opinions held by Hillsong Church. If you believe this message is classified as a commercial electronic message in accordance with the Spam Act, you may indicate that you do not wish to receive further commercial electronic messages from us by sending an email to [email protected] . Please consider the environmental impact before printing this email.
info: ** No persistent storage method specified! Data may be lost when process s
huts down.
What is this error exactly?
@mayurthole I suppose you do not provide a database connection/method to persist data, e.g. for Mongo or Postgres. You should provide upon creation of an instance of your bot/slack controller, otherwise you will not be able to store teams or user when the register to your application/integration.
Most helpful comment
@devaroop's solution worked for me, just remove the
.jswhen starting the bot (e.g.node slack_botinstead ofnode slack_bot.js)