How the cloud got me a free Swedish massage
Ok, technically, it’s my employer Active Solution that provides free Swedish Massage for me as an employee (according to The Daily Show is is part of our Stockholm Syndrome). The issue though, is that the weakly massage has limited amount of available seats. You can sign up in advance, but I never seem to prioritize that and when it’s Wednesday morning, all slots are usually taken.
Working a couple of years at this place I’ve realized a few things though: There will always be one or two persons that in the last minute needs to hand their slot over to someone else. The way we handle this is as simple as sending out an email to everyone stating:
“Available massage time at 11 o’clock!”
You reply and you get the slot. But I’m too late to the game, every - single - time.
I thought, how can I beat the game and always be first to grab those available slots? And this is where the cloud comes in :)
Introducing Massage Email Bot
To be able to grab those available slot I wanted to implement some kind of automatic reply on those specific emails. You can do conditional auto replies in Outlook, but those rules will only evaluate on the client which requires you to have your computer and Outlook running at all time. Didn’t work for this scenario.
As the developer I am I was thinking of writing some Azure Function, grabbing emails through the Microsoft Graph Outlook API:s and doing some magic there, but it all seemed to much orchestration for such simple task. I quickly evaluated Logic Apps (that could have solved it) but eventually turned to Microsoft Flow (which i, from what I can understand, is a more end user friendly version of the same infrastructure as Logic Apps). Microsoft Flow is at its core quite similar to IFTTT which I’m using for automating other things.
In Microsoft Flow I used the Office 365 Outlook Connector, listened for incoming emails, filter them out by the subject line and then make a customized auto reply. My first version looked like this:
But after trying it out I realized a few flaws, most importantly, it would introduce an infinite loop and completely flood my inbox. Because the auto reply also included “Massage time” in the subject line, the same flow would trigger on the auto reply and so it would go on forever. I also wanted to avoid any auto reply outside of the organisation, so I wanted to filter on our email domain.
Using the conditional block I made sure to only reply on the initial email and ended up with this flow.
I was ready to try it out, but realized it was to slow! It took up to several minutes for it to make the reply. Turned out that the free plan only runs the flow roughly every 15 minutes and I needed to step up to a Premium plan to get 1 minute checks. I would have loved if the Outlook connector could take advantage of the notification API and react immediately without having to scan the inbox in intervals. But you could get a 90 day free trial for Premium, so I did and now it was quick enough.
So, finally Wednesday and massage time. As usual I had no slot and was quite occupied so didn’t have time to check my inbox and then it happened. My bot had grabbed an available slot for me and my time paid off ;)
Ideas of improvement
Calendar integration: I did try to parse the time in the email and create a slot in my calendar (and also verified I was actually available), but people tend to write the time in so many ways it wasn’t easily solvable. I did try to run it through Cognitive Services Text Analysis but it only catches the most obvious cases which I as easily could grab with a simple Regexp, might be that the Swedish model is not as accurate as the English one.
Multi language: At Active Solution we speak multiple languages, so it would be nice if it supported multiple languages. Maybe overkill, but there is a translator connector that could provide a generic solution to that “problem”.
I’ve actually turned of this flow now, to give my colleagues a fair chance of grabbing those slots, but it was a fun way of exploring a new technique. I think Microsoft Flow can really automate boring and simple tasks while you can spend time on more interesting things. For some scenarios you’ll have to step up your pricing plan, but the free tier will handle most of your personal scenarios.