/onebusaway-alexa

An Java-based app to communicate with Amazon Alexa for devices such as the Amazon Echo

Primary LanguageJavaOtherNOASSERTION

OneBusAway skill for Alexa

Build Status Coverage Status Join the OneBusAway chat

Are you ready to ask your Amazon Echo, "Alexa, where's my bus?"

This project is an implementation of the OneBusAway open-source platform for real-time transit info for Amazon's Alexa Voice Service.

Install and Use

This project isn't released publicly yet. We plan to make the first release in early 2016.

Never miss the bus again!

Just say "Alexa, open OneBusAway" to get started. You'll set your city and favorite stop, using the stop number. Then, just say "Alexa, open OneBusAway" to get arrival times for your favorite stop. You can also change your city or stop at any point, or ask OneBusAway to repeat the last information.

You can find your stop number on the placard in the bus zone, in your OneBusAway mobile app, or on your agency website. If you have trouble finding your stop number, see our guide for "Finding your stop number".

Refer to interaction model/utterances.txt for the full list of spoken phrases we support.

Our user interface flow diagram also defined how you can interact with the skill.

Develop

The application backing the skill was designed to run in AWS.

Prepare your AWS environment

  1. Log in to your AWS Console and switch to the "N. Virginia" region.
  2. Apply the CloudFormation template in aws/cloudformation/onebusaway.template in your AWS account. Name your stack "onebusaway-alexa" for consistency with existing documentation.
  3. Acknowledge "that this template might cause AWS CloudFormation to create IAM resources."
  4. Switch to the Output tab of your stack and note the AWS key ID and secret key. You will use these in the next section.

Personalize the app

  1. Create src/main/resources/onebusaway.properties with the following content:
skill-app-id-development=amzn1.echo-sdk-ams.app... //You'll get this when setting up your Skill. See below.
aws.key-id=...
aws.secret-key=...
googlemaps.api-key=...
onebusaway.api-key=...

And fill it in with your own values.

Build the skill

  1. Install the Java Platform SE Development Kit (JDK) and Maven.

  2. Clone this repository.

  3. Build this project on the command line with mvn package. Look for "BUILD SUCCESS". Resulting JAR is target/onebusaway-alexa-1.0-jar-with-dependencies.jar

  4. Upload to Amazon Lambda with:

     mvn lambduh:deploy-lambda \
         -DaccessKey={your_key} \
         -DsecretKey={your_key} \
         -Ds3Bucket={your_bucket} \
         -Dregion=us-east-1 \
         -DlambdaRoleArn=arn:aws:iam::{your_arn}:role/lambda_basic_execution
    

...where {your_key} is your AWS keys, {your_bucket} is your S3 bucket, and {your_arn} is your AWS Lambda ARN. Note that the AWS credentials used here are distinct from those you just added to onebusaway.properties! Those are for running the application, whereas these are for whichever IAM user you allow to deploy Lambda functions.

  1. From the AWS Console, open your Lambda function and note its ARN. You will use it in the next section.
  2. Add "Alexa Skills Kit" as a new Event Source.

See the lambduh plugin homepage for more information on deploying.

Contributing

Want to make OneBusAway Alexa better? We welcome collaboration! See our Contributing Guide for more details.

Deploy to your Alexa device for the first time

This will be a bit circuitous, because you want your skill to run only if triggered by Alexa, rather than some random Internet visitor or script kiddie. But to do this, we must create the skill first, to get the unique skill ID. But we cannot get this until deploying the skill, which requires your skill to be already running in Lambda. That's why we deployed the skill even though it won't work yet.

  1. Go to the Amazon Developer Console
  2. Add a new skill. Set Invocation Name to "one bus away". Plug in your Lambda function's ARN.
  3. Into "Intent Schema" text box, paste the contents of file interaction model/schema.json.
  4. Under "Custom Slot Types," click on "Add Slot Type". Under "Enter type", add TRANSIT_MODES. Under "Enter values", paste the contents of the file interaction model/customSlotTypes/TRANSIT_MODES.
  5. Under "Custom Slot Types," click on "Add Slot Type". Under "Enter type", add AMAZON.US_CITY. Under "Enter values", paste the contents of the file interaction model/customSlotTypes/AMAZON.US_CITY.
  6. Into "Sample Utterances" text box, paste the contents of file interaction model/utterances.txt. Go Next. That creates the skill.
  7. Switch back to "Skill Information" section, the first section of wizard.
  8. Note the Application Id. Copy that into src/main/resources/onebusaway.properties under the skill-app-id-development=amzn1... entry.
  9. Now recompile and re-deploy to Lambda!

CAUTION: Every time you re-deploy to Lambda using the lambduh-maven-plugin, you must manually re-add "Alexa Skills Kit" as the function's Event Source. You do not need to do this if you deploy your code through the Lambda UI in AWS Console.

Authors

License

Apache v2.0

Privacy Policy

See our Privacy Policy to better understand what information the OneBusAway Alexa skill uses when you request transit arrival information.