slackapi / hubot-slack Goto Github PK
View Code? Open in Web Editor NEWSlack Developer Kit for Hubot
Home Page: https://slack.dev/hubot-slack/
License: MIT License
Slack Developer Kit for Hubot
Home Page: https://slack.dev/hubot-slack/
License: MIT License
Currently, using a designation that would be hyperlinked (#channel and @username) will send a nonsensical internal id to the bot. If this is simply a matter of providing special case where, if the hyperlinked text starts with @
or #
, then use the link text and not the link url:
https://github.com/tinyspeck/hubot-slack/blob/master/src/slack.coffee#L78-L79
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
we're using private room for inividual projects, and would love to have hubot as part of the room.
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?
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?
I'm wondering if it's possible to send text to a room which contains a link within specifically formatted text. EG, here is a link to google
Have tried standard markdown and also the instructions here: https://api.slack.com/docs/formatting, but to no avail.
Am I just doing something wrong?
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?
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).
Scripts that use robot.brain.usersForFuzzyName(name) to match users and store data about them
(like the ubiquitous https://github.com/github/hubot/blob/master/src/scripts/roles.coffee)
do not seem to work correctly using Slack. Seems to be an issue with how Slack is storing the user object, because anytime someone clears their session cookies by closing their browser the roles script loses all memory of them)
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.
Specifically, karma.coffee and giphy.coffee either break the Heroku process or just return "error" from Hubot in Slack. Any ideas?
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.
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?
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.
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.
Current you have to emit
multiple attachments when you wish to send multiple.
This is an issue when you have "ordered" attachments, for example things with due dates.
Looks like multiple attachments per request is supported, just that the code expects only one: https://github.com/tinyspeck/hubot-slack/blob/master/src/slack.coffee#L63
I can take a stab at implementing this if you like.
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!
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]:
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.
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
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. ๐ธ
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?
Helps keep track of things and move easily from using npm vs git for pkg source.
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.
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?
For HUBOT_SLACK_CHANNELS
, it would be helpful to mention that the channels should be specified without pounds. So general,random
instead of #general,#random
.
Or make it work with both variants in the code.
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
The URL / TOKEN structure you are using is depreciated.
The new API uses a structure like this:
https://hooks.slack.com/services/XXXXXXX/YYYYYY/ZZZZZZZZ
You can support this by adding something like
define('SLACK_URL'),'https://hooks.slack.com/services/XXXXXXX/YYYYYY/ZZZZZZZZ';
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...
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?
I can see my Hubot is starting up and connecting to Slack just fine in my logs...
It's also receiving messages...
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.
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?
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.
Why is every message that is received logged?
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.
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.
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.
Use this output to find id's https://api.slack.com/methods/users.list/test
It's a manual process and not scaleable, but it works.
can I use robot.send
?
robot.send 'general', 'hello world'
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.
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?
Our campfire hubot plugins often send pastes by including a \n
in a send()
, but in slack it doesn't show up as a paste (and can often flood the room).
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?
Not sure if slash commands are the right route, as they seem to require individual setup:
https://myteam.slack.com/services/new/slash-commands
Perhaps slack could expose another event for commands, if they haven't already? Need to investigate :)
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?
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.
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
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:
Is that the expected behavior or am I doing something wrong?
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.
Using Heroku Button
any chance to make hubot responds help with a private message ? Looks like it has been done for hubot-irc adaptor.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.