bot-relay

1.0.1-beta.1 • Public • Published

relay

Bot user that can send messages to different users

npm version Dependency Status

Build Status Coverage Status Code Climate Join the chat at https://gitter.im/nshimiye/relay

Installation

npm install bot-relay

usage

  • 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>']);

Readme

Keywords

Package Sidebar

Install

npm i bot-relay

Weekly Downloads

1

Version

1.0.1-beta.1

License

MIT

Last publish

Collaborators

  • nshimiye