/alexa-skills-kit-model

Amazon Alexa Skills Kit Model

Primary LanguagePHP

Alexa Skill Kit Model

Build Status

This is a mapping between Alexa's request and response envelopes and PHP classes. There model library doesn't do any processing and is solely responsible for mapping only.

Reading request envelope

To read a json request execute

$data = json_decode($payload, true);
$envelope = RequestEnvelope::fromValue($data);

Writing response envelope

To create a json response use respective builders

$speech = PlainTextOutputSpeech::ofText("Plain text string to speak");
    
$response = Response::builder()
    ->withOutputSpeech($speech)
    ->withShouldEndSession(true)
    ->build();
    
$envelope = ResponseEnvelope::builder()
    ->withVersion("string")
    ->withResponse($response)
    ->build();
    
$payload = json_encode($envelope);

Composer

Use "vasily-kartashov/alexa-skills-kit-model"

ToDo