BotKit Slack bot. Show free meeting rooms, book rooms (Google Calendar API) etc.
MIT License
Slack bot for office use.
botToken
$ forever start src/app.js
Bot sends a reply to the channel or to private chat where the command was sent from.
Sends exceptions and errors to the user defined in the configuration file (slackAdminUserId
).
Anonyous messages are sent to the home channel defined in the configuration file (homeChannelId
)
Returns Office has people or Office is empty message, depending if there is currently people at the office.
GET /api/haspeople/{id}
from Sensordata API for all sensors in the configuration file. If any of the requests return true, then there is someone at the office.
Returns lates sensors data for all sensors defined in the configuration file.
GET /api/data/{id}
from Sensordata API.
{"name":"5krs","temperature":21.25,"humidity":23,"noise":47,"light":124,"time":"11:47 19.01."}
{"name":"6krs","temperature":22.64,"humidity":23,"noise":45,"light":571,"time":"11:47 19.01."}
Free meeting rooms shows a list of rooms that are free and duration how long they are available. Current events shows a list of next 2 events for each calendar defined in the configuration file. It will hide info from private events. Book a room makes a reservation for the next X minutes if that time is available. Bookings made with the SlackBot can also be cancelled by the same user.
Uses Google Calendar API. Meeting room calendars are defined in the configuration file. Booker info from Slack User Info.
Requirements:
npm run create_token
to store authentication token to json-file. This file is not in version controlGet list of restaurants/bars from Google Places API that are max 500m/800m from the office and return random item from that list. Office location is defined in the configuration file.
Requirements:
Automatically translate the conversation to selected language.
Requirements:
translator: {
keyPath: '/home/user123/office-slack-bot/translate_secret.json',
prefix: ':flag-england:',
language: 'en',
maxCharacters: 1000,
channels: {
aaaaa: {
enabled: true
},
xxxxx: {
enabled: true
}
}
}
Bot adds a channel to the channel list when translate
command is issued from the channel.
Nodemailer is used to sen email. Add mailConfig
to the configuration file. Will send email to defined email address and cc to sender. Add information to the configuration's emailMessage
.
Bot's source code has an implementation to send an email to the maintenane company.
Requirements:
Uses Cheerio to scrape text from html. Selector is executed with eval it's result is shown to user. Use helpers\cheerioTester.js
to verify selector.
reddit : {
url: 'https://www.reddit.com/r/all',
description: 'Top link from Reddit all',
selector: `const link = $('#siteTable').find('a').first().attr('href'); link.startsWith('http') ? link : 'https://www.reddit.com' + link;`
}
Send GET request to the defined url. External service will send a command to IoT device.
Console app wraps the same functionality as BotKit, so it works with same commands and returns same responsens.
$ npm run console
configuration.js containts tokens, passwords, locations, sensors etc.
If allowGuestsToUse
is set to false, then restricted users will get an error messages when trying to send messages to the bot.
configuration.js:
'use strict';
module.exports = {
botToken: 'xxxx',
homeChannelId: 'xxxx',
slackAdminUserId: 'xxxx',
allowGuestsToUse: false,
apiUserName: 'xxxx',
apiPassword: 'xxxx',
apiUrl: 'xxxx',
locationApiKey: 'xxxx',
office: { lat: 60.17, lon: 24.94 },
sensors: [
{ id: 'xxx', name: 'xx' },
{ id: 'xxx', name: 'xx' }
],
meetingRooms: [
{ name: 'xxxx', id: 'xxxx' }
],
translator: {
keyPath: '/home/my-user/office-slack-bot/translate_secret.json',
prefix: ':flag-england:',
language: 'en',
maxCharacters: 1000,
channels: {
AAAA: {
enabled: true
},
BBBB: {
enabled: true
}
}
},
webScraperOptions: {
reddit: {
url: 'https://www.reddit.com/r/all',
description: 'Top link from Reddit all',
selector: `const link = $('#siteTable').find('a').first().attr('href'); link.startsWith('http') ? link : 'https://www.reddit.com' + link;`
},
vincit_kurssi: {
url: 'https://www.kauppalehti.fi/5/i/porssi/porssikurssit/osake/index.jsp?klid=2073',
description: 'Vincit stock value',
selector: `$('.stock_number').text() + "€";`
},
hs_top: {
url: 'https://www.hs.fi/',
description: 'Most read link from Helsingin Sanomat',
selector: `'https://www.hs.fi/' + $('.is-most-read-articles-list').find('a').first().attr('href');`
}
},
emailConfig: {
service: 'gmail',
host: 'smtp.gmail.com',
auth: {
user: '[email protected]',
pass: 'xxxxx'
}
},
emailMessage: {
receiver: '[email protected]',
subject: 'Maintenance request',
template: `
Hi,
{content}
Br,
{senderName}
`
},
doorBell: {
url: 'https://webhook.site/0e1a0101-7435-48e4-8bf7-fcea6e812a5e',
message: 'Opening the door'
}
};
Test folder contains tests. Some tests require correct Google API keys in the configuration file.
$ npm test
Run test matchin the pattern:
$ npm run test:g [pattern]
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Licensed under the MIT License.