1.0.1-beta.1 • Published 10 years ago
bot-relay v1.0.1-beta.1
relay
Bot user that can send messages to different users
Installation
npm install bot-relayusage
- Instance initialization
const relay = require('bot-relay');
let token = '<slack bot token>'; //@TODO add url to get this token
let slackRelay = relay.slackRelay(token);
slackRelay.connect().then( relayInstance => {
// send messages to known users
// broadcast messages to all users
// post messages to channels
}, connectionError => {
// you can try to reconnect
// you can verify with slack to make sure your token is still valid
});- Turn the bot on and off.
slackRelay.connect(); // return promise - resolve with relay instance
slackRelay.disconnect(); // return promise - resolve with success message- Relay provide a "notify" method that takes in the user-name or channel-name
relayInstance.notify('<user-1>', 'user_typing');- Send message to slack user
- given user name
- use your bot to send a message to the above user.
relayInstance.send('Hi there!', '<user-1>');- Post in a slack channel
- given a channel name
- use your bot to post a message to the above channel.
relayInstance.post('Hello! I am alive :)', '<channel-1>');- Send message to slack user
relayInstance.broadcast('Sorry for spamming!', ['<user-1>', '<user-2>']);