An example Alexa Skill to read upcoming events from Apple Calendar, written in Python.
- An AWS account
- A pre-existing Apple ID with events in the calendar.
- Open
lambda_function.py
, fill in your Apple ID username and password at the top and save. If you use 2 factor authentication then you will need to turn it off, as the Apple web service doesn't seem to work with app specific passwords. - Zip up the four folders (dateutil, pytz, requests & tzlocal) and the three .py files (apple_calendar_api.py, isoweek.py and lambda_function.py) into a single zip file.
- Create an AWS Lambda function
using your zip file as the code
- You can follow the official Amazon instructions to give you a hand
- You should uncomment the block in the
lambda_handler
function and insert yourapplicationId
to only allow requests coming from yourapplicationId
- You can use
test_event.json
as your test template. - Consider extending the timeout beyond the default of 3 seconds (I raised mine to 10, which is likely excessive, but may eliminate some sporadic errors)
- Create a new Alexa
Skill using
intent_schema.json
andsample_utterances.txt
. You can choose your own word for invocation (I usecalendar
). - Don't publish the skill (because it includes your Apple ID username and password), leave it in development mode
- Test that it's working from the web interface during the creation of the skill
- Test that it's working with your Echo
So far the following commands work:
Alexa ask calendar today
- lists events happening todayAlexa ask calendar tomorrow
- lists events happening tomorrowAlexa ask calendar Monday
(or any other day) - lists events happening on the next day givenAlexa ask calendar this week
- lists events between today and next SundayAlexa ask calendar next week
- lists a full week of events starting from next Monday
Note that if you used something other than calendar
for the invocation word, you must substitute that in the above examples.
- Currently you can't add new events as the Apple web service doesn't allow this.
- Doesn't work if you use 2 Factor Authentication to protect your Apple account.
- As a consequence of the point above, I receive an email from Apple every single time it runs telling me I have logged into a new computer so I've set my email host to delete all these.
- https://github.com/n8henrie/alexa-wolfram-alpha -- A simple skill to query Wolfram Alpha, from which I have cribbed the instructions in this README and some of the boilerplate code.
- https://github.com/picklepete/pyicloud -- A Python library for connecting to iCloud, which I stripped down to the basics for our purposes here.