An Alexa skill to discover when the next tram is due using the Traveline NextBuses API and an AWS Lambda written in Go.
You will require an Amazon Web Services (AWS) account and credentials to use the Traveline NextBuses API.
Please ensure the following dependencies are installed:
- Git
- npm
- Go 1.14+
- AWS CLI
- AWS SAM CLI - to run Lambda locally
Configure the AWS CLI in the WSL console.
Then run:
make install
To deploy the infrastructure to AWS run:
make deploy USERNAME=[] PASSWORD=[] AWS_ACCOUNT_ID=[] AWS_REGION=[] NAPTAN_CODE=[]
Where:
USERNAME
- the username for the Traveline NextBuses APIPASSWORD
- the password for the Traveline NextBuses APIAWS_ACCOUNT_ID
- the AWS account ID to install the infrastructureAWS_REGION
- the AWS region to install the infrastructureNAPTAN_CODE
- the NaPTAN code of the tram stop for the next tram times
To run the Lambda locally using the AWS SAM:
make sam-synth-cdk USERNAME=[] PASSWORD=[] NAPTAN_CODE=[]
make sam-local
You will require an Amazon developer account.
Login to the alexa develop console and create a new skill with the following configuration.
- Skill name:
Next tram
- Default language:
English (UK)
- Choose a model to add to your skill:
Custom
- Choose a method to host your skill's backend resources:
Provision your own
Choose: Start from scratch
Invocation
- Skill Invocation Name:
next tram
Intents
- Name:
when
- Sample Utterance:
When is my next tram due
Endpoint
- Service Endpoint Type: AWS Lambda ARN
- Default Region: Use the ARN output when the infrastructure stack is deployed
You will then need to build the model.
Select the Test
tab in teh alexa developer console.
- Skill testing is enabled in:
Development
Alexa Simulator: ask next tram when my next tram is due
And the magic should happen!