Fot. http://www.thecinessential.com/aliens-terminator-2-future/
.NET, Alexa and me
Perfect voice assistant for .NET dev?
Rafał Hryniewski Amazon Alexa
Alexa ...
... and Rafał Hryniewski
@r_hryniewskifb.me/hryniewskinet
Agenda
• We’ve met
• Short history of voice recognition
• Here and now
• Why Alexa?
• First contact
• Working with voice
• Session, dialogs and other tools
• Where’s money in that
• Connecting with existing solution
History
Fot. https://en.wikipedia.org/wiki/Star_Wars_opening_crawl
Long time ago in sci-fi realm
Fot. https://www.flickr.com/photos/ikrichter/20355251321
1922 – Radio Rex
• Recognized it’s name
Fot. https://www-03.ibm.com/ibm/history/exhibits/specialprod1/specialprod1_7.html
1961 – IBM Shoebox
• Recognized 16 words (‘plus’,
‘minus’ etc.) and digits.
• Basically voice controlled
calculator
• IBM demonstration:
https://www.youtube.com/wat
ch?v=rQco1sa9AwU
Fot. https://www-03.ibm.com/ibm/history/exhibits/specialprod1/specialprod1_7.html
Few others
• 1976 – DARPA’s Harpy – Recognized 1011 words
• 1990 – Dragon Dictate – Recognized 5000, allowed for
controlling PC with voice
• 2003 – Voice Recognition for Office XP
2011 - Apple Siri 2012 - Google Now
2014 - Microsoft Cortana 2014 - Amazon Alexa
Platforms today
• Alexa
• Siri
• Cortana
• Google Now
• Others
https://en.wikipedia.org/wiki/Category:Virtual_assistants
Why Alexa?
• Jakis obrazek
Fot. http://hdw.eweb4.com/wallpapers/4257/
Devices
Siri Google Now Cortana Alexa
Apple Home
Pod
Google Home
Mini
Harman Cardon
Invoke
Echo Dot
349$ 49$ 99$ 49$
Apple Siri
• Programming only in Swift
and Objective-C
• Expensive and not very good
device
Fot. https://giphy.com/gifs/no-cat-nR4L10XlJcSeQ
Google Now
• I’m not familiar with Android
Environment
Fot. https://giphy.com/gifs/W5YVAfSttCqre
Microsoft Cortana
• No devices by Microsoft
• I’ve trusted them with
Windows Phone before
Fot. https://giphy.com/gifs/reaction-imgfave-RddAJiGxTPQFa
Amazon Alexa
• I could use C#
• Cloud based
• Easy integration with any
existing app
• A lot of devices
• Growing platform
Fot. https://giphy.com/gifs/people-hd-gifsremastered-10Jpr9KSaXLchW
Other Devices
Echo Echo Plus Echo Spot Echo Show
Better sound
quality
Built-in smart
home hub
Small display Better display
and sound
99$ 150$ 130$ 230$
And Echo Look
• 200$
• Take pictures and videos using voice
commands
• Allows to categorize your wardrobe!
• Gives fashion advice based on machine
learning!!!
Fashion advice. Machine learning.
Fot. https://giphy.com/gifs/whoa-hd-tim-and-eric-xT0xeJpnrWC4XWblEk
Where do we start?
https://memegenerator.net
You need two things
• Amazon Developer Account -
https://developer.amazon.com
• AWS Account if you’re going to use AWS Lambda -
https://aws.amazon.com
• Hosting for your HTTPS endpoint if you’re not going to use AWS
Lambda
Endpoints
• AWS Lambda
• Any HTTPS endpoint
Nope, you don’t need device to start
Fot. memegenerator.net
Let’s create a skill
Fot. memegenerator.net
Alexa Skill Console
Choosing Base Model
Managing Alexa Skill
Required Steps Checklist
Creating AWS Lambda Endpoint
Configuring AWS Lambda Endpoint
Configuring AWS Lambda Endpoint
.NET Tooling
• Alexa.NET - https://github.com/timheuer/alexa-skills-dotnet
• AlexaSkillsKit.NET -
https://github.com/AreYouFreeBusy/AlexaSkillsKit.NET
Visual Studio Project with Alexa.NET
public async Task<SkillResponse> FunctionHandler(SkillRequest input, ILambdaContext
context) {
switch (input.Request) {
case LaunchRequest r:
return ResponseBuilder.Tell("You've launched your skill");
case IntentRequest r when r.Intent.Name == "MyIntent":
return ResponseBuilder.Tell("You've requested 'MyIntent'");
case IntentRequest r when r.Intent.Name == BuiltInIntent.Cancel:
return ResponseBuilder.Tell("You've requested 'Cancel'");
case IntentRequest r when r.Intent.Name == BuiltInIntent.Stop:
return ResponseBuilder.Tell("You've requested 'Cancel'");
case IntentRequest r when r.Intent.Name == BuiltInIntent.Help:
return ResponseBuilder.Tell("You've requested 'Help'");
default:
return ResponseBuilder.Tell("I don't know what you mean.");
}}
Ready to start project available on my repo
github.com/r-hryniewski/Alexa.NET-TalkDemo/tree/template
Intents
Intents
Handling intents
switch (input.Request) {
case LaunchRequest r:
return ResponseBuilder.Tell(“Skill launch request");
case IntentRequest r when r.Intent.Name == "MyIntent":
return ResponseBuilder.Tell(“Intent defined by you”);
case IntentRequest r when r.Intent.Name ==
BuiltInIntent.Cancel:
return ResponseBuilder.Tell(“Built in intent");
}
Slots
Set temperature to 20 degrees celsius/kalvins/fahrenheits
Slots
Set temperature to 20 degrees celsius/kalvins/fahrenheits
20 – amount slot
celsius/kalvins/fahrenheits – unit slot
Slot
Using Slots
Using Slots
private SkillResponse
HandleTemperatureIntent(IntentRequest r)
{
var amount = r.Intent.Slots["amount"].Value;
var temperatureUnit =
r.Intent.Slots["temperatureunit"].Value;
return ResponseBuilder.Tell(
$"It's {amount} degrees {temperatureUnit}...");
}
Publishing to AWS Lambda
Testing
Working with voice
https://giphy.com/gifs/kimmyschmidt-l0He0B1237tKb5fWM
SSML – Markup
• <speak>Entire response</speak>
• Three seconds <break time=“3s”/> pause.
• <s>First sentence<s/><s>Second sentence<s/>
• <prosody volume=“loud” rate=”slow” pitch=“medium”>Controlling
volume, rate and pitch</prosody>
• <say-as interpret-as=“telephone">555 555 555</say-as>
https://developer.amazon.com/docs/custom-skills/speech-synthesis-markup-language-ssml-reference.html
SSML – In code
return ResponseBuilder.Tell(new SsmlOutputSpeech()
{
Ssml = "<speak>Hey there!</speak>"
});
Session
• Yes, we have session.
• Sadly, Alexa.NET doesn’t support seamless integration with
Dynamo DB like JS SDK
Session - Demo
private SkillResponse HandleIntent(SkillRequest input)
{
if (input.Session.Attributes != null &&
input.Session.Attributes.TryGetValue("AudienceCount",
out var count))
{
return ResponseBuilder.Tell($"There are around
{count} people here.", input.Session);
}
}
And since it’s ordinary .NET Code you can...
• Post messages to Service Bus
• Call HTTP
• Fetch and persist to DB
• Do absolutely anything
Fot. https://www.ranker.com/list/they-said-i-could-be-anything-meme/robert-wabash
Where’s money in that?
Business model for single developer
• Every Alexa Skill is available for free (for now)
• You can include paid, premium content in your skills
• Most popular skills in their categories will be awarded by
Amazon
• Developer with at least 1 published skill will receive 100$ for
AWS and additional 100$ per month if it’ll generate any AWS
charges
Business model for companies
• Alexa for Business – publishing private skills for companies
https://developer.amazon.com/alexa-skills-kit/alexaforbusiness
Connecting with existing solution
• Any REST with HTTPS can be used to expose Alexa Skill
endpoint
Other stuff - IFTT
• https://ifttt.com/amazon_alexa
Other stuff – Home skills
Fot. https://www.cultofmac.com/436778/win-a-chance-to-wire-up-your-smart-home-with-amazons-alexa-deals/
Other stuff – Lists
Fot. https://imgflip.com/memegenerator/80385734/Chris-Jericho-List
Other stuff – Echo Spot/Show
Fot. Amazon
Summary
Fot. https://benbrookshelflife.files.wordpress.com/2016/10/gladiator.jpg
Where to learn
• codecademy.com/learn/learn-alexa - JS
• developer.amazon.com/alexa-skills-kit
• timheuer.com/blog/ - Alexa.NET Author
• facebook.com/AlexaDevs/
Samples, links, slides
bit.ly/rh-alexa
Questions?
Fot. https://imgur.com/gallery/sFBxW3i
@r_hryniewskifb.me/hryniewskinet

.NET, Alexa and me