Saturday, November 12, 2016

A pill reminder skill


If I were to put in a time lapse photo on my journey with developing skills for the Echo, I think I would see myself poring through Amazon documentation, copying and pasting one of the skills and getting a T-shirt, writing the first set of lambda functions, making some feeble efforts at learning javascript/node and then deciding to stick with Python, figuring out how to update sets,lists and maps, in DynamoDB entities, session management, control flow for intents....and finally concluding that I'd become just about educated enough to be dangerous.

So, with a big TH to the folks at DaVincian Healthcare, who won the overall Pymnts/Alexa Challenge, I set out to build a pill reminder skill. (check out their awesome video here )

Considering that I couldn't possibly integrate with a pharmacy to just read out prescriptions and add them once prescribed by a doctor(which would have made life infinitely easier), I took the easy way out by just speaking out the names of medicines to add or remove them.

Straight off the bat, I realized a problem with this - my pronunciation of a medicine had to be identical through the life cycle of the existence of that medicine in my schedule. Variations would just add it on as a new medication, a request to remove it from my schedule would stump Alexa and have her go boing-boing at me etc. (Why am I now not surprised that, while Alexa lets me add things to my To-Do list, any removals would have to be through the app?)

Note to self:  is there a service out there that can validate text of a medicine name? If so, integrate with such service.

Secondly, a voice based interaction needs to be designed and built very differently from a screen-based interaction. eg once one start using the skill , how do they know what all they can do? Do we go, for adding a medicine, say 1, for deleting a medicine, say 2 and so on. To listen to options like those, one is better off calling Comcast - an Alexa skill needs to be a lot more friendly, engaging and intuitive. You should basically be able to have a conversation with Alexa.


But since this was an effort to be just dangerous and learn, I boldly ventured forward. I planned on developing these intents:

  • add a medicine to my schedule(which, in this case, was driven off the day of the week)
  • remove a medicine from my schedule(for a particular day of the week)
  • list all medications in my schedule
  • list medications from my schedule for a particular day of the week
  • remove all my medications from my schedule
No effort would be made to retain history of the users interactions. The last intent listed above would blow away all traces of the existence of the last known schedule for the user.

Of course, any time, you're adding or removing medicines, Alexa should prompt for a confirmation, which is where the built-in YesIntent and NoIntent intents come handy.

So, without further ado, lets get started.

  • Set up your environment (this has been discussed thread bare in all the awesome tutorials out there. Here's one in case you're still looking)
  • Attach Dynamo DB access Policy in IAM to the role you're using


  • Create a table in DynamoDB 











  • Create the lambda function. The steps are very well detailed in tutorial referenced earlier, replace the code in the handler function with code from pillButler.py
  • Setup the skill in developer portal. Use the intent schema from IntentSchema.json
  • Create the slot types
 








  • Add sample utterances from SampleUtterances.txt
  • Invoke your skill from Alexa by saying "Alexa, open pill butler"

I'd like to reiterate that this was an exercise purely for fun and learning - no effort has been made to develop a complete solution. There are many corner(and not so corner) cases that would not pass muster and I am sure that this certainly will NOT win a T-shirt from the Alexa folks at Amazon if I were to submit this for publication.There is no practical use of this skill in this shape and form, unless integrated with a pharmacy and hence, not publishing it.


Happy Echo-ing!