- Introduction
- Flows
- Configuration
- Deployment
- Settings Summary
- Setup Slack App β
- Storage Adapter β
- Development
- Contributing
- Other Projects We Are Working On
- License
This Slack slash command is inspired by car2go's previous platform luncher2go
which matches coworkers of one location on demand to get to know new colleagues while having lunch, a coffee chat or similar.
The basic idea behind erna is to enter a specific command, choose your current location and get your match at the defined time, day and week. In case of an odd number of applicants, there's one larger group. You get even notified in the unfortunate case of no match. But don't be sad βΒ keep trying and tell your coworkers about the app π.
While starting, erna generates up to 250 scheduled events per timezone which are enough for roughly 1-24 years. Additionally it is possible to schedule custom location-specific events via the subcommand schedule
and to skip regularly scheduled events via skip
.
The app is optimized for zeit now v1, so that it is possible to deploy the app with a few commands:
git clone https://github.com/sharenowTech/erna.git
cd erna
now
Feel free to contribute new storage providers or other features.
Since erna is a cronjob-like service ensure that the app is scaled exactly once at a single datacenter.
- Run the command with the
schedule
subcommand:
/<command> schedule <YYYY-MM-DD> <HH:mm> [<title>]
- Get notified in case of an invalid format.
- Get asked for the related location.
- Get notified about the scheduled event in case of success.
- Get notified about an existing event at the same time in the same location.
- Run the command with the
skip
subcommand:/<command> skip <YYYY-MM-DD> <HH:mm>
- Get notified in case of an invalid format.
- Get feedback
- Get notified about the skip events at that date in case of success.
- Get notified about an existing skip at the same date.
- Run the command with the
notify
subcommand:/<command> notify [<additional message>]
The configuration is based on environment variables.
Pass in a list of available locations including the related timezone.
Those locations are provided as interactive command, so people can choose their current location on a daily basis.
As already said, it is necessary to define the related timezones (map).
Each timezone is enclosed between #
and :
:
[#<Timezone>:<Location>[,<Location>*]]+
Example:
LOCATIONS=#Europe/Berlin:Berlin,Hamburg#America/New_York:NYC
If just one location is provided, erna skips the prompt for choosing the location as it is unnecessary.
The Slack Bot User OAuth Access Token is required.
How to get the token and set the required permissions is explained in the slack setup chapter.
Example:
TOKEN=xoxp-12345678-87654321-10011001-3x4mp13
The Slack app its signing secret is required.
Slack provides the app its signing secret on the Base Information page of your app.
Example:
SECRET=12345abcdef67890
Pass in a custom database url containing information like clusters, replica set and further options.
Default is no external database, so it uses an in-memory state instead.
Further information about the storage is listed in the storage adapter chapters.
Example:
DB=mongodb://one.myinstance.com:27017,two.myinstance.com:27017?ssl=true&replicaSet=myCluster
Pass in database credentials in a username:password
format.
Example:
DB_CREDENTIALS=username:password
Pass in the name of the database.
Example:
DB_NAME=erna_local
Pass in the username of the Slack bot user.
Example:
BOT_NAME=chieflunchofficer
Pass in an integer to use a custom port.
This variable is optional and its default is 3000
.
Example:
PORT=8080
Pass in an integer as desired match size.
Actual size may differ because of an odd number of members per location.
So the possible group size is 2 β€ [ACTUAL_MATCH_SIZE] β€ [MATCH_SIZE] + 1
Example:
MATCH_SIZE=4
Pass in a simple 24hr format to define the local time of announcing the matches.
Do not pass am
/pm
12hr formats. This option affects both the Slack messages and the scheduled matches.
Example:
MATCH_TIME=15:00
Pass in a single day matching the /^(MON|TUE|WED|THU|FRI|SAT|SUN)$/
pattern to define the day or range of days for announcing the matches.
This option affects both the Slack messages and the scheduled matches.
Example:
MATCH_DAY=TUE
Pass in a comma-separated list of week numbers per month matching the pattern /^[0-5](,[0-5])?$/
.
It filters the generated events by week numbers. So passing 1,3
excludes all events scheduled in the second, fourth and fifth week of a month. Passing only 0
means that no regular events are scheduled.
Example:
MATCH_INTERVAL=1,3
To simplify the deployment of erna there are a couple of ways to pass the configurations mentioned above.
Since this service is optimized for zeit now v1 the following lines focus on this service. But it is quite easy and straightforward to adapt the principle to other services.
The easiest way to deploy erna is to clone the repository, enter the created directory, create a .env
file and deploy the service. There is an integrated solution which fetches an existing .env
file, so no further actions are needed. Moreover, it is possible to pass a specific file like .env.prod
using the -E
flag. Feel free to replace now
with your preferred service.
# .env.prod or .env
LOCATIONS=#Europe/Berlin:Berlin,Hamburg#America/New_York:NYC
TOKEN=xoxp-12345678-87654321-10011001-3x4mp13
SECRET=12345abcdef67890
DB=mongodb://username:[email protected]:27017,two.myinstance.com:27017?ssl=true&replicaSet=myCluster
git clone https://github.com/sharenowTech/erna.git
cd erna
now
or
git clone https://github.com/sharenowTech/erna.git
cd erna
now -E .env.erna.prod
GET /
β Health CheckGET /schedule
β Overview over future events (regular & custom ones)POST /commands
β Slash CommandPOST /actions
β Interactive Components
chat:write:bot
mpim:write
im:write
commands
bot
- named
erna
To simplify the local development and testing, read the slack tutorial about using tunneling.
Basically it's enough to install ngrok, run npm start
in the repository and tunnel the port ngrok http 3000
. Use the output temporary URL in the Slack app settings.
The validator (./lib/env/validator.js
) is responsible for handling and validating environment variables. The schema listed in ./lib/env/schema.js
defines which variables are required, what are their defaults, which regex pattern is required and how to transform the passed values.
Further details can be found in the schema definition β.
Fork this repository and push in your ideas.
Would be awesome if you add corresponding tests.
For further information read the contributing guideline.
π Β Tech Blog
π¦ Β @car2godevs
π Β Our Tech Stack
πΌ Β Job Board
The MIT License
Copyright (c) 2018 car2go Group GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.