3
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Alexaスキルでおうむ返し

Last updated at Posted at 2018-08-26

発話内容をAlexaにおうむ返しさせるサンプル。Alexaは任意の発話を受けるスロットタイプが無いようだが、適当なスロットタイプでいけた。

インテントの設定

インテント名は適当にCopyIntentとし、スロットタイプはAMAZON.Colorを指定。
スクリーンショット 2018-08-26 18.57.38.png

AMAZON.Colorが任意の文字列を受けられるという情報は、この書籍を参考にした。

おもしろまじめなAIスピーカーアプリをつくろう -Google Home(アシスタント)&Amazon Echo(Alexa)音声アシスタント開発
https://www.shuwasystem.co.jp/products/7980html/5273.html

Lambda関数

CopyIntentHandlerメソッドで、 スロットのmessageを取り出す。

const CopyIntentHandler = {
    canHandle(handlerInput) {
        return handlerInput.requestEnvelope.request.type === 'IntentRequest'
            && handlerInput.requestEnvelope.request.intent.name === 'CopyIntent';
    },
    handle(handlerInput) {
        let value = handlerInput.requestEnvelope.request.intent.slots.message.value;
        const speechText = value + 'って言いましたね!';

        return handlerInput.responseBuilder
            .speak(speechText)
            .getResponse();
    },
};

とりあえず、これでうまくいった。

3
6
2

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
3
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?