Botkit: I can't see my own console logs, even when debug is set to true

Created on 31 Jan 2017  Â·  13Comments  Â·  Source: howdyai/botkit

This just makes it difficult to debug anything at all. I can't examine objects like bot and message.

Am I doing something wrong?

Slack-related question

All 13 comments

This simple example from the README doesn't work unless you're in a direct message conversation with the bot.

Simple reply example:

controller.hears(['keyword','^pattern$'],['message_received'],function(bot,message) {

  // do something to respond to message
  // ...

  bot.reply(message,"Tell me more!");

});

Slack requires you to specify a channel: https://api.slack.com/methods/chat.postMessage#channels, but that should only be if we're replying as a particular user.

I can't seem to figure out what's going on, and I have no way of inspecting anything, because when I console log, nothing shows up in my terminal.

Reply takes a message as its source, and pulls the channel field off it.
What Events did you subscribe to? The example above will trigger for the
right keyword on any user message being received (hence the
'message_received') but that only applies to message events youve
subscribed to
The main ones are 'message.channel' for public channel messages and '
message.im' for private messages
Have you subscribed to messages.channel?
On Tue, Jan 31, 2017 at 1:07 PM Costa Michailidis notifications@github.com
wrote:

This simple example from the README doesn't work unless you're in a direct
message conversation with the bot.

Simple reply example:

controller.hears(['keyword','^pattern$'],['message_received'],function(bot,message) {

// do something to respond to message
// ...

bot.reply(message,"Tell me more!");

});

Slack requires you to specify a channel:
https://api.slack.com/methods/chat.postMessage#channels

I can't tell if botkit is doing that for me, or if I'm supposed to pull
the incoming channel from the bot or message objects and send in back in
the reply function parameters.

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/howdyai/botkit/issues/635#issuecomment-276443149, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AMUR2zeNsjrn9HBbpU7Ppkkj4Xv9FRBpks5rX3h1gaJpZM4Ly9qp
.

Well, hilariously enough, my code triggers on a bunch of swear words, and replies with the words 'HR!'

It's just a silly test for now. We'll do more useful things after we have some fluency in making bots, I promise : )

kit.hears(
  ['poo', 'darn you', 'butt'], // PG on the public web
  ['message_received'],
  function (bot, message) {
    bot.reply(message, "HR!")
  }
)

I'd still really love to see my own console logs : )

@jonchurch So, I can't figure out how to subscribe my bot to a channel?

You have to /invite the bot into any particular channel you want it to listen to.

I was assuming you are using Events API, if you are then you can add bot permissions like message.channels under Event Subscriptions in your app's settings http://api.slack.com/apps

Turns out I had already done that.

shot

It still doesn't respond to 'message_received', sorry not really sure what's wrong here. I'm reviewed my code many times, in fact the code I copied straight from the botkit guide doesn't run either.

hmm try using 'ambient' instead of 'message_received'

Nope, it's just me sending out profanity all by my lonesome. Here's the stackoverflow question for this: http://stackoverflow.com/questions/41964205/slackbot-not-responding-to-message-received-event

I've had problems with message_received and don't use it with Slack anymore, I get more specific by using 'direct_message', 'direct_mention', 'mention', or 'ambient'
you can combine them like so ['direct_message', 'mention', 'ambient'] which should work for you here.

@jonchurch No, that doesn't help. I want to make a bot that listens for profanity, and then sends out an alert when that happens, but my use case is just one use case.

The larger issue is that I can't log anything to my console to inspect things and debug.

Can you show me an example that demonstrates this issue?

There are no console.logs in the above code snippets
On Mon, Feb 6, 2017 at 12:12 PM Costa Michailidis notifications@github.com
wrote:

@jonchurch https://github.com/jonchurch No, that doesn't help. I want
to make a bot that listens for profanity, and then sends out an alert when
that happens, but my use case is just one use case.

The larger issue is that I can't log anything to my console to inspect
things and debug.

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/howdyai/botkit/issues/635#issuecomment-277747827, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AMUR29bxhykhRUy8v-1XFnZ1z2-bOyK2ks5rZ1SEgaJpZM4Ly9qp
.

Does some of the code execute? You arent receiving a message from your bot correct?

Okay, cool!

kit.hears(
  ['poop', 'kaka', 'other-profanity'],
  ['message_received'],
  function (bot, message) {
    console.log('MY LOG', message)
    bot.reply(message, "HR! \n -burp- mmmm I luvz milk.")
  }
)

MY LOG never shows up, and neither does the the bot message. And, now it becomes obvious why the console log doesn't show up, the event's not firing.

Baaahahahaa : )

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abinashmohanty picture abinashmohanty  Â·  4Comments

liornaar picture liornaar  Â·  3Comments

znat picture znat  Â·  4Comments

imjul1an picture imjul1an  Â·  3Comments

dfischer picture dfischer  Â·  4Comments