-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start building the logic of storing commute
- Loading branch information
Showing
13 changed files
with
725 additions
and
17 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[{"id":"1","name":{"value":"1","synonyms":[]}},{"id":"2","name":{"value":"2","synonyms":[]}},{"id":"3","name":{"value":"3","synonyms":[]}},{"id":"4","name":{"value":"4","synonyms":[]}},{"id":"5","name":{"value":"5","synonyms":[]}},{"id":"6","name":{"value":"6","synonyms":[]}},{"id":"7","name":{"value":"7","synonyms":[]}},{"id":"A","name":{"value":"A","synonyms":["alpha"]}},{"id":"C","name":{"value":"C","synonyms":["charlie"]}},{"id":"E","name":{"value":"E","synonyms":["echo"]}},{"id":"N","name":{"value":"N","synonyms":["november"]}},{"id":"Q","name":{"value":"Q","synonyms":["quebec"]}},{"id":"R","name":{"value":"R","synonyms":["romeo"]}},{"id":"W","name":{"value":"W","synonyms":["whiskey"]}},{"id":"B","name":{"value":"B","synonyms":["bravo"]}},{"id":"D","name":{"value":"D","synonyms":["delta"]}},{"id":"F","name":{"value":"F","synonyms":["foxtrot"]}},{"id":"M","name":{"value":"M","synonyms":["mike"]}},{"id":"L","name":{"value":"L","synonyms":["lima"]}},{"id":"G","name":{"value":"G","synonyms":["golf"]}},{"id":"S","name":{"value":"S","synonyms":["sierra","singapore"]}},{"id":"J","name":{"value":"J","synonyms":["juliet"]}},{"id":"Z","name":{"value":"Z","synonyms":["zulu"]}},{"id":"SIR","name":{"value":"SIR","synonyms":[]}}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module.exports = function() { | ||
let { subwayStation, subwayDirection, subwayLine } = this.event.request.intent.slots; | ||
|
||
if(this.event.request.dialogState === 'COMPLETED') { | ||
this.emit(':tell', 'thank you'); | ||
} else { | ||
console.log(JSON.stringify(this.event)); | ||
this.emit(':delegate'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ | |
"author": "Damon Aw <[email protected]>", | ||
"scripts": { | ||
"data:convert_csv_stops_to_json": "csvtojson ./assets/mta/Stations.csv > ./values/subway-stops.json", | ||
"data:convert_stations_to_slot": "node ./scripts/clean-station-names.js > ./data/slots/station-names.json", | ||
"data:slots:generate_station_names": "node ./scripts/clean-station-names.js > ./data/slots/station-names.json", | ||
"data:slots:generate_subway_lines": "node ./scripts/generate-subway-lines.js > ./data/slots/subway-lines.json", | ||
"dynamodb:download": "mkdir -p downloads && mkdir -p dynamodb_local && wget -N https://s3-us-west-2.amazonaws.com/dynamodb-local/dynamodb_local_latest.tar.gz -P ./downloads && tar -xvf ./downloads/dynamodb_local_latest.tar.gz -C ./dynamodb_local", | ||
"dynamodb:start": "java -Djava.library.path=./dynamodb_local/DynamoDBLocal_lib -jar ./dynamodb_local/DynamoDBLocal.jar -sharedDb -inMemory", | ||
"release": "rm -f subway.zip && yarn --production && zip -r subway.zip . -x '*.git*' -x 'tests/*' -x 'downloads/*' -x 'assets/*' -x 'dynamodb_local/*'", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const _ = require('lodash'); | ||
|
||
const subwayLines = [ | ||
'1', '2', '3', | ||
'4', '5', '6', | ||
'7', | ||
'A', 'C', 'E', | ||
'N', 'Q', 'R', 'W', | ||
'B', 'D', 'F', 'M', | ||
'L', 'G', | ||
'S', | ||
'J', 'Z', | ||
'SIR' | ||
]; | ||
|
||
const synonyms = { | ||
'A': ['alpha'], | ||
'C': ['charlie'], | ||
'E': ['echo'], | ||
'N': ['november'], | ||
'Q': ['quebec'], | ||
'R': ['romeo'], | ||
'W': ['whiskey'], | ||
'B': ['bravo'], | ||
'D': ['delta'], | ||
'F': ['foxtrot'], | ||
'M': ['mike'], | ||
'L': ['lima'], | ||
'G': ['golf'], | ||
'S': ['sierra', 'singapore'], | ||
'J': ['juliet'], | ||
'Z': ['zulu'] | ||
}; | ||
|
||
process.stdout.write( | ||
JSON.stringify(subwayLines.map(line => ({ id: line, name: { value: line, synonyms: synonyms[line] || [] }}))) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
{ | ||
"version": "1.0", | ||
"session": { | ||
"new": true, | ||
"sessionId": "amzn1.echo-api.session.02c67291-9e9a-4ca5-bef8-c19b642426c4", | ||
"application": { | ||
"applicationId": "amzn1.ask.skill.4fe3808f-fda4-4bfc-8e53-07b9f3b3baae" | ||
}, | ||
"user": { | ||
"userId": "amzn1.ask.account.AG7TBVHS7QUDLBU6N65BSUJMZZTQ6CFD4YFQELQRLXB3M4UV64MQ7RJ5CPWXYALQ3QJ665TJ7OIF3ZT4RMC5NQRPH5OWB4TMQTC46REKNEYDBLUN6OJ7OLXYHGEUOLZYRA3CQGGSLOSOFQTEVG4DNKVRN3NIVPK2YYUCAFJ64ODXBDNE5YNAXDX7GQATDLNGZR7G5KMDNTHZR2I" | ||
}, | ||
"attributes": {} | ||
}, | ||
"context": { | ||
"AudioPlayer": { | ||
"playerActivity": "STOPPED" | ||
}, | ||
"System": { | ||
"application": { | ||
"applicationId": "amzn1.ask.skill.4fe3808f-fda4-4bfc-8e53-07b9f3b3baae" | ||
}, | ||
"user": { | ||
"userId": "amzn1.ask.account.AG7TBVHS7QUDLBU6N65BSUJMZZTQ6CFD4YFQELQRLXB3M4UV64MQ7RJ5CPWXYALQ3QJ665TJ7OIF3ZT4RMC5NQRPH5OWB4TMQTC46REKNEYDBLUN6OJ7OLXYHGEUOLZYRA3CQGGSLOSOFQTEVG4DNKVRN3NIVPK2YYUCAFJ64ODXBDNE5YNAXDX7GQATDLNGZR7G5KMDNTHZR2I" | ||
}, | ||
"device": { | ||
"deviceId": "amzn1.ask.device.AEGQ5USV2TVZTMTG7AXEFTAK5FA4GCTGJWPKJJYMWCFA3E4ADMSX6V7UYVNDBFNUVE2FFWHIZEUBFGWELKJLN243XVK7MURJXUD5O7HFHWAQNFDJAWPSELUAO3NX2RECP6QEZEICXGE2ULYJFUYGSWSNEFRA", | ||
"supportedInterfaces": { | ||
"AudioPlayer": {} | ||
} | ||
}, | ||
"apiEndpoint": "https://api.amazonalexa.com" | ||
} | ||
}, | ||
"request": { | ||
"type": "IntentRequest", | ||
"requestId": "amzn1.echo-api.request.f6c656ec-0bc0-4fc6-bb89-91747b4718c7", | ||
"timestamp": "2017-07-07T21:55:46Z", | ||
"locale": "en-US", | ||
"intent": { | ||
"name": "storeCommute", | ||
"confirmationStatus": "NONE", | ||
"slots": { | ||
"subwayStation": { | ||
"name": "subwayStation", | ||
"confirmationStatus": "NONE" | ||
}, | ||
"subwayDirection": { | ||
"name": "subwayDirection", | ||
"confirmationStatus": "NONE" | ||
}, | ||
"subwayLine": { | ||
"name": "subwayLine", | ||
"confirmationStatus": "NONE" | ||
} | ||
} | ||
}, | ||
"dialogState": "STARTED" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"version": "1.0", | ||
"session": { | ||
"new": false, | ||
"sessionId": "amzn1.echo-api.session.02c67291-9e9a-4ca5-bef8-c19b642426c4", | ||
"application": { | ||
"applicationId": "amzn1.ask.skill.4fe3808f-fda4-4bfc-8e53-07b9f3b3baae" | ||
}, | ||
"user": { | ||
"userId": "amzn1.ask.account.AG7TBVHS7QUDLBU6N65BSUJMZZTQ6CFD4YFQELQRLXB3M4UV64MQ7RJ5CPWXYALQ3QJ665TJ7OIF3ZT4RMC5NQRPH5OWB4TMQTC46REKNEYDBLUN6OJ7OLXYHGEUOLZYRA3CQGGSLOSOFQTEVG4DNKVRN3NIVPK2YYUCAFJ64ODXBDNE5YNAXDX7GQATDLNGZR7G5KMDNTHZR2I" | ||
}, | ||
"attributes": {} | ||
}, | ||
"context": { | ||
"AudioPlayer": { | ||
"playerActivity": "STOPPED" | ||
}, | ||
"System": { | ||
"application": { | ||
"applicationId": "amzn1.ask.skill.4fe3808f-fda4-4bfc-8e53-07b9f3b3baae" | ||
}, | ||
"user": { | ||
"userId": "amzn1.ask.account.AG7TBVHS7QUDLBU6N65BSUJMZZTQ6CFD4YFQELQRLXB3M4UV64MQ7RJ5CPWXYALQ3QJ665TJ7OIF3ZT4RMC5NQRPH5OWB4TMQTC46REKNEYDBLUN6OJ7OLXYHGEUOLZYRA3CQGGSLOSOFQTEVG4DNKVRN3NIVPK2YYUCAFJ64ODXBDNE5YNAXDX7GQATDLNGZR7G5KMDNTHZR2I" | ||
}, | ||
"device": { | ||
"deviceId": "amzn1.ask.device.AEGQ5USV2TVZTMTG7AXEFTAK5FA4GCTGJWPKJJYMWCFA3E4ADMSX6V7UYVNDBFNUVE2FFWHIZEUBFGWELKJLN243XVK7MURJXUD5O7HFHWAQNFDJAWPSELUAO3NX2RECP6QEZEICXGE2ULYJFUYGSWSNEFRA", | ||
"supportedInterfaces": { | ||
"AudioPlayer": {} | ||
} | ||
}, | ||
"apiEndpoint": "https://api.amazonalexa.com" | ||
} | ||
}, | ||
"request": { | ||
"type": "IntentRequest", | ||
"requestId": "amzn1.echo-api.request.ff88ca27-f12f-4ab1-9cc2-02b52cea1ec7", | ||
"timestamp": "2017-07-07T21:55:59Z", | ||
"locale": "en-US", | ||
"intent": { | ||
"name": "storeCommute", | ||
"confirmationStatus": "NONE", | ||
"slots": { | ||
"subwayStation": { | ||
"name": "subwayStation", | ||
"confirmationStatus": "NONE" | ||
}, | ||
"subwayDirection": { | ||
"name": "subwayDirection", | ||
"confirmationStatus": "NONE" | ||
}, | ||
"subwayLine": { | ||
"name": "subwayLine", | ||
"value": "R", | ||
"resolutions": { | ||
"resolutionsPerAuthority": [ | ||
{ | ||
"authority": "amzn1.er-authority.echo-sdk.amzn1.ask.skill.4fe3808f-fda4-4bfc-8e53-07b9f3b3baae.SUBWAY_LINE", | ||
"status": { | ||
"code": "ER_SUCCESS_MATCH" | ||
}, | ||
"values": [ | ||
{ | ||
"value": { | ||
"name": "R", | ||
"id": "e1e1d3d40573127e9ee0480caf1283d6" | ||
} | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
"confirmationStatus": "NONE" | ||
} | ||
} | ||
}, | ||
"dialogState": "IN_PROGRESS" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import test from 'ava'; | ||
|
||
import LambdaTester from 'lambda-tester'; | ||
import getTestEvent from '../helpers/get-test-event.js'; | ||
|
||
import storeCommute from '../../handlers/store-commute.js'; | ||
import createAlexaHandler from '../helpers/create-alexa-handler.js'; | ||
|
||
test(`Handling the start of the dialog`, async t => { | ||
t.plan(1); | ||
|
||
const event = getTestEvent('store-commute-start'); | ||
const alexaHandler = createAlexaHandler({ storeCommute }); | ||
|
||
const result = await LambdaTester(alexaHandler) | ||
.event(event) | ||
.expectSucceed(r => r); | ||
|
||
t.is(result.response.directives[0].type, "Dialog.Delegate") | ||
}); | ||
|
||
test(`collecting subwayLine and a valid input is given`, async t => { | ||
t.plan(1); | ||
|
||
const event = getTestEvent('store-commute-subway-line'); | ||
const alexaHandler = createAlexaHandler({ storeCommute }); | ||
|
||
const result = await LambdaTester(alexaHandler) | ||
.event(event) | ||
.expectSucceed(r => r); | ||
|
||
t.is(result.response.directives[0].type, "Dialog.Delegate"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const fs = require('fs'); | ||
|
||
module.exports = (eventName) => JSON.parse( | ||
fs.readFileSync(`${process.cwd()}/tests/fixtures/events/${eventName}.json`) | ||
); |