SlideShare a Scribd company logo
1 of 37
Download to read offline
Developing skills for Amazon Echo
Mainz, 26.01.2017
Moritz Kammerer
About the author
2
● 2016 Supervised bachelor thesis about NUIs
● 2016 Developed customer project with Amazon Echo
● GitHub: @phxql / Twitter: @phxql
● Blog: https://www.mkammerer.de/blog
● Sourcecode: https://github.com/qaware/iot-hessen-amazon-echo
What is a Amazon Echo?
3
● Digital assistent from Amazon
● Provides an audio interface
● https://www.youtube.com/watch?v=KkOCeAtKHIc
What’s the cool thing?
4
● Alexa has built-in features: weather, facts, news, music, …
● And it is also extensible via so called skills
● In this talk: We develop a skill for warehouse management
Demo
5
● Utterances:
○ “Wie viele Schrauben haben wir noch?”
○ “Bestelle mir neue Schrauben”
○ “In welchem Regal befinden sich die Schrauben?”
How does that work?
6
● Register the skill in the Amazon Skill Store
● Develop an application with a HTTP interface
● Enable the skill on your Echo
Okay, but how does that really work?
7
Echo
Amazon Cloud Your service
Natural Language
HTTPS / JSON
Develop a skill, step by step. Step 1.
8
● Create a new skill: Amazon Developer Console / Alexa / Alexa Skill Kit [7]
Skill types
9
● SmartHome Skill API: Switch on/off lamps, control heating
● Flash Briefing Skill API: News as audio or text feed
● Custom Interaction Model: Define own utterances, most flexible
○ That’s what we will use
Develop a skill, step by step. Step 2.
10
What are intents?
11
● “an intent represents an action that fulfills a user’s spoken request”
● Intent schema is a JSON formatted list of intents
{
"intent": "QueryInventory",
"slots": [
{
"name": "ware",
"type": "LIST_OF_WARES"
}
]
}
Slots (parameter) of the intent
Slot type
Intents of our skill
12
● QueryInventory (ware): Determine how many of a ware is in the warehouse
● OrderWare (ware): Orders a new ware
● LocateWare (ware): Find a ware in the warehouse
● Quit (): Aborts the conversation
Intent slot types
13
Attention: Alexa tries to match the spoken word to this list, but other values can still be sent to the skill!
Hint: There are predefined slots, e.g. for dates, durations, time, etc.: [1]
Utterances - Combine intents with audio commands
14
Intent name
Command from the user
Slot name
Hint: Best practices and a handbook for the utterances design: [2], [3]
Skill configuration
15
HTTPS endpoint
of our skill
You can also use AWS Lambda for your service
OAuth2 link to an
non-Amazon account
SSL configuration
16
Skill configured, time for some code!
17
● We create a Spring Boot application for our service
● Open Spring Initializr [6], dependencies: only web
● Add the Alexa Skills Kit for Java [4] to the Maven POM:
<dependency>
<groupId>com.amazon.alexa</groupId>
<artifactId>alexa-skills-kit</artifactId>
<version>1.2</version>
</dependency>
Implement the Speechlet
18
com.amazon.speech.speechlet.SpeechletV2
● void onSessionStarted(...)
○ Gets called when a session is started
● SpeechletResponse onLaunch(...)
○ Gets called when the user starts a conversation
● SpeechletResponse onIntent(...)
○ Gets called when the user invokes an intent
● void onSessionEnded(...)
○ Gets called when the session is ended
Our speechlet implementation
19
● onSessionStarted: not needed
● onLaunch:
○ When called, user wants a conversation. Set a session flag:
requestEnvelope.getSession().setAttribute("conversation", "true");
○ When not called, user wants a one-shot intent
● onSessionEnded: not needed
The skill logic resides in onIntent
20
● onIntent: read the intent name and handle the intent
Intent intent = requestEnvelope.getRequest().getIntent();
switch (intent.getName()) {
case "QueryInventory":
return handleQueryInventory(requestEnvelope);
…
}
QueryInventory intent handling
21
● Read slot “ware”:
Slot wareSlot = intent.getSlot("ware");
String ware = wareSlot == null ? null : wareSlot.getValue();
QueryInventory intent handling
22
● If ware is missing from the intent (ware == null), tell the user.
● If in conversation mode, let the user retry:
○ return SpeechletResponse.newAskResponse(new PlainTextOutputSpeech("Ich
habe die Ware nicht verstanden. Was möchten Sie tun?"),
new Reprompt(...));
● If not in conversation mode (one-shot intent)
○ return SpeechletResponse.newTellResponse(new PlainTextOutputSpeech("Ich
habe die Ware nicht verstanden."));
SSML [5] is also supported
If the user doesn’t answer the quesion, this
text is spoken.
QueryInventory intent handling
23
● Now find the ware amount:
int amount = warehouseService.getAmount(ware.get());
● And create a response to the user:
return SpeechletResponse.newTellResponse(new PlainTextOutputSpeech(
String.format("Es sind noch %d %s im Lager.", amount, ware)
));
One-shot flow
24
Conversation flow
25
Wire the speechlet into Spring Boot
26
@Bean
public ServletRegistrationBean alexaServlet(WarehouseSpeechlet speechlet) {
SpeechletServlet speechServlet = new SpeechletServlet();
speechServlet.setSpeechlet(speechlet);
ServletRegistrationBean servlet = new ServletRegistrationBean(speechServlet, "/alexa");
servlet.setName("alexa");
return servlet;
}
Speechlet will answer on /alexa
Set speechlet properties
27
// Disable signature checks for development
System.setProperty(Sdk.DISABLE_REQUEST_SIGNATURE_CHECK_SYSTEM_PROPERTY, "true");
// Allow all application ids for development
System.setProperty(Sdk.SUPPORTED_APPLICATION_IDS_SYSTEM_PROPERTY, "");
// Disable timestamp verification for development
System.setProperty(Sdk.TIMESTAMP_TOLERANCE_SYSTEM_PROPERTY, "");
For production you’ll find this ID in the “Skill Information” section
Skill implemented, how to test it?
28
This request gets
sent to the skill
service
Enter text here
Hint: Copy the JSON and POST it with your preferred tool (curl, Postman, etc.) to /alexa
And now with voice...
29
● Amazon forces you to use SSL
● So... configure Spring Boot to use SSL
○ Create a new keystore
○ Create a new keypair, the CN must be set to your servers DNS name
○ Enable SSL in Spring Boot:
server.port: 443
server.ssl.key-store: classpath:keystore.jks
server.ssl.key-store-password: ""
server.ssl.key-store-type: jks
server.ssl.key-alias: ec2-35-157-19-115.eu-central-1.compute.amazonaws.com
And now with voice...
30
● Export the SSL certificate as X.509 (starts with -----BEGIN CERTIFICATE-----)
● Paste the X.509 certificate in the skill configuration under “SSL Certificate”
● Build the Spring boot application
● Upload the application to a publicly accessible server (e.g. EC2)
● Start the application
● Add your Alexa to the account which created the skill
● Enable the skill in the Alexa App
● Now you can invoke the skill
What I wish I knew
31
● TLS: Must be port 443, the CN in the certificate must match the DNS
● Slot types are not enums, but only recommendations for the speech recognition
● Slots can be null! (e.g. “Bestelle mir neue “)
● The user id is changing when the user removes and re-adds the skill
● Alexa Skill Kit for Java: Exclude log4j and slf4j-log4j12
● When testing the skill, use the Alexa Mobile App: The cards contain useful debug information
● Implement local and test with voice: Use SSH remote port forwarding:
ssh -R 443:localhost:8443 root@server
What have we learned?
32
● Develop an interaction model:
○ Intents, slots and slot types
○ Utterances
● To use the Alexa Skills Kit and implement the SpeechletV2 interface
○ When onSessionStarted(), onLaunch(), onIntent() and onSessionEnded() are called
○ What the difference between newAskResponse() and newTellResponse() is
● How to beat TLS
Conclusion
33
● Pro:
○ Echo can be extended with custom skills
○ Skills are very flexible
○ The Alexa Skills Kit abstracts all the request and response handling
○ Amazon handles the speech-to-text and text-to-speech
● Contra:
○ No semantic analysis, just matching the utterances exactly
○ Have to invoke the skill by saying, “Alexa, tell [skill] …”
○ TLS is very annoying (and badly documented) when developing a skill
34
https://github.com/qaware/iot-hessen-amazon-echo
Source Code:
References
35
● [1] https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference
● [2] https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-voice-design-best-practices
● [3] https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-voice-design-handbook
● [4] https://github.com/amzn/alexa-skills-kit-java
● [5] https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference
● [6] http://start.spring.io/
● [7] https://developer.amazon.com/edw/home.html#/skills/list
Appendix
36
Timings
37

More Related Content

What's hot

Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and servers
Tatsuhiko Miyagawa
 

What's hot (20)

Lambdaless and AWS CDK
Lambdaless and AWS CDKLambdaless and AWS CDK
Lambdaless and AWS CDK
 
Amazon API Gateway
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
 
Everything-as-code. A polyglot journey.
Everything-as-code. A polyglot journey.Everything-as-code. A polyglot journey.
Everything-as-code. A polyglot journey.
 
Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015Paws - Perl AWS SDK Update - November 2015
Paws - Perl AWS SDK Update - November 2015
 
Building a chatbot – step by step
Building a chatbot – step by stepBuilding a chatbot – step by step
Building a chatbot – step by step
 
AWS July Webinar Series: Overview: Build and Manage your APIs with Amazon API...
AWS July Webinar Series: Overview: Build and Manage your APIs with Amazon API...AWS July Webinar Series: Overview: Build and Manage your APIs with Amazon API...
AWS July Webinar Series: Overview: Build and Manage your APIs with Amazon API...
 
Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014Building an aws sdk for Perl - Granada Perl Workshop 2014
Building an aws sdk for Perl - Granada Perl Workshop 2014
 
Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)Using PHP Functions! (Not those functions, Google Cloud Functions)
Using PHP Functions! (Not those functions, Google Cloud Functions)
 
Killer Docker Workflows for Development
Killer Docker Workflows for DevelopmentKiller Docker Workflows for Development
Killer Docker Workflows for Development
 
Serverless in production, an experience report (London DevOps)
Serverless in production, an experience report (London DevOps)Serverless in production, an experience report (London DevOps)
Serverless in production, an experience report (London DevOps)
 
Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)Serverless in production, an experience report (FullStack 2018)
Serverless in production, an experience report (FullStack 2018)
 
Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)Serverless in Production, an experience report (AWS UG South Wales)
Serverless in Production, an experience report (AWS UG South Wales)
 
