Writing Alexa Voice Skills With NodeJS (with a little IoT)
-
Upload
david-janes -
Category
Technology
-
view
573 -
download
0
Transcript of Writing Alexa Voice Skills With NodeJS (with a little IoT)
![Page 1: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/1.jpg)
Writing Alexa Voice Skills With NodeJS(with a little IoT)
![Page 3: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/3.jpg)
Introduction
![Page 4: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/4.jpg)
Important Links
• Alexa Skills Console https://developer.amazon.com/edw/home.html#/skills/list
• Sample Code & Skill https://github.com/dpjanes/homestar-alexa
![Page 5: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/5.jpg)
Topics Covered
• Choosing an Architecture
• Creating a Skill
• Interaction Model
• Skills for the IoT
• Testing your Skill
![Page 6: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/6.jpg)
Emphasis
• We'll focus on core concepts
• Intent, Slots, Utterances
• From definition to implementation
![Page 7: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/7.jpg)
About IOTDB
• Open Source IoT Platform
• Based on Semantics
• Natural fit for voice control
• https://github.com/dpjanes/node-iotdb
![Page 8: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/8.jpg)
Architecture
![Page 9: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/9.jpg)
Many Moving Parts
• Home
• Amazon Echo
• IoT Device
• Iot Controller
• Amazon
• Alexa Voice Skill
• Cloud
• Skill Server
• Vendor Server
• Proxy Server
![Page 10: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/10.jpg)
Typical Alexa Voice Skill(hosted)
![Page 11: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/11.jpg)
Typical Alexa Voice Skill(AWS Lambda)
![Page 12: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/12.jpg)
Cloud Based
![Page 13: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/13.jpg)
Home Based
![Page 14: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/14.jpg)
Proxy Based
![Page 15: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/15.jpg)
This Presentation
• Focus on writing Alexa Voice Skill
• Communications between Cloud and your Home will be "open"
![Page 16: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/16.jpg)
e.g. mainly this
![Page 17: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/17.jpg)
CreatingAlexa Voice Skills
![Page 18: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/18.jpg)
e.g. here
![Page 19: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/19.jpg)
Getting Started
• https://developer.amazon.com/edw/home.html#/skills/list
• Create an Account if you don't have one
• will require SMS verification
• Select "Add a New Skill"
![Page 20: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/20.jpg)
Alexa Skill Editor
![Page 21: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/21.jpg)
Alexa Skill Editor
• We'll focus on
• Skill Information
• Interaction Model
• Configuration
• Test
![Page 22: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/22.jpg)
Skill Editor: Skill Information
![Page 23: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/23.jpg)
Alexa Skill Editor
![Page 24: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/24.jpg)
Creating New Skill: Skill Information
![Page 25: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/25.jpg)
Skill Information: Skill Type
• Different types of Skills
• Custom: the most flexible
• Smart Home Skill: don't have to use the "magic word" (the Invocation Name)
• Flash Briefing: news
![Page 26: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/26.jpg)
Skill Information: Skill Type
• What will appear in your Skills List
• What will appear in the App Store
![Page 27: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/27.jpg)
Skill Information: Invocation Name
• The "Magic Word"
• Alexa, ask HomeStar to …
• Alexa, tell HomeStar to …
• Not needed with Smart Home Skills
![Page 28: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/28.jpg)
Skill Editor:Interaction Model
![Page 29: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/29.jpg)
![Page 30: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/30.jpg)
This is the Cool Part
• The Interaction Model determines how Alexa interprets your voice commands
![Page 31: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/31.jpg)
Interaction Terminology
• Utterances
• Slots
• Intents
![Page 32: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/32.jpg)
Utterances
• Step 1 in writing your Alexa Voice Skill
• Write down things you want to say
• Look for Patterns
![Page 33: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/33.jpg)
Utterances"Ask HomeStar…"
• turn on Stove
• turn off Stove
• turn on Light
• turn on Light in the Kitchen
• turn off TV
• turn off Living Room TV
• turn off everything
• to turn off everything
• to turn off everything in the Living Room
• turn down TV
• turn down TV in the Living Room
![Page 34: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/34.jpg)
Utterances"Ask HomeStar…"
• turn on {Thing}
• turn off {Thing}
• turn on {Thing}
• turn on {Thing} in the Kitchen
• turn off {Thing}
• turn off Living Room {Thing}
• turn off {Thing}
• to turn off {Thing}
• to turn off {Thing} in the Living Room
• turn down {Thing}
![Page 35: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/35.jpg)
Utterances"Ask HomeStar…"
• turn on {Thing}
• turn off {Thing}
• turn on {Thing}
• turn on {Thing} in the {Zone}
• turn off {Thing}
• turn off {Zone} {Thing}
• turn off {Thing}
• to turn off {Thing}
• to turn off {Thing} in the {Zone}
• turn down {Thing}
• turn down {Thing} in the {Zone}
![Page 36: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/36.jpg)
Utterances"Ask HomeStar…"
• {Action} {Thing}
• {Action} {Thing}
• {Action} {Thing}
• {Action} {Thing} in the {Zone}
• {Action} {Thing}
• {Action} {Zone} {Thing}
• {Action} {Thing}
• to {Action} {Thing}
• to {Action} {Thing} in the {Zone}
• {Action} {Thing}
• {Action} {Thing} in the {Zone}
![Page 37: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/37.jpg)
Utterances"Ask HomeStar…"
• {Action} {Thing}
• to {Action} {Thing}
• {Action} {Thing} in the {Zone}
• to {Action} {Thing} in the {Zone}
• {Action} {Zone} {Thing}
• to {Action} {Zone} {Thing}
![Page 38: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/38.jpg)
Slots
• These are the {variables} in the Utterances
• e.g. {Thing}, {Zone}, {Action}
• two types of slots:
• Custom (e.g. above)
• Built-In
![Page 39: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/39.jpg)
Slots (Built-In)
• Date
• Duration
• Four Digit Number
• Number
• Time
• Cities…
![Page 40: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/40.jpg)
Slots {Thing}
• lamp
• light
• coffee maker
• kettle
• stove
• tv…
![Page 41: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/41.jpg)
Slots {Action}
• turn off
• turn on
• turn down
• turn up
• open
• close
![Page 42: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/42.jpg)
Slots {Zone}
• Back Door
• Back Garden
• Back Hall
• Back Porch
• Basement
• Basement Bathroom…
![Page 43: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/43.jpg)
Intents
• Basically, Intents are "phases" of your conversation with Alexa
• If "single shot" then this isn't very complicated - just define a "FirstIntent", e.g. HomeStarFirst Intent
![Page 44: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/44.jpg)
Putting it together
![Page 45: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/45.jpg)
Putting it together
![Page 46: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/46.jpg)
Skill Editor:Configuration
![Page 47: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/47.jpg)
![Page 48: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/48.jpg)
Configuration: Endpoint
• Two (major options)
• AWS Lambda
• Hosted - contacts a url
• Note the URL we are using - we'll see it again soon
![Page 49: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/49.jpg)
Configuration: Account Linking
• Used for connecting to systems that have accounts!
• E.g. Smart Homes - what Smart Home does Alexa have to talk to
• Set up when user connects to Skill
![Page 50: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/50.jpg)
Configuration: Account Linking
• Alexa calls your Authorize URL with a number of parameters
• Let the user do something on your website to confirm it
• Your website redirects back to Alexa with a number of magic parameters
![Page 51: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/51.jpg)
Alexa Skill Endpoint /Your Server
![Page 52: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/52.jpg)
e.g. here
![Page 53: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/53.jpg)
Sample Code
• url: https://github.com/dpjanes/homestar-alexa/
• ./hosted/monitor_1.js
![Page 54: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/54.jpg)
N.B.
• Alexa Skill is configured to hit https://alexa.homestar.io/request
• You must use HTTPS
• Amazon provides flexibility in certs
![Page 55: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/55.jpg)
Sample Code (1)
![Page 56: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/56.jpg)
Demo (1)"monitor_1.js"
![Page 57: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/57.jpg)
The Request
![Page 58: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/58.jpg)
The Request
• "session"
• a session of interactions (captured in Intents) between user and Alexa
• user login info (from Account Linking)
• "request"
• the Intent and Slot data
![Page 59: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/59.jpg)
The Request"session"
![Page 60: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/60.jpg)
The Request"session"
• "new": we can be continuing a session
• "sessionId": in case you are, for logging
• "user": all this is set up by Account Linking
• not required if just for yourself
![Page 61: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/61.jpg)
The Request"request"
![Page 62: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/62.jpg)
The Request"request"
• "type"
• "locale"
• "intent"
![Page 63: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/63.jpg)
The Request"request/intent"
• "name"
• "slots"
• Action / Query / Zone / Thing
• We defined these!
![Page 64: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/64.jpg)
The Request"request/intent"
• "request/intent/slots/Action/value": the {{ Action }}
• "request/intent/slots/Thing/value": the {{ Thing }}
![Page 65: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/65.jpg)
The Response
![Page 66: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/66.jpg)
The Response
• "response/outputSpeech/text": this is what Alexa will say to the user
• "response/shouldEndSession": make false if you want to keep going
![Page 67: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/67.jpg)
Sample Code (II)
![Page 68: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/68.jpg)
Demo (II)"monitor_2.js"
![Page 69: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/69.jpg)
Skill Editor: Test
![Page 70: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/70.jpg)
Test
![Page 71: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/71.jpg)
Going Further
![Page 72: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/72.jpg)
IOTDB
• NPM modules
• iotdb
• homestar
• iotdb-commands
• takes Action / Thing / &c and does it
![Page 73: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/73.jpg)
Demo (III)live
![Page 74: Writing Alexa Voice Skills With NodeJS (with a little IoT)](https://reader031.fdocuments.in/reader031/viewer/2022030317/586fb3f41a28abe57d8b6ee1/html5/thumbnails/74.jpg)
Get in touch! David Janes
http://iotdb.org/social/imadeit/