PHP code example of minicodemonkey / amazon-alexa-php
1. Go to this page and download the library: Download minicodemonkey/amazon-alexa-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
minicodemonkey / amazon-alexa-php example snippets
$jsonDataAsArray = $request->json()->all(); // This is how you would retrieve this with Laravel
$alexaRequest = \Alexa\Request\Request::fromData($jsonDataAsArray);
if ($alexaRequest instanceof IntentRequest) {
// Handle intent here
}
$response = new \Alexa\Response\Response;
$response->respond('I\'m your response message');
$response = new \Alexa\Response\Response;
$response->reprompt('What is your favourite color?');
$response = new \Alexa\Response\Response;
$response->respond('Cooool. I\'ll lower the temperature a bit for you!')
->withCard('Temperature decreased by 2 degrees');
$response = new \Alexa\Response\Response;
$response->respond('Cooool. I\'ll lower the temperature a bit and show you an image!')
->withImageCardCard('My title', 'My caption text for the image...', 'https://url.to/small-image.jpg', 'https://url.to/large-image.jpg');
$response = new \Alexa\Response\Response;
$response->respond('To link the skill with your account, click the linkAccount shown in your alexa app.')
->withLinkAccountCard();