UK Public Transport will help user utilize the public transportation for the fullest. They plan on taking which mode of public transports for a trip between two places. It will help with the shortest path possible with multiple public mode of transportation like trains, buses, tubes, boats etc. It will also help them in finding train stations near any place and its time table so that they can plan their journey in advance
Prerequisites- Basic Knowledge of JavaScript and Node.js
- Amazon AWS Account for deploying Lambda Function
- Google API Key with Google Maps API, Google Static Map API, and URL Shorting API enabled
- Transport API account
- bespoken.tools for Testing
- Echosim.io for Testing
- Mocha for testing
Here is an Quick Start tutorial on how to publish a Alexa Skill with Node.js and Lambda Function. Here is the first skill I developed where I cover some basics.
FunctionalityUK Public Transport in its current state support two functionality,
- Planning a trip by public transports (mode of transport can be by foot, bus, train, tube, boat etc.,) between two places in UK
- Finding train stations near by any place in UK
Intent Schema
{
"intents": [
{
"intent": "AMAZON.CancelIntent"
},
{
"intent": "AMAZON.HelpIntent"
},
{
"intent": "AMAZON.StopIntent"
},
{
"intent": "AMAZON.YesIntent"
},
{
"intent": "AMAZON.NoIntent"
},
{
"intent": "NearByTrainIntent",
"slots": [
{
"name": "location",
"type": "LOCATION_LIST"
}
]
},
{
"intent": "PlanPublicTransportIntent",
"slots": [
{
"name": "from",
"type": "LOCATION_LIST"
},
{
"name": "to",
"type": "LOCATION_LIST"
}
]
},
{
"intent": "DateTimeIntent",
"slots": [
{
"name": "date",
"type": "AMAZON.DATE"
},
{
"name": "time",
"type": "AMAZON.TIME"
}
]
},{
"intent": "LocationIntent",
"slots": [
{
"name": "location",
"type": "LOCATION_LIST"
}
]
}
]
}
Utterances
PlanPublicTransportIntent plan a trip from {from} to {to}
PlanPublicTransportIntent plan a trip from {from}
PlanPublicTransportIntent plan a trip to {to}
PlanPublicTransportIntent plan a trip
NearByTrainIntent find stations nearby {location}
NearByTrainIntent find any stations nearby {location}
NearByTrainIntent find station nearby {location}
NearByTrainIntent find train station nearby {location}
NearByTrainIntent find train stations nearby {location}
NearByTrainIntent what are the stations nearby {location}
NearByTrainIntent what are the train stations nearby {location}
NearByTrainIntent for stations nearby {location}
NearByTrainIntent for station nearby {location}
NearByTrainIntent for any station nearby {location}
NearByTrainIntent find stations near {location}
NearByTrainIntent find any stations near {location}
NearByTrainIntent find station near {location}
NearByTrainIntent find train station near {location}
NearByTrainIntent find train stations near {location}
NearByTrainIntent what are the stations near {location}
NearByTrainIntent what are the train stations near {location}
NearByTrainIntent for stations near {location}
NearByTrainIntent for station near {location}
NearByTrainIntent for any station near {location}
DateTimeIntent {date} {time}
DateTimeIntent {time} {date}
DateTimeIntent {date}
DateTimeIntent {time}
DateTimeIntent at {date} {time}
DateTimeIntent on {date} {time}
DateTimeIntent at {date}
DateTimeIntent on {date}
DateTimeIntent at {time}
DateTimeIntent on {time}
LocationIntent {location}
LocationIntent to {location}
LocationIntent from {location}
LocationIntent for {location}
LOCATION_LIST (Just some sample location are given. Other locations will get captured automatically)
wembley stadium
manchester
downing street
IntentsPlanPublicTransportIntent
For handling requests for planning a trip between places. {from} is the location from which the user plans to travel. {to} is the location to which the user plans to travel. If the user doesn't specify {from} or {to} or both we will ask the user for from and to location which will be captured in LocationIntent.
NearByTrainIntent
For handling requests for finding near by train station. {location} is the location to which near by stations are searched.
DateTimeIntent
Used in both trip planning and station finding. Captured if either date or time or both are mentioned.
LocationIntent
For capturing location separately if the user hasn't specified the from or to location while planning the trip
Built-in Intents used
- AMAZON.YesIntent/AMAZON.NoIntent - For handling yes no response
- AMAZON.NextIntent - For navigating the directions while trip planning
- AMAZON.RepeatIntent - To repeat any direction if the user didn't quite get it the first time
- AMAZON.HelpIntent, AMAZON.CancelIntent, AMAZON.StopIntent are used as well
Alexa Skills Kit for Node.js is used for building the overall flow. Google's geocoding API is used to convert the user mentioned location to latitude and longitude as well as to verify that the place is in UK only. Transportapi's APIs were used to find near by stations and journey paths for trip planning. Google's Static Map API was used to add a map to card while mentioning a train station. Google map is given as reference for navigation for trip planning.
TestingI am still having difficulties using Echosim for testing. And I don't own any echo devices yet so Service Simulator in Alexa dashboard and bespoken.tools are my only ways of testing. Service Simulator came in very handy for testing the skill before submitting for certification. Bespoken tools can in handy during development. The project contains test scripts written with mocha and bespoken emulator. To run the test script in the root folder run the following command:
mocha test
Packaging and DeploymentI used node-lambda this time. It helped in packaging the skill along with required node_modules as a zip file which I can upload to Amazon Lambda.
Skill StatusAs of writing this article the skill is submitted for certification and waiting. This is the application ID amzn1.ask.skill.57389f99-9a74-4f34-b6a6-ba4b48c26b09
Future PlansWill be adding more search options to other transport mode other than train like buses, car etc.
Comments and Suggestions are welcome.
Comments