Paws - A Perl AWS SDK
Paws - A Perl AWS SDKPaws - A Perl AWS SDK
Paws - A Perl AWS SDK
 
Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018Docker for Developers - PHP Detroit 2018
Docker for Developers - PHP Detroit 2018
 
Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
 
Containerizing your Security Operations Center
Containerizing your Security Operations CenterContainerizing your Security Operations Center
Containerizing your Security Operations Center
 
Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)
 
Amazon API Gateway
Amazon API GatewayAmazon API Gateway
Amazon API Gateway
 
Plack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and serversPlack perl superglue for web frameworks and servers
Plack perl superglue for web frameworks and servers
 
Build and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API GatewayBuild and Manage Your APIs with Amazon API Gateway
Build and Manage Your APIs with Amazon API Gateway
 

Viewers also liked

Secure Architecture and Programming 101
Secure Architecture and Programming 101Secure Architecture and Programming 101
Secure Architecture and Programming 101
QAware GmbH
 

Viewers also liked (20)

Per Anhalter durch den Cloud Native Stack (extended edition)
Per Anhalter durch den Cloud Native Stack (extended edition)Per Anhalter durch den Cloud Native Stack (extended edition)
Per Anhalter durch den Cloud Native Stack (extended edition)
 
Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.
Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.
Everything-as-code. Polyglotte Software-Entwicklung in der Praxis.
 
