What happens when you cross a group of PHP developers with the ultimate festive snack? A sophisticated cross-platform, natural language, artificially intelligent chatbot, of course! Discover how we created the ultimate mince pie rating system using a range of online tools.
‘Twas a night (long) before Christmas…
After work one November evening, we began debating which criteria are most important for a perfect mince pie – and how these should be weighted.
As the self-proclaimed ‘pie masters’, we started putting numbers into a test application and setting test scenarios. For example:
- Great taste, bad looks, high price
- Bad taste, good looks, modest price
- Awful taste, equally bad looks, high price
- Amazing taste, great looks, low price (the ultimate pie!)
We tweaked as we went along to align more closely with how we would rank the pies ourselves.
Before long, we had a finely tuned Mince Pie Algorithm (MPA):
((Taste x 0.8) + (Looks x 0.2)) – Price per pie / π2
Gathering the data
With the pie algorithm in place, we needed data. It was no time at all before pies started arriving on our desks – during the initial period, we were averaging as many as three pies per day.
To start gathering the necessary data, we built a form that would capture everyone’s feedback and subject it to the MPA:
Using this form, members of the team could quickly and easily rate their pies. These ratings were then captured in an airtable database.
Additionally, every time a pie was rated, a post also appeared on our @MincePieRatings Twitter account.
Making sense of the data
As with a lot of development work here at Redweb, there was a need for this to be a decoupled application, so different platforms could process the data. We created an API to make mincemeat (…sorry) of this requirement:
We then set about creating a variety of applications to use the data, including a website, Slackbot and chatbot.
Creating the applications
Website
The first application was a PHP website. The data from the mince pie ratings is processed and output on the page in Pie Ranking Order (PRO), based on the MPA.
We also pulled in pictures of the pies from the mince pie rating Instagram account, for a little added visual context:
Slack
As enthusiastic users of Slack, creating a Slackbot to get updates on the ratings was essential. Users can pass it commands such as ‘table’ or ‘tastingnotes’ and the bot responds with real-time mince pie rating data:
Dialogflow
Obviously, if you have a big decision to make about which mince pies you should be buying for Christmas, the above applications may not be enough! What you really need is something with some intelligence, something you can speak to as if it’s your friend.
That’s where natural language processing comes in. To accomplish this, our Development Director Dave used Dialogflow to create our new best friend: our very own mince pie chatbot.
At the moment, this chatbot can be spoken to through Google Assistant as well as via the mince pie rating website. The same code could also be used to connect to Facebook or Twitter messaging apps.
What did we learn?
From creating the algorithm to outputting the data to various applications, this process has enabled us to experiment with a range of tools, including:
- Slim PHP framework: a simple framework that handles routing
- AirTable: an online database with an excellent API
- Dialogflow: a natural language processing chatbot framework
- IFTTT: an online webhook system that allows us to automatically tweet every time someone reviewed a pie
- DigitalOcean to quickly spin up droplets, using ServerPilot to securely configure them
So although the project started out as a bit of fun, we managed to learn an awful lot from it. Oh, and if you were wondering – Lidl’s Favorina range of mince pies should be the pie that takes pride of place at your Christmas table this year.
Merry Christmas!