Bot user that can send and receive messages to and from different users
npm install bot-relay
- 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
relayInstance.send('Hi there!', '<user-1>');
- Post in a slack channel
relayInstance.post('Hello! I am alive :)', '<channel-1>');
- Send message to slack user
relayInstance.broadcast('Sorry for spamming!', ['<user-1>', '<user-2>']);