GithubHelp home page GithubHelp logo

slackapi / hubot-slack Goto Github PK

View Code? Open in Web Editor NEW
2.3K 148.0 636.0 811 KB

Slack Developer Kit for Hubot

Home Page: https://slack.dev/hubot-slack/

License: MIT License

CoffeeScript 100.00%
hubot-adapter hubot coffeescript slack slack-app bot

hubot-slack's Introduction

hubot-slack

Important Notice

This project is no longer under active development. If you’re just getting started, we recommend taking a look at Bolt for JS with Socket Mode first. If you’ve been using this project, only critical issues (such as severe security issues) will be addressed, but we advise planning to migrate to the newer SDK.

This is a Hubot adapter to use with Slack.

Hubot Slack Adapter CI Builds codecov npm (scoped)

Comprehensive documentation is available.

hubot-slack's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hubot-slack's Issues

No hubot on channels

Hi.

I just configured hubot for slack and it looks like it doesn't work - it doesn't appear on any channel.
I don't have any errors in logs (it runs on heroku).
I tried changing whitelist/blacklist channels but with no luck.
Any ideas how can I debug what is wrong?

Hubot die message not delivered

Hi there

I think this is related to slack adapter, hubot die message delivered ok when I run it in Shell but not with slack adapter.

my ping.coffee, I added a sleep function and call it to sleep 10 seconds before process.exit 0 but does not make any difference.

# Description:
#   Utility commands surrounding Hubot uptime.
#   hubot responds to "thank you" now
#
# Commands:
#   hubot ping - Reply with pong
#   hubot echo <text> - Reply back with <text>
#   hubot time - Reply with current time
#   hubot die - End hubot process

userCanKillMe  = ['admin', 'Shell']
responseToThanks = ['You are welcome',
                    'My pleasure',
                    'Buy me a drink next time']

refuseToDie    = ['Well, give me a reason',
                  'Why you want to kill me?',
                  'Are you sure?',
                  'Don\'t like me? I am only trying to help',
                  'Bored? find something else to do',
                  'You can\'t kill me!']

sleep = (ms) ->
  start = new Date().getTime()
  continue while new Date().getTime() - start < ms

module.exports = (robot) ->
  robot.respond /thanks?\s*[a-zA-Z!\s]*$/i, (msg) ->
    msg.send msg.random responseToThanks

  robot.respond /PING$/i, (msg) ->
    msg.send "PONG"

  robot.respond /ADAPTER$/i, (msg) ->
    msg.send robot.adapterName

  robot.respond /ECHO (.*)$/i, (msg) ->
    msg.send msg.match[1]

  robot.respond /TIME$/i, (msg) ->
    msg.send "Server time is: #{new Date()}"

  robot.respond /DIE$/i, (msg) ->
    if msg.message.user.name in userCanKillMe
      msg.send "I will be back ..."
      sleep 10000
      process.exit 0
    else
      msg.send msg.random refuseToDie

Add robot.enter and robot.leave support?

Hi again!
I have a really basic script setup to post when users enter or leave rooms:

enterReplies = ["WELCOME TO THE THUNDERDROME", "WELCOME TO THE JUUUUUNGLLLEEEEE!"]

leaveReplies = [":crying_cat_face:", ":crying_cat_face: Nooooooooo! Anything but that!", "They're dropping like FLIES!"]

module.exports = (robot) ->
  robot.enter (msg) ->
    msg.send msg.random enterReplies

  robot.leave (msg) ->
    msg.send msg.random leaveReplies

...But I can't seem to get it to work (Just tested it).

