udayshi / php-alexa
This is PHP Helper library for Alexa and Echo Show to generate response with few lines of code.
v1.0
2019-09-17 08:21 UTC
Requires
- php: >=7.0
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This is PHP Helper library for Alexa and Echo Show to generate response with few lines of code..
Install via composer
Require the package with composer:
composer require udayshi/usalexa
Usage
Quick Implement
Just to send PlainText Quick response you can create function with any name and pass \USAlexa\Alexa $obj as parameter on created function.
Once you create the function you have to map and register the method.
Finally you can run it.
require('./vendor/autoload.php'); $obj=new \USAlexa\Alexa(); #Define function to handle request function launchIntentHandlerPhp(\USAlexa\Alexa $obj){ $obj->response->setResponse('Hello From PHP USAlexa.'); } #Register intent and run $obj->registerIntentHandler('LaunchRequest','launchIntentHandlerPhp') ->run();
Adding Effects
You can add the following effects:
- Whisper
- Break
- Emphasis
- Strong
- Moderate
- Reduced
- SayAs
require('./vendor/autoload.php'); $obj=new \USAlexa\Alexa(); #Define function to handle request function launchIntentHandlerPhp(\USAlexa\Alexa $obj){ $obj->response->setResponse('Hello From PHP USAlexa.') #Auto detect and send ssml $obj->response->setWhisper('Hello') ->setBreak(2) ->setEmphasisStrong('Strong') ->setEmphasisModerate('Moderate') ->setEmphasisReduced('Reduced') ->setSayAs('TEST'); ; } #Register intent and run $obj->registerIntentHandler('LaunchRequest','launchIntentHandlerPhp') ->run();
Echo Show Response
As long as you have minimum parameter for the echo show it will send proper response to the targeted devices.
require('./vendor/autoload.php'); $obj=new \USAlexa\Alexa(); #Define function to handle request function launchIntentHandlerPhp(\USAlexa\Alexa $obj){ $obj->response->setResponse('Hello From PHP USAlexa for echo show.') #Autodetect $img=$obj->getImageObject('[[IMG_URL]]'); $obj->template->setBackgroundImage($img); $img=$obj->getImageObject('[[IMG_URL]]'); $obj->template->setImage($img); ; } #Register intent and run $obj->registerIntentHandler('LaunchRequest','launchIntentHandlerPhp') ->run();