テスト用カウント処理追加

This commit is contained in:
ろむねこ 2024-07-16 09:46:41 +09:00
parent 33e6e2fbdf
commit 490fca395e
Signed by: Fujimatsu
GPG Key ID: FA1F39A1BA37D168

View File

@ -21,8 +21,21 @@ const HelloWorldIntentHandler = {
return Alexa.getRequestType(handlerInput.requestEnvelope) === 'IntentRequest'
&& Alexa.getIntentName(handlerInput.requestEnvelope) === 'HelloWorldIntent';
},
handle(handlerInput: Alexa.HandlerInput) {
const speakOutput = 'Hello World!';
async handle(handlerInput: Alexa.HandlerInput) {
const attributesManager = handlerInput.attributesManager;
const attributes = await attributesManager.getPersistentAttributes();
if (!attributes.counter) {
attributes.counter = 0;
} else {
attributes.counter += 1;
}
attributesManager.setPersistentAttributes(attributes);
await attributesManager.savePersistentAttributes();
const speakOutput = `Hello World! You've visited this skill ${attributes.counter} times.`;
return handlerInput.responseBuilder
.speak(speakOutput)