Booking a meeting room is a small task that people do many times a week, usually in the middle of a conversation about the meeting itself. This page follows one booking from a slash command to a calendar event, and the three constraints that shaped it: Slack must be answered in three seconds, two bookings must not overlap, and a calendar that people trust has to agree with the database.

The commands

Two Slack apps share the code: one for meeting rooms, one for the broadcast studio. Each has three commands.

CommandWhat it does
BookOpens a modal with the booking form
My bookingsSends the user their next ten bookings as a direct message, each with an edit and delete menu
Day scheduleSends a timeline of one day, from 07:00 to 22:00, with the free gaps shown. Edit and delete menus appear only on the user’s own bookings

The studio bot has the same three for live-broadcast slots, with crew roles in place of attendees.

Verifying that Slack sent it

A slash-command endpoint is a public URL. Anyone who finds it can post to it, so the first thing each route does is prove the request came from Slack.

Slack signs every request with a secret the app shares with it. The route reads the raw body as text before any parsing, builds the string Slack signed from a version tag, the request’s timestamp and that body, computes an HMAC-SHA256 with the signing secret, and compares the result with the signature header in constant time.

Two details matter.

  • The raw body. The signature covers the exact bytes Slack sent. Parsing the form first and re-serialising it would produce a different string and a signature that never matches.
  • The timestamp. A request whose timestamp is more than five minutes old is refused. Without that, a captured request could be replayed later with its valid signature.

There are two signing secrets, one per bot. The route tries each, and the one that verifies also decides which bot’s API client is used to answer.

From command to booking

A sequence with four participants: Slack, meaning the user and the platform; the Slack routes for commands and interactions; MongoDB holding reservations; and Google Calendar, the shared room calendar. Step one, Slack sends a slash command signed with HMAC-SHA256. Step two, the signature and the five-minute window pass and the route opens the modal. The user fills in the modal and submits. Step three, Slack sends a view_submission. Step four, the route runs one query for the same room, these dates and an overlapping time. Step five, it inserts one document per date. Step six, it answers 200, or returns the error to be shown inside the modal. After the response: step seven, the route creates the calendar event and stores its id on the booking, and step eight, sends a confirmation as a direct message.
Figure 1. One booking. The modal opens straight from the command. The submission is validated, checked for conflicts, written and answered inside the three-second window. The calendar event and the confirmation message follow after the response.

The modal. The form asks for a title, a room, a date, start and end times in ten-minute steps, a recurrence, attendees picked from the Slack workspace, external guests typed as names, and when to remind. Two of the fields change the form: choosing “another place” reveals a text field, and choosing a recurrence reveals its end condition. Slack sends an action when either changes, and the route rebuilds the modal from its current state and updates it in place.

The submission. When the user submits, the route:

  1. Validates the times. An end that is not after the start is returned as an error that Slack shows inside the modal, so the user corrects it without losing the form.
  2. Finds the person. The Slack user’s profile email is matched to a oneFlow account. Each selected attendee is resolved the same way, and attendees with no account are still kept with their name and email.
  3. Expands the recurrence into dates.
  4. Checks for conflicts.
  5. Writes the booking and answers.

After the write. The Google Calendar event and the confirmation message are started once the booking is saved and are not awaited, so the response to Slack does not wait for them. A calendar API call can take longer than Slack will wait. If it is slow, the user still sees a saved booking, and the event appears a moment later.

Recurrence and conflicts

A table of recurrence rules. Daily generates every day from the start date. Weekly generates every 7 days. Every two weeks generates every 14 days. Weekdays generates Monday to Friday. Every N days is typed as free text. Chosen weekdays, for example Monday, Wednesday and Friday. Notes: a series ends on a date or after a count of 1 to 52; no series has more than 52 occurrences; each occurrence is its own booking, tied to the others by a group id, and its own calendar event. Below, the conflict rule: a new booking clashes with an existing one when the room and the date match, the existing start is before the new end, and the existing end is after the new start. A series is checked with one query over every generated date, and the modal lists the first three clashes.
Figure 2. Recurrence rules and the conflict rule. A series is expanded to its dates, then checked with one query.