Secure Architecture and Programming 101
Secure Architecture and Programming 101Secure Architecture and Programming 101
Secure Architecture and Programming 101
 
Der Cloud Native Stack in a Nutshell
Der Cloud Native Stack in a NutshellDer Cloud Native Stack in a Nutshell
Der Cloud Native Stack in a Nutshell
 
Azure Functions - Get rid of your servers, use functions!
Azure Functions - Get rid of your servers, use functions!Azure Functions - Get rid of your servers, use functions!
Azure Functions - Get rid of your servers, use functions!
 
Introduction to building alexa skills and putting your amazon echo to work
Introduction to building alexa skills and putting your amazon echo to workIntroduction to building alexa skills and putting your amazon echo to work
Introduction to building alexa skills and putting your amazon echo to work
 
Lightweight developer provisioning with gradle and seu as-code
Lightweight developer provisioning with gradle and seu as-codeLightweight developer provisioning with gradle and seu as-code
Lightweight developer provisioning with gradle and seu as-code
 
JEE on DC/OS - MesosCon Europe
JEE on DC/OS - MesosCon EuropeJEE on DC/OS - MesosCon Europe
JEE on DC/OS - MesosCon Europe
 
Microservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing MicroservicesMicroservices @ Work - A Practice Report of Developing Microservices
Microservices @ Work - A Practice Report of Developing Microservices
 
