Giter Site home page Giter Site logo

tdmalone / where-is-tim Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 73 KB

An experimental Alexa skill that advises my wife when I'm due home from work.

License: Other

Python 91.58% Makefile 8.42%
alexa-skill python geolocation lambda aws-lambda python3 aws-lambda-python alexa-custom-skill alexa-skills-kit

where-is-tim's Introduction

Where is Tim?

Build Status Coverage Status

An experimental Alexa skill that advises my wife when I'm due home from work. All she has to do is say 'Alexa, ask Tim if he's left work yet' or 'Alexa, ask Tim how far away from home he is'.

It runs as a Lambda function on the Python 3.7 runtime, and is powered by the Alexa Skills Kit (ASK) SDK for Python (full documentation here).

Why?

Just as an excuse to learn both Alexa skills and Python, really! And also because I had some of the infrastructure already set up from previous projects.

Can I use this?

Sure! You likely won't be able to use it as is as it's very custom made, but feel free to take whatever parts you like and make something for yourself.

You should know that not all of the required infrastructure is contained within this repo:

  • The Lambda function was originally set up from the Alexa Skills Kit (ASK) Sample Fact Skill [Python 3.6] (GitHub repo) via the AWS Serverless Application Repository (SAM), with many changes made since then.

    • A number of settings have been manually changed on the Lambda function (I'll add Terraform configuration for this at some stage, since I prefer it over CloudFormation and even with drift detection, CloudFormation can't tell that I've messed with it).
    • You'll need some environment variables configured, such as:
      • DYNAMODB_TABLE: The name of the DynamoDB table to read from
      • PYTHONPATH: Currently should be set to /var/task/vendor:/var/runtime:/opt/python
      • TIMEZONE: The name of the timezone (eg. Australia/Melbourne) that the location event times are stored in
      • Additional optional environment variables include EXCEPTION_MESSAGE, FALLBACK_MESSAGE, LOGGING_LEVEL, METRO_TRAINS_LINE_ID, PRONOUN, VALID_EVENT_MAX_ACCURACY_IN_METRES, and VALID_EVENT_MAX_AGE_IN_SECONDS.
    • The SAM deployment template adds a Lambda Layer holding the ASK SDK, hence ask-sdk is not included in the function's requirements.txt, but would need to be added if you use/deploy it elsewhere. Otherwise, the layer's ARN is arn:aws:lambda:us-east-1:173334852312:layer:ask-sdk-for-python-36:1 if you want to add it to your Lambda function manually.
  • The database structure assumes a DynamoDB backend, populated by geolocation events coming from the Proximity Events iPhone app.

    • These are parsed by a this webhook parser and forwarded to an SNS topic.
    • They're then inserted into a DynamoDB table by a custom Lambda function, which does a bunch of other custom automation things based on my location (this function is currently private, but I'll make it public when I've fully separated personal configuration from the code).
    • From there, for performance reasons they're then replicated to a DynamoDB table in the same region that this Alexa skill runs from, and the data is enriched at the same time (by this function)

You should also know that because the original code was licensed under the Amazon Software License, a portion of it is still encumbered by it (see LICENSE for more details, specifically clause 3.2). That means this project is not completely open source, as clause 3.3 would appear to fall foul of clause 10 of the Open Source definition (IANAL though - I'm just interested in licenses). This applies to all projects derived from ASL-licensed examples.

Other useful things to know:

  • There's a Makefile with some common tasks, such as installing dependencies in a virtualenv (make install) and deploying updates. For easy deployment, you might like to install the ASK CLI, which make deploy will try to do for you.
  • The ASK Sample Fact Skill for Python also provides some good getting started instructions.
  • Train line disruption data works only in Melbourne, Australia. You'll need to rewrite it if you want to support a train service in another city/country.

Tests

Run make test. You'll need pytest installed.

Questions?

If you want to implement something similar and have questions - or if you've had a look at my code and think I could do something better (this is my first Python script, so be gentle), feel free to log an issue!

License

MIT and ASL.

where-is-tim's People

Contributors

tdmalone avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.