A recurring booking is turned into a list of dates before anything else happens. The generator supports six rules and stops at 52 occurrences whatever the end condition says, so a weekly meeting with no end date becomes one year of bookings and not an unbounded series.

Each date becomes its own document. The documents of one series share a group id and a copy of the rule. This is the data shape.

// one reservation (shape)
{
  title,
  location,                      // one of the fixed rooms, or free text
  date,                          // "YYYY-MM-DD", Korean time
  startTime, endTime,            // "HH:mm"
  createdBy:    { userId, fullName, email },
  participants: [{ userId, fullName, email }],   // userId empty for people without an account
  reminders:     [10, 30],       // minutes before
  remindersSent: [],             // keys of reminders already delivered
  googleEventId,                 // set after the calendar event is created
  recurrenceGroupId,             // shared by the occurrences of one series
  recurrenceRule: { type, intervalDays, customDays, endDate, occurrences }
}

The conflict rule is the standard interval overlap: two bookings in the same room on the same date clash when each starts before the other ends. For a series, the check is one query: the same room, any of the generated dates, and the overlap condition. If anything comes back, nothing is written, and the modal lists the first three clashes with a count of the rest. A series is accepted whole or not at all.

book(room, dates[], start, end):
    clashes = reservations.find(
        location = room
        and date in dates
        and startTime < end
        and endTime   > start )
    if clashes: return errors to the modal (first three, "+N more")
    insert one document per date, with a shared group id
    respond 200
    then, without waiting:
        for each document: create the calendar event, store its id
        send the confirmation message

Google Calendar

The tool writes to two shared calendars, one for rooms and one for the studio, through a service account.

BookingCalendar event
TitleSummary
RoomLocation
Date, start and endStart and end as local times with the Asia/Seoul time zone
Organiser’s nameDescription
Attendees who have an emailAttendees, with display names

The event id that Google returns is stored on the booking. An edit replaces the event by that id, and a delete removes it. Because every occurrence of a series is its own booking, every occurrence is also its own event.

Reminders

A booking carries the minutes-before values the user chose. A route designed to be called once a minute looks at today’s bookings, and for each reminder whose time has arrived it sends a direct message to every attendee it can find in Slack.

Sending once is handled with a key. Each reminder has a key made of its minutes, the booking’s date and its start time. Before sending, the route checks whether the key is in the booking’s list of sent reminders, and after sending it adds it. The send window is two minutes wide, so a run that is a little late still fires, and the key keeps the next run from firing again.

Editing a booking from Slack clears the list. Because the key includes the start time, a meeting moved to a new time gets fresh reminders, and the old ones cannot fire.

Failure modes

What happensWhat the system does
A request arrives with a wrong signatureRefused before any work is done
A valid request is replayed after five minutesRefused by the timestamp check
The end time is not after the startAn error shown inside the modal
The Slack user has no matching accountAn error shown inside the modal
One date of a series clashesNothing is written. The modal lists the clashes
The calendar call failsThe booking stays. The failure is logged and the booking has no event id
The reminder route runs twice in the same minute windowThe key in the sent list stops the second message
Someone other than the creator tries to editRefused, with one super-admin exception in Slack

Limits

  • The conflict check is a query. It reads and then writes, and no database constraint backs it. A unique key on room, date and slot would make the rule structural.
  • The calendar is a mirror with no repair. A failed calendar call is logged and not retried, so a booking can exist without an event. There is no job that reconciles the two.
  • A series is a set of independent bookings. Editing one occurrence changes that occurrence. There is no “this and following” edit.
  • Each occurrence is a separate calendar event. Google’s own recurrence rules are not used, so a year-long weekly series is 52 API calls in the background.
  • This module has no automated tests. The tests in the repository cover permissions, the broadcast workflow and a recipient parser.