Develop Alexa Skills for Amazon Echo with PHP
-
Upload
ralf-eggert -
Category
Technology
-
view
329 -
download
1
Transcript of Develop Alexa Skills for Amazon Echo with PHP
Develop Alexa Skills Develop Alexa Skills for Amazon Echo with PHPfor Amazon Echo with PHP
AWS Tech Community Days, Cologne, 27/09/2017AWS Tech Community Days, Cologne, 27/09/2017
Ralf EggertRalf EggertCEO Travello GmbH, Trainer, Author, Coach,CEO Travello GmbH, Trainer, Author, Coach,
PHP Developer & Alexa Skill DeveloperPHP Developer & Alexa Skill Developer
Three questions!Three questions!
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 44 from from 5858
AgendaAgenda
Amazon Alexa Basics
Prepare skill
Why PHP?
Implement skill code
Learnings
Amazon Alexa BasicsAmazon Alexa Basics
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 66 from from 5858
How does an Alexa request work?How does an Alexa request work?
AWSLambdaFunction
Alexa Voice Service
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 77 from from 5858
How does an Alexa request work?How does an Alexa request work?
AWSLambdaFunction
Alexa Voice Service
Voice Command
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 88 from from 5858
How does an Alexa request work?How does an Alexa request work?
AWSLambdaFunction
Alexa Voice Service
Voice Command
Voice Request
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 99 from from 5858
How does an Alexa request work?How does an Alexa request work?
AWSLambdaFunction
Alexa Voice Service
Voice Command
Voice Request
JSON Request
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1010 from from 5858
How does an Alexa request work?How does an Alexa request work?
AWSLambdaFunction
Alexa Voice Service
Voice Command
Voice Request
JSON Request
JSON Response
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1111 from from 5858
How does an Alexa request work?How does an Alexa request work?
AWSLambdaFunction
Alexa Voice Service
Text Response
Voice Command
Voice Request
JSON Request
JSON Response
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1212 from from 5858
How does an Alexa request work?How does an Alexa request work?
AWSLambdaFunction
Alexa Voice Service
Text Response
Voice Response
Card Response
Voice Command
Voice Request
JSON Request
JSON Response
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1313 from from 5858
Alternative requestAlternative request
HTTPSEndpoint
Server
Alexa Voice Service
Text Response
Voice Response
Card Response
Voice Command
Voice Request
JSON Request
JSON Response
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1414 from from 5858
Alexa Voice Service (AVS)Alexa Voice Service (AVS)
Alexa Voice Service
AutomaticSpeech
Recognition(ASR)
NaturalLanguage
Understanding(NLU)
TextTo
Speech(TTS)
VoiceCommandMapping
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1515 from from 5858
Alexa Skills Kit (ASK)Alexa Skills Kit (ASK)
Alexa Skills Kit
Interaction-Model /Skill Builder
Configuration
Publishing /Privacy
TestService Simulator
Beta Test
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1616 from from 5858
ASK OverviewASK Overview
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1717 from from 5858
Alexa Skill BuilderAlexa Skill Builder
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1818 from from 5858
AWS Lambda FunctionsAWS Lambda Functions
Why PHP?Why PHP?
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2020 from from 5858
Possible solutionsPossible solutions
Compile PHP for AWS
Use supported runtime engine for AWS
Use own HTTPS endpoint server
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2121 from from 5858
Use supported runtime engine?Use supported runtime engine?
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2222 from from 5858
Compile PHP for AWS Lambda?Compile PHP for AWS Lambda?
https://goo.gl/N9VVvb
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2323 from from 5858
Use own HTTPS endpoint server?Use own HTTPS endpoint server?
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2424 from from 5858
Solution foundSolution found
Compile PHP for AWS
Use supported runtime engine for AWS
Use own HTTPS endpoint server
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2525 from from 5858
Disadvantages own HTTPS endpointDisadvantages own HTTPS endpoint
Some dev-tools only work with Lambda (API, CLI)
Need to build own library for Alexa
Server administration
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2626 from from 5858
Advantages own HTTPS endpointAdvantages own HTTPS endpoint
Use any software you want
Full control over server environment
Privacy concerns (soft concern)
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2727 from from 5858
Open-source PHP libraryOpen-source PHP library
https://github.com/travello-gmbh/
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2828 from from 5858
My current tech stackMy current tech stack
Prepare skillPrepare skill
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3030 from from 5858
Create sample dialogsCreate sample dialogs
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3131 from from 5858
Sample dialog ISample dialog I
Alexa, start my zoo!
Welcome to your zoo.
Please name an animal in my zoo!
An elephant lives in your zoo.
Thanks, Alexa.
You are welcome.
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3232 from from 5858
Sample dialog IISample dialog II
Alexa, start my zoo!
Welcome to your zoo.
How many animals live in my zoo?
42 animals live in your zoo.
Thanks, Alexa.
You are welcome.
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3333 from from 5858
Create flow diagramsCreate flow diagrams
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3434 from from 5858
Flow diagrammFlow diagramm
Welcome to your zoo
Start my zoo
An elephantlives in your zoo
42 animalslive in your zoo
»name« »number«
»name« »number«
You're welcome
»thanks« »thanks«
»thanks«
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3535 from from 5858
Configure Alexa Skills KitConfigure Alexa Skills Kit
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3636 from from 5858
Create custom slot typesCreate custom slot types
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3737 from from 5858
Create custom intentsCreate custom intents
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3838 from from 5858
Configure HTTPS endpointConfigure HTTPS endpoint
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3939 from from 5858
Configure SSL certificateConfigure SSL certificate
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4040 from from 5858
Test HTTPS endpointTest HTTPS endpoint
Implement skill codeImplement skill code
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4242 from from 5858
Install sample applicationInstall sample application
$ git clone https://github.com/travello-gmbh/example-zoo-skill
$ cd example-zoo-skill
$ composer install
$ sudo chmod -R 777 data/cache/
// setup a virtual host for http://example-zoo-skill
// with the example-zoo-skill/html/ path as doc root
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4343 from from 5858
Test sample applicationTest sample application
/data/postman/collection.json
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4444 from from 5858
Update text fileUpdate text file
return [ 'alexaLaunchTitle' => 'Welcome', 'alexaLaunchMessage' => 'Welcome to my zoo', 'alexaRepromptMessage' => 'Another animal or cancel?', 'alexaHelpTitle' => 'Help', 'alexaHelpMessage' => 'You can ask me which animal ' . 'lives in your zoo or how many animals live there.', 'alexaCancelTitle' => 'Thanks', 'alexaCancelMessage' => 'Thanks and see you soon!', 'alexaStopTitle' => 'Thanks', 'alexaStopMessage' => 'Thanks and see you soon!', 'alexaAnimalTitle' => 'An animal', 'alexaAnimalMessage' => '%1$s lives in your zoo!', 'alexaCountTitle' => 'Animal census', 'alexaCountMessage' => '%1$s animals live in your zoo!',];
/data/texts/zoo.common.texts.de-DE.php
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4545 from from 5858
Create text helper classCreate text helper class
<?phpnamespace Zoo\Application\Helper;
use TravelloAlexaLibrary\Application\Helper\AbstractTextHelper;
class ZooTextHelper extends AbstractTextHelper implements ZooTextHelperInterface{ public function getAnimalTitle(): string { return $this->commonTexts[$this->locale]['alexaAnimalTitle']; } public function getAnimalMessage(string $animal): string { return sprintf($this->commonTexts[$this->locale]['alexaAnimalMessage'], $animal); } public function getCountTitle(): string { return $this->commonTexts[$this->locale]['alexaCountTitle']; } public function getCountMessage(int $count): string { return sprintf($this->commonTexts[$this->locale]['alexaCountMessage'], $count); }} /module/Zoo/src/Application/Helper/ZooTextHelper.php
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4646 from from 5858
Create zoo application ICreate zoo application I
<?phpnamespace Zoo\Application;
use TravelloAlexaLibrary\Application\AbstractAlexaApplication;use TravelloAlexaLibrary\Request\RequestType\IntentRequestType;use Zoo\Application\Helper\ZooTextHelperInterface;
class ZooApplication extends AbstractAlexaApplication{ protected function handleIntentRequest(): bool { $intentRequest = $this->alexaRequest->getRequest();
switch ($intentRequest->getIntent()->getName()) { case 'AnimalIntent': return $this->animalIntent();
case 'AMAZON.StopIntent': return $this->stopIntent();
/* ... */ } }}
/module/Zoo/src/Application/ZooApplication.php
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4747 from from 5858
Create zoo application IICreate zoo application II
<?phpnamespace Zoo\Application;
use TravelloAlexaLibrary\Response\Card\Standard;use TravelloAlexaLibrary\Response\OutputSpeech\SSML;
class ZooApplication extends AbstractAlexaApplication{ private function animalIntent(): bool { $zooMessage = $this->textHelper->getAnimalMessage('An elephant');
$this->alexaResponse->setOutputSpeech(new SSML($zooMessage));
$this->alexaResponse->setCard(new Standard( $this->textHelper->getAnimalTitle(), $zooMessage, $this->smallImageUrl, $this->largeImageUrl ));
return true; }}
/module/Zoo/src/Application/ZooApplication.php
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4848 from from 5858
Test zoo applicationTest zoo application
/data/postman/collection.json
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4949 from from 5858
More featuresMore features
Session attributes step2→
Second intent step4→
https://github.com/travello-gmbh/example-zoo-skill
Species slot type step3→
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5050 from from 5858
Coming soon in Library 2.0Coming soon in Library 2.0
https://github.com/travello-gmbh/amazon-alexa-skill-library
Introducing Intent classes
Automatic intent handling
LearningsLearnings
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5252 from from 5858
Early successEarly success
6 months top 10 activated skills
75.000 customers so far
64 customer reviews so far
2.500.000 utterances so far
Most accessed DE skill in 05/2017
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5353 from from 5858
Biggest challengesBiggest challenges
First name slot type
Signature validation
Category slot type intents→
Chance to break first skill2nd server for tests
More complex VUI / CUI
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5454 from from 5858
Certification processCertification process
7 days for feedback (02/2017)
Signature validation issue
16 hours to go live (07/2017)Single-word invocation issue
0 issues»abbrechen« intent issue
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5555 from from 5858
Development numbersDevelopment numbers
10 working days total
80% for infrastructure code
15 working days total
90% for skill code
20% for skill code
10% for infrastructure code
AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5656 from from 5858
LearningsLearnings
Start with simple skill
Test thoroughly
Write a solid code base
Build more than one skill
Design a sophisticated VUI
Do not trust slot-types blindly
Have fun!
Questions?Questions?
Thanks!Thanks!Mail: [email protected]: [email protected]: www.travello.audioWeb: www.travello.audio