Leveraging the Power of Solr with Spark
Leveraging the Power of Solr with SparkLeveraging the Power of Solr with Spark
Leveraging the Power of Solr with Spark
 
Automotive Information Research driven by Apache Solr
Automotive Information Research driven by Apache SolrAutomotive Information Research driven by Apache Solr
Automotive Information Research driven by Apache Solr
 
Automotive Information Research driven by Apache Solr
Automotive Information Research driven by Apache SolrAutomotive Information Research driven by Apache Solr
Automotive Information Research driven by Apache Solr
 
Vamp - The anti-fragilitiy platform for digital services
Vamp - The anti-fragilitiy platform for digital servicesVamp - The anti-fragilitiy platform for digital services
Vamp - The anti-fragilitiy platform for digital services
 
A Hitchhiker's Guide to the Cloud Native Stack
A Hitchhiker's Guide to the Cloud Native StackA Hitchhiker's Guide to the Cloud Native Stack
A Hitchhiker's Guide to the Cloud Native Stack
 
Chronix as Long-Term Storage for Prometheus
Chronix as Long-Term Storage for PrometheusChronix as Long-Term Storage for Prometheus
Chronix as Long-Term Storage for Prometheus
 
Amazon Echo
Amazon EchoAmazon Echo
Amazon Echo
 
Please meet Amazon Alexa and the Alexa Skills Kit
Please meet Amazon Alexa and the Alexa Skills KitPlease meet Amazon Alexa and the Alexa Skills Kit
Please meet Amazon Alexa and the Alexa Skills Kit
 
Project6
Project6Project6
Project6
 
GOOGLE's Thoughts from the RetailOasis BIG Breakfast
GOOGLE's Thoughts from the RetailOasis BIG BreakfastGOOGLE's Thoughts from the RetailOasis BIG Breakfast
GOOGLE's Thoughts from the RetailOasis BIG Breakfast
 
Is technology the real game changer?
Is technology the real game changer?Is technology the real game changer?
Is technology the real game changer?
 

Similar to Developing Skills for Amazon Echo

Who needs containers in a serverless world
Who needs containers in a serverless worldWho needs containers in a serverless world
Who needs containers in a serverless world
Matthias Luebken
 

Similar to Developing Skills for Amazon Echo (20)

