Automating Team Lunches with Chef Friday

3 minute read

One of the favourite perks of working at Polymathian is catered lunches each Friday. Back when we started, these Friday lunches were as simple as walking the entire team across the road to the local Indian restaurant. As we grew, it became harder to find restaurants that cater for so many walk-ins, so we switched to delivery. This opened a new world of restaurant options however, it meant we needed a way to select a restaurant and collect the growing number of orders. This required a lot of manual work and coordination, so it soon became apparent that our ordering system needed to be automated.

It was decided a simple chat bot would be the best technology to use, since it matched our desired requirements well.

Requirement Response
No new install for employees Teams is already installed
‘Push’ style workflow, get votes on Thursday and orders on Friday Chat bots can proactively message people
Requires minimal / no training or onboarding Chat is intuitive and can use a wizard-style workflow to guide people through a process without specialist knowledge
Be fun, avoid turning team lunches into a corporate process Bots can take on more personality than a web form or spreadsheet

One concern was that chat bots can be a terrible experience for the end user. They often fall into the frustrating position of wanting to be spoken to like a human but being as dumb as a bag of rocks. However, in this case, the chat bot acts like an interactive form and doesn’t need to “understand” anyone. So, we decided to create a chat bot which could run the vote, collect food orders, and output summaries per restaurant for sending to Deliveroo.

Creating a Chat Bot

Since the chat bot (now named Chef Friday) was just walking individual users through the same process, the simplest approach was to model the process as a state machine. Each user’s current state can be persisted and some state transitions cause side effects (e.g. submitting a valid vote records your preferences).

Chef Friday state machine

The primary goal of the chat bot was to save time through automation. The solution needed to be quick and straightforward to implement. Microsoft’s Bot framework seemed overkill for what we wanted to create however, it also appeared to be the only SDK for talking to Microsoft Teams. We decided to use it but only for that interface, otherwise sticking to a stack we know well:

Chef Friday infrastructure

In the spirit of simplicity, the bot was implemented as one giant switch statement on the user’s current state.
Is that A+ software? No.
But it works great and we know the bot’s codebase won’t be growing over time.

switch (convoState) {
  case ConversationState.WOULD_YOU_LIKE_LUNCH:
    switch (recMessage) {
      case "yes":
        // Move onto asking them if they want to vote
        dbConversation.inForLunch = true;
        dbConversation.state = ConversationState.WOULD_YOU_LIKE_TO_VOTE;
        await dataMapper.update(dbConversation);
        await context.sendActivity("Would you like to vote?");
        break;
      case "no":
        // Set the user to be out and done for the week
        dbConversation.inForLunch = false;
        dbConversation.state = ConversationState.DONE;
        await dataMapper.update(dbConversation);
        await context.sendActivity("No worries!\n\nI'll see you next week.");
        break;
      default:
        await context.sendActivity("Sorry, I didn't understand");
    }
    break;
  // ...
}

Results

Chef Friday was released to the company nearly two years ago and has been a massive success.

It took less than a day to develop, has required less than a day of maintenance since, and hosting costs are negligible. He has saved hundreds of work hours, reduced the level of human error, and has seen the company double in size without any training thanks to the chat bot’s intuitive nature. By giving him a bit of pesonality he’s also become a beloved member of the team.

Chef Friday infrastructure