My mother is a diabetic, and needs to take several medicines - to treat her diabetes, control her blood pressure, and for a few related cardiac problems. This means she has a varying set of pills to take every day, at different times. Missing even a few doses can be disastrous to her health.
Knowing that a large number of people around the world face a similar situation, and seeing that there was no such skill dedicated to helping patients on the Alexa Skill Store, I decided to go ahead and make my own. This project is the result of several weeks of research, and a desire to use Alexa to make the world a better place.
What it does
PillBox lets you tell it what medicines you have to take and when. It then proceeds to send you reminders on your smartphone, and record whether you took the medication or not. This helps ensure you take your medication, and at the right time, which is very important for the treatment of several serious medical conditions - from Alzheimer's to Parkinson's, and a plethora of heart-related diseases.
It also keeps track of your inventory for medicines, and reminds you when it's time to buy more. It can order over-the-counter medication for you directly from Amazon too!
To summarise, the features it offers are:
- Medication reminders on your smartphone
- Tracking of whether you took your medicine on time
- Reports on how well you've been taking your meds - how many times you correctly took each medicine the previous week or month, and advise on how you can improve if necessary
- Notification when medicine quantity falls less than what is required for the next two weeks
- Suggests you order medicines that are almost over immediately on Amazon, via Alexa, so it can be delivered to your doorstep in time
How I built it
The first thing I did was go through the [Alexa Skills Kit Voice Design Best Practices] (https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-voice-design-best-practices. I knew to provide a seamless experience to my users, I would have to incorporate these guidelines in every stage of development.
The next step was to build the Alexa sample skill. This helped me get comfortable with AWS Lambda and the Alexa Skills Kit, and the surrounding Amazon ecosystem. The synergy between these various offerings is what helps get an Alexa skill off the ground quickly, and with minimal (currently zero) maintenance costs.
Then, I went ahead and built my own interaction model, following the same steps I had in the tutorial. This is where I paid most attention to the Voice Design Best Practices. The entire user flow had to be imagined in a way that was both simple and intuitive to the user, but did not drag on for too long by asking trivial questions. The easiest way to go about this was to find a friend, and ask him or her to talk to me as if I were Alexa. I responded in the same manner I would expect my skill on Alexa to. After several such simulated conversation with various people of different age groups and backgrounds, I noted down the way they structured their sentences, and incorporated that into the workflow and sample utterances for my intents in the intent schema.
Now, it was time to work on my Lambda function. In my case, it mainly had to record the following information:
- The name of the medication
- The times and days on which the medicine had to be taken
- The current quantity of medicine available
- The quantity of it consumed every week (for reminding the user to purchase more, so they can place orders on Amazon)
I picked python since that was the scripting language I was most comfortable with - providing both flexibility for quick prototyping, and the confidence of familiarity. I referred to this excellent post on building an Alexa Skill with Python to help me along the way, and make sure I was doing things right. Juggling an internship side-by-side, I was able to complete it over a weekend (and boy, was that a fun weekend!).
As recommended, I used Amazon DynamoDB to persist my users' information (medication times, quantity, history of correctly taking medication). Since there was very little splicing and slicing of data to be done, it fit right into the pros of using a NoSQL database.
Next, since I intended to send the reminders via the user's smartphone, I would have to set up an OAuth 2.0 service which returned a token to the Alexa Skill Set, on a separate server. Different from the lambda service, the server supported account creation and authentication necessary for account linking. This helps link the account I use to push reminders on the smartphone, to the Amazon account the user is logged into on Alexa. The linking process involves the user first downloading and creating an account on the PillBox smartphone application (currently Android-only). He then logs into the smartphone app with that account. When he installs the Alexa Pill Box Skill, he will be prompted to login to his account on my server. A successful login will generate an OAuth 2.0 token, which is used to authenticate and identify which user to send the reminders too.
Once I had the OAuth 2.0 up and working, I was able to link the Alexa skill to the smartphone app, and set about writing the rest of the Android application that would receive push notifications from my server. The push notifications are what would be used to trigger the alarm-based reminder on the user's phone. This phase involved writing the complete Android application integrated with Google Cloud Messaging. Once done, a reminder pushed to the phone would trigger a flashing red screen urging the user to take their medication, while the phone vibrates and rings.
With all the components of the skill now ready, it was time to test the entire workflow end-to-end! After a bit of inevitable tinkering and tweaking, everything was working perfectly, and it was time to submit my skill for certification. Woohoo!
Challenges I ran into
I was unfamiliar with both DynamoDB and AWS Lambda. However the rich collection of tutorials provided online by Amazon help me tide over that.
I had to set up my own OAuth 2.0 service to allow Alexa to interface with my smartphone application, which was something I had never done before. Getting it to work felt like an accomplishment of its own.
This was also the first Alexa Skill I was building, and there is always fear of the unknown. However, it was a lot easier than expected, and with every small breakthrough I made, my eagerness to build only grew.
Accomplishments that I'm proud of
It was a great feeling for me to first hear Alexa tell me something I had programmed her to say. Admittedly, it was pretty early in the development cycle, but it gave me the confidence to push on.
I also surprised myself by being able to grok OAuth, Amazon DynamoDB, and AWS Lambda, besides the framework provided by the Alexa Skills Kit, to a build a full-fledged skill in such a short span of time. The feeling of accomplishment you get when you put on the finishing touches to your completed skill, and submit it for certification, is in a league of its own.
The most satisfying moment of it all, however, was when my mum started using it, and after a few days told me herself how much easier it now was for her to deal with her medication. Tech is great to build, but nothing compares to the warm fuzzy feeling you get it when it actually changes people's lives for the better.
What I learned
This challenge helped me learn a lot of things - from using AWS Lambda and DynamoDB to OAuth and the Alexa Skill Kit. I now feel confident enough to go ahead and build several more Alexa skills, which given the impact I feel this skill has had, is something I definitely look forward to doing. It also taught me that Voice Interfaces have the potential to change and simplify our lives in ways that were previously unimaginable - all we need to do as developers is reach out, and give it form.
What's next for PillBox
Alexa Push Alerts Unfortunately, Alexa does not support push alerts yet, but that is expected to change in the coming months. Once this feature is available, PillBox will allow users to opt-in and receive reminders not just on their smartphones, but via Alexa too.
Cross-Platform Support Given the positive feedback I've received for the skill, I intend to go ahead and make it cross-platform to support iOS and Windows phones too.