Skip to content

Commit

Permalink
use @talkyjs/ssml instead of ask-utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidetaka Okamoto committed Dec 24, 2020
1 parent 4a35e64 commit d806147
Show file tree
Hide file tree
Showing 15 changed files with 6,046 additions and 21 deletions.
8 changes: 6 additions & 2 deletions lambda/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@
"license": "MIT",
"dependencies": {
"@talkyjs/core": "1.x",
"@ask-utils/speech-script": "3.x",
"@talkyjs/ssml": "0.2.0",
"ask-sdk-core": "^2.6.0",
"ask-sdk-model": "^1.18.0"
"ask-sdk-model": "^1.18.0",
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"directories": {
"lib": "src",
Expand Down Expand Up @@ -48,6 +50,8 @@
"@ask-utils/test": "3.x",
"@types/jest": "^25.2.1",
"@types/node": "^13.13.5",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/webpack": "^4.41.12",
"jest": "^26.0.1",
"source-map-support": "^0.5.19",
Expand Down
7 changes: 2 additions & 5 deletions lambda/src/HelpIntent/HelpIntent.speech.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/** @jsx ssml */
import {
ssml,
SpeechScriptJSX,
} from '@ask-utils/speech-script'
import React from 'react';
import { SpeechScriptJSX } from '@talkyjs/ssml'

export class HelpIntentScript extends SpeechScriptJSX {
speech() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HelpIntentRouter canHandle should return false when given a not IntentRequest 1`] = `true`;

exports[`HelpIntentRouter handle should match snapshot 1`] = `
Object {
"outputSpeech": Object {
"ssml": "<speak><p>Hello! It's a nice development. How are you?</p></speak>",
"type": "SSML",
},
"reprompt": Object {
"outputSpeech": Object {
"ssml": "<speak><p>How are you?</p></speak>",
"type": "SSML",
},
},
"shouldEndSession": false,
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`HelpIntentScript should return false when given a not IntentRequest 1`] = `
Object {
"outputSpeech": Object {
"ssml": "<speak><p>Hello! It's a nice development. How are you?</p></speak>",
"type": "SSML",
},
"reprompt": Object {
"outputSpeech": Object {
"ssml": "<speak><p>How are you?</p></speak>",
"type": "SSML",
},
},
"shouldEndSession": false,
}
`;
4 changes: 3 additions & 1 deletion lambda/src/LaunchRequest/LaunchRequest.router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ export const LaunchRequestRouter: Router = {
handler: async (handlerInput) => {


const script = new LaunchRequestScript(handlerInput)
const script = new LaunchRequestScript(handlerInput, {
dummyProps: "It's a nice development."
})
return script
.createResponseBuilder()
.getResponse();
Expand Down
16 changes: 9 additions & 7 deletions lambda/src/LaunchRequest/LaunchRequest.speech.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/** @jsx ssml */
import {
ssml,
SpeechScriptJSX,
} from '@ask-utils/speech-script'
import React from 'react';
import { SpeechScriptJSXWithOption } from '@talkyjs/ssml'

export class LaunchRequestScript extends SpeechScriptJSX {
export class LaunchRequestScript extends SpeechScriptJSXWithOption<{
dummyProps: string;
}> {
speech() {
return (
<speak>
<p>Hello! It's a nice development. How are you?</p>
<p>
<amazon-emotion name="excited" intensity="high">Hello!</amazon-emotion>
{this.options.dummyProps} How are you?
</p>
</speak>
)
}
Expand Down
4 changes: 3 additions & 1 deletion lambda/src/LaunchRequest/tests/LaunchRequest.speech.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ describe('LaunchRequestScript', () => {
name: "LaunchRequest",
confirmationStatus: 'NONE'
});
const script = new LaunchRequestScript(handlerInput);
const script = new LaunchRequestScript(handlerInput, {
dummyProps: "It's a nice development."
});
expect(script.createResponse()).toMatchSnapshot();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`LaunchRequestRouter canHandle should return false when given a not IntentRequest 1`] = `false`;

exports[`LaunchRequestRouter handle should match snapshot 1`] = `
Object {
"outputSpeech": Object {
"ssml": "<speak><p><amazon:emotion name=\\"excited\\" intensity=\\"high\\">Hello!</amazon:emotion>It's a nice development. How are you?</p></speak>",
"type": "SSML",
},
"reprompt": Object {
"outputSpeech": Object {
"ssml": "<speak><p>How are you?</p></speak>",
"type": "SSML",
},
},
"shouldEndSession": false,
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`LaunchRequestScript should return false when given a not IntentRequest 1`] = `
Object {
"outputSpeech": Object {
"ssml": "<speak><p><amazon:emotion name=\\"excited\\" intensity=\\"high\\">Hello!</amazon:emotion>It's a nice development. How are you?</p></speak>",
"type": "SSML",
},
"reprompt": Object {
"outputSpeech": Object {
"ssml": "<speak><p>How are you?</p></speak>",
"type": "SSML",
},
},
"shouldEndSession": false,
}
`;
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
/** @jsx ssml */
import {
ssml,
SpeechScriptJSX,
} from '@ask-utils/speech-script'
import React from 'react';
import { SpeechScriptJSX } from '@talkyjs/ssml'

export class StopAndCancelAndNoIntentScript extends SpeechScriptJSX {
speech() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`StopAndCancelAndNoIntentRouter canHandle should match the snapshot of the "AMAZON.CancelIntent" IntentRequest 1`] = `true`;

exports[`StopAndCancelAndNoIntentRouter canHandle should match the snapshot of the "AMAZON.NoIntent" IntentRequest 1`] = `true`;

exports[`StopAndCancelAndNoIntentRouter canHandle should match the snapshot of the "AMAZON.StopIntent" IntentRequest 1`] = `true`;

exports[`StopAndCancelAndNoIntentRouter handle should match snapshot 1`] = `
Object {
"outputSpeech": Object {
"ssml": "<speak><p>Good-bye!</p></speak>",
"type": "SSML",
},
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`StopAndCancelAndNoIntentScript should match the snapshot of the "AMAZON.CancelIntent" IntentRequest 1`] = `
Object {
"outputSpeech": Object {
"ssml": "<speak><p>Good-bye!</p></speak>",
"type": "SSML",
},
}
`;

exports[`StopAndCancelAndNoIntentScript should match the snapshot of the "AMAZON.NoIntent" IntentRequest 1`] = `
Object {
"outputSpeech": Object {
"ssml": "<speak><p>Good-bye!</p></speak>",
"type": "SSML",
},
}
`;

exports[`StopAndCancelAndNoIntentScript should match the snapshot of the "AMAZON.StopIntent" IntentRequest 1`] = `
Object {
"outputSpeech": Object {
"ssml": "<speak><p>Good-bye!</p></speak>",
"type": "SSML",
},
}
`;
162 changes: 162 additions & 0 deletions lambda/src/tests/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Skill handler should match the snapshot of the "AMAZON.CancelIntent" IntentRequest 1`] = `
Object {
"response": Object {
"outputSpeech": Object {
"ssml": "<speak><p>Good-bye!</p></speak>",
"type": "SSML",
},
},
"sessionAttributes": Object {
"__talkyjs": Object {
"sessionSituation": Object {
"invocationNumber": 0,
"turnCount": 1,
},
},
},
"userAgent": "ask-node/2.10.1 Node/v12.14.1",
"version": "1.0",
}
`;

exports[`Skill handler should match the snapshot of the "AMAZON.HelpIntent" IntentRequest 1`] = `
Object {
"response": Object {
"outputSpeech": Object {
"ssml": "<speak><p>Hello! It's a nice development. How are you?</p></speak>",
"type": "SSML",
},
"reprompt": Object {
"outputSpeech": Object {
"ssml": "<speak><p>How are you?</p></speak>",
"type": "SSML",
},
},
"shouldEndSession": false,
},
"sessionAttributes": Object {
"__talkyjs": Object {
"recordedResponse": Object {
"outputSpeech": Object {
"ssml": "<speak><p>Hello! It's a nice development. How are you?</p></speak>",
"type": "SSML",
},
"reprompt": Object {
"outputSpeech": Object {
"ssml": "<speak><p>How are you?</p></speak>",
"type": "SSML",
},
},
"shouldEndSession": false,
},
"sessionSituation": Object {
"invocationNumber": 0,
"turnCount": 1,
},
},
},
"userAgent": "ask-node/2.10.1 Node/v12.14.1",
"version": "1.0",
}
`;

exports[`Skill handler should match the snapshot of the "AMAZON.NoIntent" IntentRequest 1`] = `
Object {
"response": Object {
"outputSpeech": Object {
"ssml": "<speak><p>Good-bye!</p></speak>",
"type": "SSML",
},
},
"sessionAttributes": Object {
"__talkyjs": Object {
"sessionSituation": Object {
"invocationNumber": 0,
"turnCount": 1,
},
},
},
"userAgent": "ask-node/2.10.1 Node/v12.14.1",
"version": "1.0",
}
`;

exports[`Skill handler should match the snapshot of the "AMAZON.StopIntent" IntentRequest 1`] = `
Object {
"response": Object {
"outputSpeech": Object {
"ssml": "<speak><p>Good-bye!</p></speak>",
"type": "SSML",
},
},
"sessionAttributes": Object {
"__talkyjs": Object {
"sessionSituation": Object {
"invocationNumber": 0,
"turnCount": 1,
},
},
},
"userAgent": "ask-node/2.10.1 Node/v12.14.1",
"version": "1.0",
}
`;

exports[`Skill handler should return false when given a not LaunchRequest 1`] = `
Object {
"response": Object {
"outputSpeech": Object {
"ssml": "<speak><p><amazon:emotion name=\\"excited\\" intensity=\\"high\\">Hello!</amazon:emotion>It's a nice development. How are you?</p></speak>",
"type": "SSML",
},
"reprompt": Object {
"outputSpeech": Object {
"ssml": "<speak><p>How are you?</p></speak>",
"type": "SSML",
},
},
"shouldEndSession": false,
},
"sessionAttributes": Object {
"__talkyjs": Object {
"recordedResponse": Object {
"outputSpeech": Object {
"ssml": "<speak><p><amazon:emotion name=\\"excited\\" intensity=\\"high\\">Hello!</amazon:emotion>It's a nice development. How are you?</p></speak>",
"type": "SSML",
},
"reprompt": Object {
"outputSpeech": Object {
"ssml": "<speak><p>How are you?</p></speak>",
"type": "SSML",
},
},
"shouldEndSession": false,
},
"sessionSituation": Object {
"invocationNumber": 0,
"turnCount": 1,
},
},
},
"userAgent": "ask-node/2.10.1 Node/v12.14.1",
"version": "1.0",
}
`;

exports[`Skill handler should return false when given a not SessionEndedRequest 1`] = `
Object {
"response": Object {},
"sessionAttributes": Object {
"__talkyjs": Object {
"sessionSituation": Object {
"invocationNumber": 0,
"turnCount": 1,
},
},
},
"userAgent": "ask-node/2.10.1 Node/v12.14.1",
"version": "1.0",
}
`;
1 change: 1 addition & 0 deletions lambda/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"module": "commonjs",
"target": "es6",
"noImplicitAny": true,
"esModuleInterop": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"outDir": "./dist",
Expand Down
Loading

0 comments on commit d806147

Please sign in to comment.