Who needs containers in a serverless world
Who needs containers in a serverless worldWho needs containers in a serverless world
Who needs containers in a serverless world
 
Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017
Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017
Building a Slack Bot Workshop @ Nearsoft OctoberTalks 2017
 
Fullstack workshop
Fullstack workshopFullstack workshop
Fullstack workshop
 
2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
Bsides tampa
Bsides tampaBsides tampa
Bsides tampa
 
Hands-on Lab: Red Hat Container Development & OpenShift
Hands-on Lab: Red Hat Container Development & OpenShiftHands-on Lab: Red Hat Container Development & OpenShift
Hands-on Lab: Red Hat Container Development & OpenShift
 
AWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp VaultAWS DevOps - Terraform, Docker, HashiCorp Vault
AWS DevOps - Terraform, Docker, HashiCorp Vault
 
Building an Empire with PowerShell
Building an Empire with PowerShellBuilding an Empire with PowerShell
Building an Empire with PowerShell
 
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides:  Let's build macOS CLI Utilities using SwiftMobileConf 2021 Slides:  Let's build macOS CLI Utilities using Swift
MobileConf 2021 Slides: Let's build macOS CLI Utilities using Swift
 
Free Mongo on OpenShift
Free Mongo on OpenShiftFree Mongo on OpenShift
Free Mongo on OpenShift
 
The State of the Veil Framework
The State of the Veil FrameworkThe State of the Veil Framework
The State of the Veil Framework
 
Wattpad - Spark Stories
Wattpad - Spark StoriesWattpad - Spark Stories
Wattpad - Spark Stories
 
Campus HTC at #TechEX15
Campus HTC at #TechEX15Campus HTC at #TechEX15
Campus HTC at #TechEX15
 
PowerShell for Penetration Testers
PowerShell for Penetration TestersPowerShell for Penetration Testers
PowerShell for Penetration Testers
 
ansible_rhel.pdf
ansible_rhel.pdfansible_rhel.pdf
ansible_rhel.pdf
 
DEF CON 27 - JOSHUA MADDUX - api induced ssrf
DEF CON 27 - JOSHUA MADDUX - api induced ssrfDEF CON 27 - JOSHUA MADDUX - api induced ssrf
DEF CON 27 - JOSHUA MADDUX - api induced ssrf
 
Managing AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormationManaging AWS infrastructure using CloudFormation
Managing AWS infrastructure using CloudFormation
 
[CB19] API-induced SSRF: How Apple Pay Scattered Vulnerabilities Across the W...
[CB19] API-induced SSRF: How Apple Pay Scattered Vulnerabilities Across the W...[CB19] API-induced SSRF: How Apple Pay Scattered Vulnerabilities Across the W...
[CB19] API-induced SSRF: How Apple Pay Scattered Vulnerabilities Across the W...
 
Build Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPCBuild Great Networked APIs with Swift, OpenAPI, and gRPC
Build Great Networked APIs with Swift, OpenAPI, and gRPC
 

More from QAware GmbH

"Mixed" Scrum-Teams – Die richtige Mischung macht's!
"Mixed" Scrum-Teams – Die richtige Mischung macht's!"Mixed" Scrum-Teams – Die richtige Mischung macht's!
"Mixed" Scrum-Teams – Die richtige Mischung macht's!
QAware GmbH
 
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
 Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
QAware GmbH
 

More from QAware GmbH (20)

50 Shades of K8s Autoscaling #JavaLand24.pdf
50 Shades of K8s Autoscaling #JavaLand24.pdf50 Shades of K8s Autoscaling #JavaLand24.pdf
50 Shades of K8s Autoscaling #JavaLand24.pdf
 
Make Agile Great - PM-Erfahrungen aus zwei virtuellen internationalen SAFe-Pr...
Make Agile Great - PM-Erfahrungen aus zwei virtuellen internationalen SAFe-Pr...Make Agile Great - PM-Erfahrungen aus zwei virtuellen internationalen SAFe-Pr...
Make Agile Great - PM-Erfahrungen aus zwei virtuellen internationalen SAFe-Pr...
 