My guess is that enter/leave messages aren't output via the Slack webhook? If not, it'd require a bit of work on the Slack side to make this happen (for which I'm no help, alas).

Add config option to ignore channels

Hi!
Hubot's great, but it's just too damn easy to pugbomb the #general channel. To that end, I think it'd be helpful to have a config option that lets you specify Slack channels where Hubot should not respond to commands.

Seems like it'd be a fun minor dev task and I might do it for my company regardless -- let me know if you want me to submit a pull request!

Support self-hosted hubots

Not sure if this is the right place for this but, I am trying to deploy a hubot locally and something seems to be missing.

The hubot appears to connect successfully:

root@97d32bf068fa:/usr/local/hubot# ./bin/hubot --adapter slack --name slackbot
Slack adapter options: { token: 'XXXXX',
  team: 'desmondmorris',
  name: 'slackbot',
  mode: 'blacklist',
  channels: [],
  link_names: 0 }
Successfully 'connected' as slackbot

I get no response from slackbot: help or @slackbot: help

Are there any limitations to self-hosting? I omitted the "Hubot URL" in configuration, is this necessary?

Hubot behind firewall, can't connect

I'm having trouble with our hubot implementation
Currently we are using hipchat and thinking about moving to Slack

I followed the instructions, and when I run hubot, locally, it looks like it connects to Slack successfully

But then the integration is disabled and I get this error

We are getting this error: curl_error: connect() timed out!. Please fix this issue and re-enable the integration to the left.

Our hubot is behind a firewall on purpose, and we really don't want to expose it's url to the outside world. But it seems that the integration configuration requires a public accesible url.

Is there any way around this? As this will be the deal breaker for us unfortunately.

Questions about html escape

Hi folks. I'm getting unexpected behavior when trying to send formatted links.

I'm attempting to send a response from hubot with a link label, like so:

msg.send "<https://github.com/link/to/a/PR|myrepo #42> fix some broken"

What I'd expect to see in Slack is this, with {{ … }} representing hyperlinked text with the URL I passed.

{{myrepo #42}} fix some broken

Instead, I see this, with literal brackets and the link in the wrong place:

<{{myrepo}} #42> fix some broken

Looking around, it's pretty evident that this is due to the escapeHTML call that occurs before the message is sent. In fact, removing that call gives me the result I'd expect, with the properly parsed link.

I'm trying to understand how https://api.slack.com/docs/formatting works in the context of hubot, but I'm a bit confused. What is the best way to allow for what I want to do without screwing up everyone else's hubot? Should I create msg.sendRaw? Is it actually safe to remove escapeHTML since slack handles most of it server-side?

Is there anyway to send a private message to a user?

My company just started using Slack and we are loving it, we already have our hubot integrated, etc. However, I am building a custom task manager and was wondering if there is anyway to send a private message to a user? This is needed for task reminders. No need to pollute the open channels.

access to user's email address

I'm new to both Hubot and Slack, but is there a way to access msg.message.user.email_address?
For example, I'd like to do stuff like this, which doesn't appear to grab the email address in Slack...

no channel specified error using webhook from gitlab

I have hubot-slack running and integrated with slack just fine.
It detects requests and responds to messages from slack but now I want to get the gitlab integration working.
Added the webhook to gitlab as
http://urltohubot:8080/gitlab/web
I see a sending message appear on the hubot screen but then it says
Slack services error: 500 no channel specified

Any ideas what I have missed?

Andrew

TypeError: Cannot read property 'token' of undefined

I'm getting this error on Heroku for each chat message:

TypeError: Cannot read property 'token' of undefined

The offending line is https://github.com/tinyspeck/hubot-slack/blob/master/src/slack.coffee#L161

Could it be an issue with the scoping of this?

Here is a full backtrace:

2014-09-02T20:32:57.663339+00:00 app[web.1]: Slack adapter options: { token: '[REDACTED]',
2014-09-02T20:32:57.663357+00:00 app[web.1]:   name: 'actionbot',
2014-09-02T20:32:57.663358+00:00 app[web.1]:   mode: 'blacklist',
2014-09-02T20:32:57.663356+00:00 app[web.1]:   team: 'actionsprout',
2014-09-02T20:32:57.663361+00:00 app[web.1]:   link_names: 0 }
2014-09-02T20:32:57.663360+00:00 app[web.1]:   channels: [ 'development', 'general', 'random' ],
2014-09-02T20:32:57.664619+00:00 app[web.1]: Successfully 'connected' as actionbot

2014-09-02T20:44:39.176747+00:00 heroku[router]: at=info method=POST path="/hubot/slack-webhook" host=actionsprout-slackbot.herokuapp.com request_id=134eaf43-0b20-4b31-8d76-525b653a1ab8 fwd="54.91.174.134" dyno=web.1 connect=4ms service=6ms status=500 bytes=711
2014-09-02T20:44:39.171453+00:00 app[web.1]: Incoming message received
2014-09-02T20:44:39.172026+00:00 app[web.1]: TypeError: Cannot read property 'token' of undefined
2014-09-02T20:44:39.172029+00:00 app[web.1]:   at /app/node_modules/hubot-slack/src/slack.coffee:161:7, <js>:165:47
2014-09-02T20:44:39.172031+00:00 app[web.1]:   at callbacks (/app/node_modules/hubot/node_modules/express/lib/router/index.js:161:37)
2014-09-02T20:44:39.172032+00:00 app[web.1]:   at param (/app/node_modules/hubot/node_modules/express/lib/router/index.js:135:11)
2014-09-02T20:44:39.172034+00:00 app[web.1]:   at pass (/app/node_modules/hubot/node_modules/express/lib/router/index.js:142:5)
2014-09-02T20:44:39.172035+00:00 app[web.1]:   at Router._dispatch (/app/node_modules/hubot/node_modules/express/lib/router/index.js:170:5)
2014-09-02T20:44:39.172037+00:00 app[web.1]:   at Object.router (/app/node_modules/hubot/node_modules/express/lib/router/index.js:33:10)
2014-09-02T20:44:39.172038+00:00 app[web.1]:   at next (/app/node_modules/hubot/node_modules/express/node_modules/connect/lib/proto.js:190:15)
2014-09-02T20:44:39.172040+00:00 app[web.1]:   at multipart (/app/node_modules/hubot/node_modules/express/node_modules/connect/lib/middleware/multipart.js:60:27)
2014-09-02T20:44:39.172041+00:00 app[web.1]:   at /app/node_modules/hubot/node_modules/express/node_modules/connect/lib/middleware/bodyParser.js:57:9
2014-09-02T20:44:39.172043+00:00 app[web.1]:   at IncomingMessage.<anonymous> (/app/node_modules/hubot/node_modules/express/node_modules/connect/lib/middleware/urlencoded.js:70:11)
2014-09-02T20:44:39.172045+00:00 app[web.1]:   at IncomingMessage.emit (events.js:92:17)
2014-09-02T20:44:39.172046+00:00 app[web.1]:   at _stream_readable.js:943:16
2014-09-02T20:44:39.172048+00:00 app[web.1]:   at process._tickCallback (node.js:419:13)
2014-09-02T20:44:39.172049+00:00 app[web.1]:

Webhook content type support

Does the Slack adapter support listening for application/json content-type webhooks? I seem to get nothing but errors when trying to parse it out.

Using application/x-www-form-urlencoded works fine and I'm happy to stay there if need be. Just curious.

The reply command uses the old handle

Hello,

The msg.reply method is not working as expected when a user changes its handle.

Example:
My old handle was 'matthieu'. My new one is 'matt'. When I receive a reply, hubot prints "matthieu: {answer}".

Is there a way to tell hubot that the handle has changed or is it a bug coming from Slack ?

Thanks.

ssl?

Any chance of being able to setup hubot with slack over https? (Sorry if the question is answered else where and I was too lazy to find it)

Also, I am using hubot robot.router.post for custom slash commands and I would like those to use ssl as well.

@<name> doesn't work in messages

I suspect that this is more a slack issue than a slackbot issue. However, when you send a @ via the 'send' method, slack assumes it is just text and doesn't do anything special with it.

TypeError: Object #<Robot> has no method 'on'

I'm trying to migrate from hipchat to slack and I'm encountering a few issues with the slack.coffee file itself.

Here's the stack trace:

TypeError: Object #<Robot> has no method 'on'
    at Slack.run (/home/ysbot/app/node_modules/hubot-slack/src/slack.coffee:159:18)
    at Robot.run (/home/ysbot/app/node_modules/hubot/src/robot.coffee:375:27)
    at Object.<anonymous> (/home/ysbot/app/node_modules/hubot/bin/hubot:106:11)
    at Object.<anonymous> (/home/ysbot/app/node_modules/hubot/bin/hubot:109:4)
    at Module._compile (module.js:456:26)
    at Object.exports.run (/home/ysbot/app/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/coffee-script.js:79:25)
    at compileScript (/home/ysbot/app/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/command.js:175:29)
    at /home/ysbot/app/node_modules/hubot/node_modules/coffee-script/lib/coffee-script/command.js:150:18
    at fs.js:271:14
    at Object.oncomplete (fs.js:107:15)

Any help would be appreciated, cheers.

Local testing

I'm wanting to run a local instance of Hubot during development, and test live on Slack. The problem is, simply running bin/hubot --adapter slack doesn't work as non of the config vars are available.

That being said, I have a gitignored priority loaded script file which mimicks Heroku config vars so I can locally test everything before deploying, and that works great. This won't work with the Slack adapter (or possibly any adapter) because the adapter tries to fire up before any files in the scripts folder are loaded.

At the moment, I test functionality as best I can locally, deploy to staging on Heroku so I can see how output appears in Slack, then when happy, deploy to production.. I'm hoping to skip this step if it's possible.. basically, being able to set config/process vars before Hubot loads an adapter.

Any thoughts would be greatly appreciated.

Cannot find module 'hubot'

I'm installing Hubot to Heroku & I'm following the instructions outlined on the hubot-slack page but when I deploy to Heroku I get the following error:

ERROR Cannot load adapter slack - Error: Cannot find module 'hubot'

Is there something I'm doing wrong? In the dependencies section in my package.json file I have:

"hubot-slack": "1.5.2"

and my Procfile looks like:

web: bin/hubot --adapter slack

Slack is sending a GET, but hubot-slack is expecting POST

On slack:
hubot: help

$ heroku logs --tail
2014-02-10T10:17:21.948985+00:00 heroku[router]: at=info method=GET path=/hubot/slack-webhook host=xxxxxxxxxx.herokuapp.com request_id=6ef841ae-f244-46f3-bc46-be80e1169787 fwd="54.205.145.201" dyno=web.1 connect=1ms service=3ms status=404 bytes=42

but in slack.coffee:

    # Listen to incoming webhooks from slack
    self.robot.router.post "/hubot/slack-webhook", (req, res) ->
      self.log "Incoming message received"

The Slack integration seems to send GET instead of a POST for some reason? Am I missing something?

Hubot doesn't show up in user list

The adapter works great and my Hubot has no problem listening/responding to messages. The only weird thing is that it doesn't show up in any user list, as far as I can tell. This has two slightly annoying results:

  1. It's hard to tell that it's even connected
  2. I can't DM it

Is that the expected behavior or am I doing something wrong?

No response from Hubot

I successfully deployed Hubot to Heroku and from the logs it seems fine but I get no response when I ping Hubot @hubot: help although the message arrives on Hubots side:

$ heroku logs
...
2014-02-21T15:41:07.797660+00:00 app[web.1]: Incoming message received

Do you have any idea how I can debug this further?

Verify slack token at some point

I'm trying out slack for the first time, and of course want to get some hubot up ons. During my first attempts, I kept getting back:

2014-04-21T13:25:22.915290+00:00 heroku[router]: at=info method=POST path=/hubot/slack-webhook host=<redacted> request_id=cd37be86-2ad5-43df-b162-d90c34b3af56 fwd="54.242.187.232" dyno=web.1 connect=1ms service=160ms status=200 bytes=138
2014-04-21T13:25:22.784723+00:00 app[web.1]: Incoming message received
2014-04-21T13:25:22.784856+00:00 app[web.1]: Sending message
2014-04-21T13:25:23.026432+00:00 app[web.1]: Slack services error: 404
2014-04-21T13:25:23.026513+00:00 app[web.1]: No hooks

Some digging lead me to comments in #39 that suggested the token was correct. Sure enough, that was the problem. I don't really understand why it changed between when I added integration initially and got other things going (maybe because I updated the hook?).

I was originally thinking to check like the http status code or body, but I don't think those would be specific enough to detect an incorrect token.

It looks like the Slack API has /auth/test which would do exactly what we want: verify the auth. It seems like that might need to be setup as a different 'Application' though and would have a different token.

Edit last message

Much the same as pressing Up (or of course, clicking "Edit") to edit the last message, I'm wondering if it's possible to do that programmatically within hubot or the adapter.

Would be stellar if it's possible.

Does anyone have any ideas?

Hubot won't respond back to messages in Slack

I can see my Hubot is starting up and connecting to Slack just fine in my logs...

slack-auth

It's also receiving messages...

screen shot 2014-08-18 at 11 02 48 am

However, when I throw it a command like "ping", "hubot ping", "vuebot ping" or "slackbot ping" (wherein it's supposed to reply with PONG), nothing happens.

screen shot 2014-08-18 at 11 02 38 am

What's going on? Did I not set something up correctly?

Here's my config:

=== vuebot Config Vars
HEROKU_URL:              'http://vuebot.herokuapp.com'
HUBOT_AUTH_ADMIN:        'tubbo'
HUBOT_SLACK_BOTNAME:     'slackbot'
HUBOT_SLACK_CHANNELMODE: 'whitelist'
HUBOT_SLACK_CHANNELS:    'ping-pong,botsnack'
HUBOT_SLACK_TEAM:        'TelVue'
HUBOT_SLACK_TOKEN:       [REDACTED]
REDISTOGO_URL:           [REDACTED]

I followed the instructions at the integration setup page...is there anything more I need to do to get it to send back messages?

Hubot does not appear in multiple channels in whitelist mode

We host a very basic hubot on Heroku (named rudy), but can only make him appear in one channel at a time when the HUBOT_SLACK_CHANNELMODE set to whitelist.

These are our relevant environment variables

HUBOT_SLACK_CHANNELMODE: whitelist
HUBOT_SLACK_CHANNELS:    channel1, channel2 
# in channel1
rudy ping
(works)
# in channel2
rudy ping
(doesn't work)

If we remove channel1 and instead set HUBOT_SLACK_CHANNELS as a single value of channel2 then rudy ping works in channel2.

Is there perhaps something I've misunderstood about the docs, or is this a bug?

Implement topic setting

you already have this as a TODO but I thought that perhaps I would upgrade it into a super-TODO, that is to say, an Issue, because it would make my scripts better and I am interested in getting that GitHub "issue closed" notification email if it ever gets in. 😸

No response from Hubot

Since the bug #35 is closed, I am reopening a new bug because 2.2.0 is not working at all for me despite proper config in the integration and resetting multiple time the hubot following your exact instructions.

It receives the messages fine, but I never see it sending a response

I am using node 0.10.32, and hubot hosted "2.7.1".

I cannot see any log message that it is sending back so something breaks somewhere in the chain

HTML being escaped not rendered

We have a very basic implementation of Hubot in Slack and we're experiencing an issue whereby the HTML output from Hubot messages isn't being rendered as HTML, but escaped and shown as plain text.

See image:
screen shot 2014-09-15 at 8 58 28 am

Any ideas what might be causing it?

Potentially related, the last character of some strings aren't being shown in Slack - not sure if that's a Hubot issue or a Slack issue.

upload file

Is there a way to upload a file to slack?
I see how to send messages and links, but I want to upload a local image as an attachment.
Is this possible?

Hubot-slack does not send updated username?

After I change my username in Slack, Hubot's list of users (robot.brain.users()) still contains my old username. I'm not sure if this is an issue with hubot-slack not sending the updated username, or with hubot not updating its list of users. I have sent messages since my username was changed.

Can anyone point me in the right direction? I would be happy to make a PR.

Can't get messageRoom working

I've got a fairy simple plugin that works with a cronjob

module.exports = (robot) ->
  reminderJob = new cronJob '50 10 * * 2-5',
                ->
                  robot.messageRoom "#general", "@channel binnen 10min verstuur ik de fax naar Sonja!"
                null
                true
                'Europe/Brussels'

This worked (with something else for #general) when we ran on HipChat, now it does not say anything.

I also tried with the "C0xxxxxxx" notation instead of the #general.

Any idea's?

example for sending message to a private group?

Hi there,

Using hubot and slack adapter, I'm trying to send a message to a specific private group, but keep getting Slack services error: 500 No channel specified

user = {}
user.room = room # using numeric room id pulled from API
robot.send {user: user}, "hello world"

Any hint?


#chargedByZenHub

Hubot - unknown connection state to Slack

Following your instructions I have deployed Hubot to Heroku and have configure the slack integration on slack.com.
It looks like it is running on Heroku but http://switchbot4.herokuapp.com/ returns Cannot GET /
I don't know if that is correct or a problem with my set up or if its simply not running. Is there a way of getting logs to work out the issue?
Will i see hubot in slack users list? He's not responding to a hubot ping command

Sorry to ask basic questions this has been a massive learning project for me learning Git, cloud deployment, and hubot itself with no real developer skill.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.