Last active
August 12, 2017 04:05
-
-
Save anthonygore/5dd66f7ca1f76f3bfa54141e19818ec5 to your computer and use it in GitHub Desktop.
Send users a welcome message (IM) from the slackbot when they join your Slack team. Uses https://github.com/smallwins/slack so look at that first. Load this somewhere in a running Node JS app.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var slack = require('slack'); | |
var bot = slack.rtm.client(); | |
var token = "your_slack_token"; | |
bot.team_join(function(obj) { | |
console.log("Team join triggered"); | |
slack.chat.postMessage( | |
{ | |
token: token, | |
channel: obj.user.id, | |
text: "Hello new user and welcome to the team!" | |
}, | |
function(err, data) { | |
// Handle errors here | |
}) | |
; | |
}); | |
bot.listen({token: token}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Which dependency do I use in package.json? thanks