\Patami\IPS\Services\Alexa\Skills\CustomResponse

Class for responses to Amazon Alexa Custom Skill requests.

You should use the TellResponse child class to speak text to the user without continuing the user's active session. In order to ask questions and continue the session to wait for the user's response after speaking to him, use the AskResponse class.

Summary

Methods
Properties
Constants
Create()
CreateSpeechOutput()
CreatePlainText()
CreateSSML()
SetSpeechOutput()
SetPlainText()
SetSSML()
ClearSpeechOutput()
GetSpeechOutput()
SetRepromptSpeechOutput()
SetRepromptPlainText()
SetRepromptSSML()
ClearRepromptSpeechOutput()
GetRepromptSpeechOutput()
SetCard()
SetSimpleCard()
SetStandardCard()
ClearCard()
GetCard()
SetCallbackIntent()
ClearCallbackIntent()
GetCallbackIntent()
ContinueSession()
EndSession()
GetText()
GetContentType()
No public properties found
No constants found
No protected methods found
$speechOutput
$repromptSpeechOutput
$card
$callbackIntent
$shouldEndSession
$request
N/A
No private methods found
No private properties found
N/A

Properties

$callbackIntent

$callbackIntent : string|null

Type

string|null — Name of the callback intent that should be called upon subsequent requests.

$shouldEndSession

$shouldEndSession : boolean

Type

boolean — True if the session should be terminated after sending the response. The session is terminated by default.

Methods

CreatePlainText()

CreatePlainText(string  $text) : \Patami\IPS\Services\Alexa\Skills\Custom\Response

Static factory method to create a Response object with plain text speech output from a string.

Parameters

string $text

Plain text speech output.

Throws

\Patami\IPS\Services\Alexa\Skills\Custom\Exceptions\SpeechOutputTextTooLongException

if the text is too long (more than 8000 characters).

Returns

\Patami\IPS\Services\Alexa\Skills\Custom\Response

New response object with speech output.

CreateSSML()

CreateSSML(string  $text) : \Patami\IPS\Services\Alexa\Skills\Custom\Response

Static factory method to create a Response object with SSML speech output from a string.

Parameters

string $text

SSML speech output.

Throws

\Patami\IPS\Services\Alexa\Skills\Custom\Exceptions\SpeechOutputTextTooLongException

if the text is too long (more than 8000 characters).

Returns

\Patami\IPS\Services\Alexa\Skills\Custom\Response

New response object with speech output.

SetSpeechOutput()

SetSpeechOutput(\Patami\IPS\Services\Alexa\Skills\Custom\SpeechOutput  $speechOutput) : $this

Updates the speech output of the response with a new SpeechOutput object.

Parameters

\Patami\IPS\Services\Alexa\Skills\Custom\SpeechOutput $speechOutput

Speech output text object.

Returns

$this —

Fluent interface.

SetPlainText()

SetPlainText(string  $text) : $this

Updates the speech output of the response with plain text speech output from a string.

Parameters

string $text

Plain text speech output.

Returns

$this —

Fluent interface.

SetSSML()

SetSSML(string  $text) : $this

Updates the speech output of the response with SSML speech output from a string.

Parameters

string $text

SSML speech output.

Returns

$this —

Fluent interface.

ClearSpeechOutput()

ClearSpeechOutput() : $this

Clears the speech output (= no speech output).

Returns

$this —

Fluent interface.

SetRepromptSpeechOutput()

SetRepromptSpeechOutput(\Patami\IPS\Services\Alexa\Skills\Custom\SpeechOutput  $speechOutput) : $this

Updates the reprompt speech output of the response with a new SpeechOutput object.

Parameters

\Patami\IPS\Services\Alexa\Skills\Custom\SpeechOutput $speechOutput

Reprompt speech output text object.

Returns

$this —

Fluent interface.

SetRepromptPlainText()

SetRepromptPlainText(string  $text) : $this

Updates the reprompt speech output of the response with plain text speech output from a string.

Parameters

string $text

Reprompt plain text speech output.

Returns

$this —

Fluent interface.

SetRepromptSSML()

SetRepromptSSML(string  $text) : $this

Updates the reprompt speech output of the response with SSML speech output from a string.

Parameters

string $text

Reprompt SML speech output.

Returns

$this —