Fully-managed Cloud-native Databases: The path to indefinite scale @ CNN Mainz
Fully-managed Cloud-native Databases: The path to indefinite scale @ CNN MainzFully-managed Cloud-native Databases: The path to indefinite scale @ CNN Mainz
Fully-managed Cloud-native Databases: The path to indefinite scale @ CNN Mainz
 
Down the Ivory Tower towards Agile Architecture
Down the Ivory Tower towards Agile ArchitectureDown the Ivory Tower towards Agile Architecture
Down the Ivory Tower towards Agile Architecture
 
"Mixed" Scrum-Teams – Die richtige Mischung macht's!
"Mixed" Scrum-Teams – Die richtige Mischung macht's!"Mixed" Scrum-Teams – Die richtige Mischung macht's!
"Mixed" Scrum-Teams – Die richtige Mischung macht's!
 
Make Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform EngineeringMake Developers Fly: Principles for Platform Engineering
Make Developers Fly: Principles for Platform Engineering
 
Der Tod der Testpyramide? – Frontend-Testing mit Playwright
Der Tod der Testpyramide? – Frontend-Testing mit PlaywrightDer Tod der Testpyramide? – Frontend-Testing mit Playwright
Der Tod der Testpyramide? – Frontend-Testing mit Playwright
 
Was kommt nach den SPAs
Was kommt nach den SPAsWas kommt nach den SPAs
Was kommt nach den SPAs
 
Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo Cloud Migration mit KI: der Turbo
Cloud Migration mit KI: der Turbo
 
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
 Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See... Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
Migration von stark regulierten Anwendungen in die Cloud: Dem Teufel die See...
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
 
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
Endlich gute API Tests. Boldly Testing APIs Where No One Has Tested Before.
 
Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!Kubernetes with Cilium in AWS - Experience Report!
Kubernetes with Cilium in AWS - Experience Report!
 
50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling
 
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAPKontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
Kontinuierliche Sicherheitstests für APIs mit Testkube und OWASP ZAP
 
Service Mesh Pain & Gain. Experiences from a client project.
Service Mesh Pain & Gain. Experiences from a client project.Service Mesh Pain & Gain. Experiences from a client project.
Service Mesh Pain & Gain. Experiences from a client project.
 
50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling50 Shades of K8s Autoscaling
50 Shades of K8s Autoscaling
 
Blue turns green! Approaches and technologies for sustainable K8s clusters.
Blue turns green! Approaches and technologies for sustainable K8s clusters.Blue turns green! Approaches and technologies for sustainable K8s clusters.
Blue turns green! Approaches and technologies for sustainable K8s clusters.
 
Per Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API GatewaysPer Anhalter zu Cloud Nativen API Gateways
Per Anhalter zu Cloud Nativen API Gateways
 
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
Aus blau wird grün! Ansätze und Technologien für nachhaltige Kubernetes-Cluster
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 

