enebularでalexaスキル その9

# 概要
enebularで、alexaスキルのwebhookを返してみた。
練習問題やってみた。

# 練習問題
chatbotを実装せよ。

# 参考にしたページ

https://qiita.com/hirokiwa/items/28426af6f051845b1a1f


# 方針
呼び出しは、チャットボット
chatbotは、nlpを使う。
LaunchRequestで、"チャットボットです。"
IntentRequestで、自由入力


# 写真

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/44ec2135-90a9-0f29-3b28-5ae246d39d96.png)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/57910948-9abf-7013-ab23-c14ae303e7ad.png)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/f8d20109-a126-131d-371b-add1b4d69526.png)
![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/614dde06-c336-7eac-bc34-08857ee32873.png)


# 手順

amazon developerコンソール

https://developer.amazon.com/dashboard

新しいスキルを作成

1.スキルに追加するモデルを選択

- カスタムを選択

2.スキルのバックエンドリソースをホスティングする方法を選択

- ユーザー定義のプロビジョニングを選択

- スキルを作成をクリック

スキルに追加するテンプレートを選択

- スクラッチで作成を選択

- 選択をクリック

呼び出し名の登録

- チャットボット

インテントの追加をクリック

カスタムインテントを作成

- MsgIntent

" {message} "

message AMAZON.SearchQuery

サービスのエンドポイントの種類

- https https://***.herokuapp.com/

ビルドを実行

テスト

開発中





# フロー

![image.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/18104/0fa2da5b-811c-6f74-3f55-d51375d31629.png)


```
[{"id":"f0a907cc.af4218","type":"http in","z":"da568283.b34a7","name":"","url":"/","method":"post","upload":false,"swaggerDoc":"","x":130,"y":140,"wires":[["2a34f775.7fda08"]]},{"id":"2a34f775.7fda08","type":"switch","z":"da568283.b34a7","name":"request.type 判定","property":"payload.request.type","propertyType":"msg","rules":[{"t":"eq","v":"LaunchRequest","vt":"str"},{"t":"eq","v":"IntentRequest","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":270,"y":80,"wires":[["cfd360ad.7b27c"],["c12a09a5.1fa5b8"]]},{"id":"d06f833d.ef44f","type":"http response","z":"da568283.b34a7","name":"","statusCode":"","headers":{},"x":750,"y":100,"wires":[]},{"id":"f37951a4.334fe","type":"debug","z":"da568283.b34a7","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","x":730,"y":260,"wires":[]},{"id":"cfd360ad.7b27c","type":"template","z":"da568283.b34a7","name":"page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n  \"version\": \"1.0\",\n  \"sessionAttributes\": {\n  },\n  \"response\": {\n    \"outputSpeech\": {\n      \"type\": \"PlainText\",\n      \"text\": \"チャットボットです。\"\n    },\n    \"card\": {\n      \"type\": \"Simple\",\n      \"title\": \"チャットボット\",\n      \"content\": \"チャットボットです。\"\n    },\n    \"reprompt\": {\n      \"outputSpeech\": {\n        \"type\": \"PlainText\",\n        \"text\": \"他にも質問はありますか？\"\n      }\n    },\n    \"shouldEndSession\": false\n  }\n}\n","x":450,"y":40,"wires":[["a3f5d1d3.48456"]]},{"id":"a3f5d1d3.48456","type":"change","z":"da568283.b34a7","name":"Set Headers","rules":[{"t":"set","p":"headers","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"headers.content-type","pt":"msg","to":"application/json","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":590,"y":160,"wires":[["d06f833d.ef44f"]]},{"id":"5d09dbfd.0d44d4","type":"template","z":"da568283.b34a7","name":"page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\n  \"version\": \"1.0\",\n  \"sessionAttributes\": {\n  },\n  \"response\": {\n    \"outputSpeech\": {\n      \"type\": \"PlainText\",\n      \"text\": \"{{payload.answer}}\"\n    },\n    \"card\": {\n      \"type\": \"Simple\",\n      \"title\": \"チャットボット\",\n      \"content\": \"{{payload.answer}}\"\n    },\n    \"reprompt\": {\n      \"outputSpeech\": {\n        \"type\": \"PlainText\",\n        \"text\": \"他にも質問はありますか？\"\n      }\n    },\n    \"shouldEndSession\": false\n  }\n}\n","x":450,"y":280,"wires":[["a3f5d1d3.48456"]]},{"id":"c12a09a5.1fa5b8","type":"function","z":"da568283.b34a7","name":"switch","func":"msg.payload = msg.payload.request.intent.slots.message.value;\n\nreturn msg;\n\n\n","outputs":1,"noerr":0,"x":250,"y":220,"wires":[["875cf6ec.9800e8"]]},{"id":"875cf6ec.9800e8","type":"nlp","z":"da568283.b34a7","utterance":"","lang":"ja","name":"","x":350,"y":340,"wires":[["5d09dbfd.0d44d4","f37951a4.334fe"]]}]
```

以上。