Alexa and the Amazon Echo is one of the biggest players in the new area for digital language
assistents. Although there is no official support to build Alexa Skills with PHP, in early summer
2017 the most used German Skill was based on a PHP application. In this talk you will learn from
the author of this skill how to build Alexa Skills with PHP based on an open-source library. The talk
will present what you need to consider when building your Alexa Skill with your own HTTPS
endpoint server instead of an AWS Lambda function.
6. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 66 fromfrom 5858
How does an Alexa request work?How does an Alexa request work?
AWS
Lambda
Function
Alexa Voice Service
7. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 77 fromfrom 5858
How does an Alexa request work?How does an Alexa request work?
AWS
Lambda
Function
Alexa Voice Service
Voice Command
8. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 88 fromfrom 5858
How does an Alexa request work?How does an Alexa request work?
AWS
Lambda
Function
Alexa Voice Service
Voice Command
Voice Request
9. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 99 fromfrom 5858
How does an Alexa request work?How does an Alexa request work?
AWS
Lambda
Function
Alexa Voice Service
Voice Command
Voice Request
JSON Request
10. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1010 fromfrom 5858
How does an Alexa request work?How does an Alexa request work?
AWS
Lambda
Function
Alexa Voice Service
Voice Command
Voice Request
JSON Request
JSON Response
11. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1111 fromfrom 5858
How does an Alexa request work?How does an Alexa request work?
AWS
Lambda
Function
Alexa Voice Service
Text Response
Voice Command
Voice Request
JSON Request
JSON Response
12. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1212 fromfrom 5858
How does an Alexa request work?How does an Alexa request work?
AWS
Lambda
Function
Alexa Voice Service
Text Response
Voice Response
Card Response
Voice Command
Voice Request
JSON Request
JSON Response
13. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1313 fromfrom 5858
Alternative requestAlternative request
HTTPS
Endpoint
Server
Alexa Voice Service
Text Response
Voice Response
Card Response
Voice Command
Voice Request
JSON Request
JSON Response
14. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1414 fromfrom 5858
Alexa Voice Service (AVS)Alexa Voice Service (AVS)
Alexa Voice Service
Automatic
Speech
Recognition
(ASR)
Natural
Language
Understanding
(NLU)
Text
To
Speech
(TTS)
Voice
Command
Mapping
15. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1515 fromfrom 5858
Alexa Skills Kit (ASK)Alexa Skills Kit (ASK)
Alexa Skills Kit
Interaction-Model /
Skill Builder
Configuration
Publishing /
Privacy
Test
Service Simulator
Beta Test
16. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1616 fromfrom 5858
ASK OverviewASK Overview
17. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1717 fromfrom 5858
Alexa Skill BuilderAlexa Skill Builder
18. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 1818 fromfrom 5858
AWS Lambda FunctionsAWS Lambda Functions
20. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2020 fromfrom 5858
Possible solutionsPossible solutions
Compile PHP for AWS
Use supported runtime engine for AWS
Use own HTTPS endpoint server
21. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2121 fromfrom 5858
Use supported runtime engine?Use supported runtime engine?
22. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2222 fromfrom 5858
Compile PHP for AWS Lambda?Compile PHP for AWS Lambda?
https://goo.gl/N9VVvb
23. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2323 fromfrom 5858
Use own HTTPS endpoint server?Use own HTTPS endpoint server?
24. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2424 fromfrom 5858
Solution foundSolution found
Compile PHP for AWS
Use supported runtime engine for AWS
Use own HTTPS endpoint server
25. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2525 fromfrom 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
26. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2626 fromfrom 5858
Advantages own HTTPS endpointAdvantages own HTTPS endpoint
Use any software you want
Full control over server environment
Privacy concerns (soft concern)
27. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2727 fromfrom 5858
Open-source PHP libraryOpen-source PHP library
https://github.com/travello-gmbh/
28. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 2828 fromfrom 5858
My current tech stackMy current tech stack
30. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3030 fromfrom 5858
Create sample dialogsCreate sample dialogs
31. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3131 fromfrom 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.
32. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3232 fromfrom 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.
33. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3333 fromfrom 5858
Create flow diagramsCreate flow diagrams
34. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3434 fromfrom 5858
Flow diagrammFlow diagramm
Welcome to
your zoo
Start my zoo
An elephant
lives in your zoo
42 animals
live in your zoo
»name« »number«
»name« »number«
You're welcome
»thanks« »thanks«
»thanks«
35. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3535 fromfrom 5858
Configure Alexa Skills KitConfigure Alexa Skills Kit
36. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3636 fromfrom 5858
Create custom slot typesCreate custom slot types
37. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3737 fromfrom 5858
Create custom intentsCreate custom intents
38. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3838 fromfrom 5858
Configure HTTPS endpointConfigure HTTPS endpoint
39. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 3939 fromfrom 5858
Configure SSL certificateConfigure SSL certificate
40. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4040 fromfrom 5858
Test HTTPS endpointTest HTTPS endpoint
42. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4242 fromfrom 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
43. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4343 fromfrom 5858
Test sample applicationTest sample application
/data/postman/collection.json
44. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4444 fromfrom 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
45. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4545 fromfrom 5858
Create text helper classCreate text helper class
<?php
namespace ZooApplicationHelper;
use TravelloAlexaLibraryApplicationHelperAbstractTextHelper;
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
46. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4646 fromfrom 5858
Create zoo application ICreate zoo application I
<?php
namespace ZooApplication;
use TravelloAlexaLibraryApplicationAbstractAlexaApplication;
use TravelloAlexaLibraryRequestRequestTypeIntentRequestType;
use ZooApplicationHelperZooTextHelperInterface;
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
47. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4747 fromfrom 5858
Create zoo application IICreate zoo application II
<?php
namespace ZooApplication;
use TravelloAlexaLibraryResponseCardStandard;
use TravelloAlexaLibraryResponseOutputSpeechSSML;
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
48. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4848 fromfrom 5858
Test zoo applicationTest zoo application
/data/postman/collection.json
49. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 4949 fromfrom 5858
More featuresMore features
Session attributes step2→
Second intent step4→
https://github.com/travello-gmbh/example-zoo-skill
Species slot type step3→
50. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5050 fromfrom 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
52. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5252 fromfrom 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
53. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5353 fromfrom 5858
Biggest challengesBiggest challenges
First name slot type
Signature validation
Category slot type intents→
Chance to break first skill
2nd server for tests
More complex VUI / CUI
54. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5454 fromfrom 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
55. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5555 fromfrom 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
56. AWS Tech Community DaysAWS Tech Community DaysRalf EggertRalf Eggert 5656 fromfrom 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!