Developing Skills for Amazon Echo

  • 1. Developing skills for Amazon Echo Mainz, 26.01.2017 Moritz Kammerer
  • 2. About the author 2 ● 2016 Supervised bachelor thesis about NUIs ● 2016 Developed customer project with Amazon Echo ● GitHub: @phxql / Twitter: @phxql ● Blog: https://www.mkammerer.de/blog ● Sourcecode: https://github.com/qaware/iot-hessen-amazon-echo
  • 3. What is a Amazon Echo? 3 ● Digital assistent from Amazon ● Provides an audio interface ● https://www.youtube.com/watch?v=KkOCeAtKHIc
  • 4. What’s the cool thing? 4 ● Alexa has built-in features: weather, facts, news, music, … ● And it is also extensible via so called skills ● In this talk: We develop a skill for warehouse management
  • 5. Demo 5 ● Utterances: ○ “Wie viele Schrauben haben wir noch?” ○ “Bestelle mir neue Schrauben” ○ “In welchem Regal befinden sich die Schrauben?”
  • 6. How does that work? 6 ● Register the skill in the Amazon Skill Store ● Develop an application with a HTTP interface ● Enable the skill on your Echo
  • 7. Okay, but how does that really work? 7 Echo Amazon Cloud Your service Natural Language HTTPS / JSON
  • 8. Develop a skill, step by step. Step 1. 8 ● Create a new skill: Amazon Developer Console / Alexa / Alexa Skill Kit [7]
  • 9. Skill types 9 ● SmartHome Skill API: Switch on/off lamps, control heating ● Flash Briefing Skill API: News as audio or text feed ● Custom Interaction Model: Define own utterances, most flexible ○ That’s what we will use
  • 10. Develop a skill, step by step. Step 2. 10
  • 11. What are intents? 11 ● “an intent represents an action that fulfills a user’s spoken request” ● Intent schema is a JSON formatted list of intents { "intent": "QueryInventory", "slots": [ { "name": "ware", "type": "LIST_OF_WARES" } ] } Slots (parameter) of the intent Slot type
  • 12. Intents of our skill 12 ● QueryInventory (ware): Determine how many of a ware is in the warehouse ● OrderWare (ware): Orders a new ware ● LocateWare (ware): Find a ware in the warehouse ● Quit (): Aborts the conversation
  • 13. Intent slot types 13 Attention: Alexa tries to match the spoken word to this list, but other values can still be sent to the skill! Hint: There are predefined slots, e.g. for dates, durations, time, etc.: [1]
  • 14. Utterances - Combine intents with audio commands 14 Intent name Command from the user Slot name Hint: Best practices and a handbook for the utterances design: [2], [3]
  • 15. Skill configuration 15 HTTPS endpoint of our skill You can also use AWS Lambda for your service OAuth2 link to an non-Amazon account
  • 17. Skill configured, time for some code! 17 ● We create a Spring Boot application for our service ● Open Spring Initializr [6], dependencies: only web ● Add the Alexa Skills Kit for Java [4] to the Maven POM: <dependency> <groupId>com.amazon.alexa</groupId> <artifactId>alexa-skills-kit</artifactId> <version>1.2</version> </dependency>
  • 18. Implement the Speechlet 18 com.amazon.speech.speechlet.SpeechletV2 ● void onSessionStarted(...) ○ Gets called when a session is started ● SpeechletResponse onLaunch(...) ○ Gets called when the user starts a conversation ● SpeechletResponse onIntent(...) ○ Gets called when the user invokes an intent ● void onSessionEnded(...) ○ Gets called when the session is ended
  • 19. Our speechlet implementation 19 ● onSessionStarted: not needed ● onLaunch: ○ When called, user wants a conversation. Set a session flag: requestEnvelope.getSession().setAttribute("conversation", "true"); ○ When not called, user wants a one-shot intent ● onSessionEnded: not needed
  • 20. The skill logic resides in onIntent 20 ● onIntent: read the intent name and handle the intent Intent intent = requestEnvelope.getRequest().getIntent(); switch (intent.getName()) { case "QueryInventory": return handleQueryInventory(requestEnvelope); … }
  • 21. QueryInventory intent handling 21 ● Read slot “ware”: Slot wareSlot = intent.getSlot("ware"); String ware = wareSlot == null ? null : wareSlot.getValue();
  • 22. QueryInventory intent handling 22 ● If ware is missing from the intent (ware == null), tell the user. ● If in conversation mode, let the user retry: ○ return SpeechletResponse.newAskResponse(new PlainTextOutputSpeech("Ich habe die Ware nicht verstanden. Was möchten Sie tun?"), new Reprompt(...)); ● If not in conversation mode (one-shot intent) ○ return SpeechletResponse.newTellResponse(new PlainTextOutputSpeech("Ich habe die Ware nicht verstanden.")); SSML [5] is also supported If the user doesn’t answer the quesion, this text is spoken.
  • 23. QueryInventory intent handling 23 ● Now find the ware amount: int amount = warehouseService.getAmount(ware.get()); ● And create a response to the user: return SpeechletResponse.newTellResponse(new PlainTextOutputSpeech( String.format("Es sind noch %d %s im Lager.", amount, ware) ));
  • 26. Wire the speechlet into Spring Boot 26 @Bean public ServletRegistrationBean alexaServlet(WarehouseSpeechlet speechlet) { SpeechletServlet speechServlet = new SpeechletServlet(); speechServlet.setSpeechlet(speechlet); ServletRegistrationBean servlet = new ServletRegistrationBean(speechServlet, "/alexa"); servlet.setName("alexa"); return servlet; } Speechlet will answer on /alexa
  • 27. Set speechlet properties 27 // Disable signature checks for development System.setProperty(Sdk.DISABLE_REQUEST_SIGNATURE_CHECK_SYSTEM_PROPERTY, "true"); // Allow all application ids for development System.setProperty(Sdk.SUPPORTED_APPLICATION_IDS_SYSTEM_PROPERTY, ""); // Disable timestamp verification for development System.setProperty(Sdk.TIMESTAMP_TOLERANCE_SYSTEM_PROPERTY, ""); For production you’ll find this ID in the “Skill Information” section
  • 28. Skill implemented, how to test it? 28 This request gets sent to the skill service Enter text here Hint: Copy the JSON and POST it with your preferred tool (curl, Postman, etc.) to /alexa
  • 29. And now with voice... 29 ● Amazon forces you to use SSL ● So... configure Spring Boot to use SSL ○ Create a new keystore ○ Create a new keypair, the CN must be set to your servers DNS name ○ Enable SSL in Spring Boot: server.port: 443 server.ssl.key-store: classpath:keystore.jks server.ssl.key-store-password: "" server.ssl.key-store-type: jks server.ssl.key-alias: ec2-35-157-19-115.eu-central-1.compute.amazonaws.com
  • 30. And now with voice... 30 ● Export the SSL certificate as X.509 (starts with -----BEGIN CERTIFICATE-----) ● Paste the X.509 certificate in the skill configuration under “SSL Certificate” ● Build the Spring boot application ● Upload the application to a publicly accessible server (e.g. EC2) ● Start the application ● Add your Alexa to the account which created the skill ● Enable the skill in the Alexa App ● Now you can invoke the skill
  • 31. What I wish I knew 31 ● TLS: Must be port 443, the CN in the certificate must match the DNS ● Slot types are not enums, but only recommendations for the speech recognition ● Slots can be null! (e.g. “Bestelle mir neue “) ● The user id is changing when the user removes and re-adds the skill ● Alexa Skill Kit for Java: Exclude log4j and slf4j-log4j12 ● When testing the skill, use the Alexa Mobile App: The cards contain useful debug information ● Implement local and test with voice: Use SSH remote port forwarding: ssh -R 443:localhost:8443 root@server
  • 32. What have we learned? 32 ● Develop an interaction model: ○ Intents, slots and slot types ○ Utterances ● To use the Alexa Skills Kit and implement the SpeechletV2 interface ○ When onSessionStarted(), onLaunch(), onIntent() and onSessionEnded() are called ○ What the difference between newAskResponse() and newTellResponse() is ● How to beat TLS
  • 33. Conclusion 33 ● Pro: ○ Echo can be extended with custom skills ○ Skills are very flexible ○ The Alexa Skills Kit abstracts all the request and response handling ○ Amazon handles the speech-to-text and text-to-speech ● Contra: ○ No semantic analysis, just matching the utterances exactly ○ Have to invoke the skill by saying, “Alexa, tell [skill] …” ○ TLS is very annoying (and badly documented) when developing a skill
  • 35. References 35 ● [1] https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/built-in-intent-ref/slot-type-reference ● [2] https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-voice-design-best-practices ● [3] https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-voice-design-handbook ● [4] https://github.com/amzn/alexa-skills-kit-java ● [5] https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/speech-synthesis-markup-language-ssml-reference ● [6] http://start.spring.io/ ● [7] https://developer.amazon.com/edw/home.html#/skills/list