Fluent interface.

ClearRepromptSpeechOutput()

ClearRepromptSpeechOutput() : $this

Clears the reprompt speech output (= no speech output).

Returns

$this —

Fluent interface.

GetRepromptSpeechOutput()

GetRepromptSpeechOutput() : \Patami\IPS\Services\Alexa\Skills\Custom\SpeechOutput|null

Returns the reprompt speech output object.

Returns

\Patami\IPS\Services\Alexa\Skills\Custom\SpeechOutput|null —

Reprompt speech output object or null if no reprompt speech output was set.

SetCard()

SetCard(\Patami\IPS\Services\Alexa\Skills\Custom\Card  $card) : $this

Updates the card that is displayed in the Alex App with a Card object.

Parameters

\Patami\IPS\Services\Alexa\Skills\Custom\Card $card

Card object to be displayed in the Alexa App.

Returns

$this —

Fluent interface.

SetSimpleCard()

SetSimpleCard(string  $title, string  $content) : $this

Updates the card that is displayed in the Alex App with a SimpleCard object created from title and content texts.

A simple card is also called a "Basic Home Card".

Parameters

string $title

Title of the card.

string $content

Text of the card. You can use \r or \r\n to insert line breaks.

Throws

\Patami\IPS\Services\Alexa\Skills\Custom\Exceptions\CardTextTooLongException

if the text is too long (more than 8000 characters).

Returns

$this —

Fluent interface.

SetStandardCard()

SetStandardCard(string  $title, string  $text, string|null  $smallImageUrl = null, string|null  $largeImageUrl = null) : $this

Updates the card that is displayed in the Alex App with a StandardCard object created from title and content texts and image URLs.

A standard card is also called a "Home Card".

Parameters

string $title

Title of the card.

string $text

Text of the card. You can use \r or \r\n to insert line breaks.

string|null $smallImageUrl

URL of a small image (recommended size: 720x480) or null for no image.

string|null $largeImageUrl

URL of a large image (recommended size: 1200x800) or null for no image.

Throws

\Patami\IPS\Services\Alexa\Skills\Custom\Exceptions\CardTextTooLongException

if the text is too long (more than 8000 characters). TODO: Implement Media objects that return the desired URLs.

Returns

$this —

Fluent interface.

ClearCard()

ClearCard() : $this

Clears the card (= no card will be displayed in the Alexa App).

Returns

$this —

Fluent interface.

GetCard()

GetCard() : \Patami\IPS\Services\Alexa\Skills\Custom\Card|null

Returns the Card object to be displayed in the Alexa App.

Returns

\Patami\IPS\Services\Alexa\Skills\Custom\Card|null —

Card object to be displayed or null if no card will be displayed.

SetCallbackIntent()

SetCallbackIntent(\Patami\IPS\Services\Alexa\Skills\Custom\Intent|string  $intent) : $this

Sets the callback intent that should be called by an intent in a subsequent request in the user's active session.

Parameters

\Patami\IPS\Services\Alexa\Skills\Custom\Intent|string $intent

Intent object or intent name to be called in the subsequent request.

Throws

\Patami\IPS\Services\Alexa\Skills\Custom\Exceptions\InvalidCallbackIntentException

if the type of the $intent parameter is invalid.

Returns

$this —

Fluent interface.

ClearCallbackIntent()

ClearCallbackIntent() : $this

Clears the callback intent.

Returns

$this —

Fluent interface.

GetCallbackIntent()

GetCallbackIntent() : string|null

Returns the name of the callback intent.

Returns

string|null —

Name of the callback intent or null if none is set.

ContinueSession()

ContinueSession(boolean  $continue = true) : $this

Sets a flag to continue or terminate the user's active session after the current request.

Parameters

boolean $continue

True to continue the session or false to terminate it.

Returns

$this —

Fluent interface.

EndSession()

EndSession() : $this

Sets a flag to terminate the user's active session after the current request.

Returns

$this —

Fluent interface.

GetText()

GetText() : string

Returns the response as a JSON-encoded data structure.

This method is called by the I/O module after the request has been processed.

Returns

string —

JSON-encoded Alexa Custom Skill response data structure.

GetContentType()

GetContentType() : string

Returns the MIME content type of the response send to the Amazon servers.

Returns

string —

MIME content type.