0
0

More than 1 year has passed since last update.

node.jsでalexaスキル その3

Posted at

概要

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

練習問題

「キヨシを開いて」で、zundokoを返せ。

サンプルコード

const LaunchRequestHandler = {
	canHandle(handlerInput) {
		return Alexa.getRequestType(handlerInput.requestEnvelope) === 'LaunchRequest';
	},
	handle(handlerInput) {
		let speakOutput = '';
		let j = 0;
		while (j < 4)
		{
			if (Math.floor(Math.random() * 2) < 1)
			{
				j++;
				speakOutput += "ズン ";
			}
			else
			{
				j = 0;
				speakOutput += "ドコ ";
			}
		}
		speakOutput += "ドコ キヨシ";
		return handlerInput.responseBuilder.speak(speakOutput)
			.reprompt(speakOutput)
			.getResponse();
	}
};


実行結果

image.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