vasily-kartashov/alexa-skills-kit-model

1.24.0 2019-11-24 03:54 UTC

This package is auto-updated.

Last update: 2024-12-14 10:01:37 UTC


README

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