A Warm Welcome to Erna

Insights into our Slack bot for lunch dates

Erna is a Slack slash command is inspired by car2go’s previous platform Luncher which matches coworkers of one location on demand to get to know new colleagues while having lunch, a coffee chat or similar.

Exemplary Sign-Up

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 schedules events per timezone based on the passed configuration. Additionally it is possible to schedule custom location-specific events via the subcommand schedule. Just access the current schedule per timezone or location via /schedule — easy as pie 🍰.

Erna’s Origin

As car2go is growing steadily at various locations, in particular as a result of the forthcoming merger with DriveNow, we also intend to continue scaling our communication across departments. For this reason, the Luncher was launched last year as a new platform, which has been replaced by erna in December to make it even easier to participate.

Erna’s Anatomy

Important information in advance: the slack bot works on the basis of a cron job. This means that continuous operation without freezing the instance must currently be ensured.

Interaction Flows

We tried to make the interaction with the slack bot as simple and intuitive as possible, but to cover a high variety of features at the same time. The graphic below illustrates these interaction flows. For all messages, several versions have been stored so that the handling is more diverse and interesting.

interaction flows within erna

Request Verification

In order to verify all incoming requests and to ensure that the requests are from authorized sources, the request verification recommended by Slack and already integrated into the headers has been implemented.

Storage Adapters

Currently are two adapters available: an InMemory and MongoDB one. The InMemory storage is default and initialized when passing no DB environment variable. Since it is a in-memory state redeploying or even freezing/sleeping of the service might cause a loss of data. The Mongo storage adapts MongoDB and is initialized when passing a mongodb:// connection url to DB environment variable. There are free DBaaS solutions like MongoDB Atlas. Using other storages such as MongoDB enables persistence.

Creating a new custom adapter is straightforward. Just extend the adapter and add the custom adapter to the index. You need to implement an interface with the asynchronous methods listed in the docs. The basic error handling for this functions is implemented in composeWrapper.

Configuration

Tailored to your wishes
With the help of the environment variables, erna can be customized according to your wishes. Besides the usual variables like Slack tokens and database information, the variables that affect the lunch dates and how they are arranged are of particular interest.

Not only the desired group size and the necessary locations with their timezones can be defined, but also the detailed time-of-day: time, weekday, week number. The aim was to make the passing of environment variables as simple as possible. Not only the file format, but also the values themselves. Thus, .env files can be defined, which are either recognized and loaded directly by erna, or can be specified during deployment.

A typical file might look like this:

TOKEN=xoxb-123456-7890
SECRET=oursupersecretslacksecret
DB=mongodb://username:password@one.myinstance.com:27017
LOCATIONS=#America/Chicago:Austin#Europe/Berlin:Berlin,Munich
MATCH_TIME=10:00
MATCH_DAY=TUE
MATCH_SIZE=3
MATCH_INTERVAL=1,3

Management
We have developed our own module for erna, which validates and handles environment variables. The reason for this is, on the one hand, that the necessary environment variables are often needed in different representations inside the Slack bot. On the other hand, this should simplify extensibility and increase comprehensibility.

The schema to be passed defines which variables are required, their default values, RegEx patterns to be matched and how to transform the input.

DB: {
name: 'db',
default: undefined,
props: {
url (x) {
return x
},
    type (x) {
if (!x) {
return x
}
      const url = new URL(x.split(',')[0])
return url.protocol.slice(0, -1)
}
}
}

The above example shows the definition of the database variable, which enables access to the passed value via env.db.url and to the related protocol via env.db.type.

Erna’s Role at car2go

Well, how do we use erna at car2go? Lunch Dates take place regularly — every first Monday of the month — at all locations. These lunch dates are made up of groups of 2–3 people, depending on whether the number of participants is even or odd. In order to have enough time, but at the same time to keep it up to date, the lunch dates are announced at 11:30 local time.

In addition to the regular lunch dates, other events are scheduled by departments such as HR. A common example are our Welcome Days, where all newcomers are usually at one location and thus have the opportunity to get to know a colleague better while having lunch.


You want to try erna by yourself, contribute something technical/editorial or spread the word about erna? Have a look at our repository, there you will find all necessary information. We provide erna as an open source module — so there are no limits to your creativity and the use 🎉.

Cheers,
Felix