0
0

More than 1 year has passed since last update.

node.jsでalexaスキル その4

Posted at

概要

node.jsでalexaスキル、やってみた。
練習問題やってみた。

練習問題

dynamodbを、使え。

サンプルコード

const LaunchRequestHandler = {
	canHandle(handlerInput) {
		return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
	},
	async handle(handlerInput) {
	    const attributesManager = handlerInput.attributesManager;
	    const attributes2 = await attributesManager.getPersistentAttributes() || {};
        let counter = attributes2.hasOwnProperty('counter') ? attributes2.counter : 0;
		let speakOutput = `こんにちは、カウンターは${counter}です`;
		counter++;
        let attributes1 = {
		    "counter": counter
	    };
	    attributesManager.setPersistentAttributes(attributes1);
	    await attributesManager.savePersistentAttributes();
		return handlerInput.responseBuilder.speak(speakOutput)
			.reprompt(speakOutput)
			.getResponse();
	}
};



実行結果

kiyosi.png

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0