1
0

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 1 year has passed since last update.

enebularでalexaスキル その7

Last updated at Posted at 2022-08-21

概要

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

練習問題

湯婆婆を実装せよ。

方針

呼び出しは、湯婆婆
LaunchRequestで、"契約書だよ。そこに名前を書きな。"
IntentRequestで、フン・・・

写真

image.png

手順

新しいスキルを作成

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

  • カスタムを選択

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

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

スキルを作成をクリック

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

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

選択をクリック

呼び出し名の登録

  • 湯婆婆

インテントの追加

  • NameIntent

  • " {Name} ",

  • " {Name} です",

  • "名前は {Name} ",

  • "名前は {Name} です"

  • name AMAZON.Person

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

  • https https://***.herokuapp.com/

フロー

image.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","f37951a4.334fe"]]},{"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\": \"フン。{{name}}というのかい。贅沢な名だねぇ。今からお前の名前は、{{newName}}だ。いいかい、{{newName}}だよ。分かったら返事をするんだ、{{newName}}!!\"\n    },\n    \"card\": {\n      \"type\": \"Simple\",\n      \"title\": \"湯婆婆\",\n      \"content\": \"フン。{{name}}というのかい。贅沢な名だねぇ。今からお前の名前は、{{newName}}だ。いいかい、{{newName}}だよ。分かったら返事をするんだ、{{newName}}!!\"\n    },\n    \"reprompt\": {\n      \"outputSpeech\": {\n        \"type\": \"PlainText\",\n        \"text\": \"他にも質問はありますか?\"\n      }\n    },\n    \"shouldEndSession\": false\n  }\n}\n","x":430,"y":240,"wires":[["a3f5d1d3.48456"]]},{"id":"c12a09a5.1fa5b8","type":"function","z":"da568283.b34a7","name":"cut","func":"var name = msg.payload.request.intent.slots.Name.value;\nvar idx = Math.floor(Math.random() * name.length);\nmsg.newName = name.substring(idx, idx + 1);\nmsg.name = name;\nreturn msg;","outputs":1,"noerr":0,"x":270,"y":240,"wires":[["5d09dbfd.0d44d4"]]}]

以上。

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?