alexa_plug v0.2.0 AlexaPlug.Response
A collection of functions for building responses expected by the Alexa Skills Kit.
Usage
alias AlexaPlug.Response
Example
To create a response:
response = Response.new
|> Response.add_session_attributes(%{"user" => "test"})
|> Response.add_output_speech("PlainText", "Hello!")
|> Response.add_card("Simple", "Title", "Content")
|> Response.add_reprompt("PlainText", "Can I help with anything else?")
|> Response.add_should_not_end_session
and the following response map is created:
%{
"version" => "1.0",
"sessionAttributes" => %{"user" => "test"},
"response" => %{
"outputSpeech" => %{
"type" => "PlainText",
"text" => "Can I help with anything else?"
},
"card": %{
"type" => "Simple",
"title" => "Title",
"content" => "Content"
},
"reprompt" => %{
"outputSpeech" => %{
"type" => "PlainText",
"text" => "Can I help with anything else?"
}
},
"shouldEndSession" => false
}
}
The same response can be built using convenience methods as follows:
response = Response.new
|> Response.add_session_attributes(%{"user" => "test"})
|> Response.add_plain_text_output_speech("Hello!")
|> Response.add_simple_card("Title", "Content")
|> Response.add_plain_text_reprompt("Can I help with anything else?")
|> Response.add_should_not_end_session
Summary
Functions
Add response.card field to the response
Add response.card field to the response
Convenience method to add response.card to the response with the type set to LinkAccount
Add response.outputSpeech field to the response
Convenience method to add response.outputSpeech to the response with the type set to PlainText
Convenience method to add response.reprompt to the response with the type set to PlainText
Add response.reprompt field to the response
Add sessionAttributes field to the response
Add response.shouldEndSession field to the response set to true
Add response.shouldEndSession field to the response set to false
Convenience method to add response.card to the response with the type set to Simple
Convenience method to add response.outputSpeech to the response with the type set to SSML
Convenience method to add response.reprompt to the response with the type set to SSML
Create a new map with version set to 1.0 and an empty response map
Functions
Add response.card field to the response.
This function is meant to be used with the LinkAccount card type.
Add response.card field to the response.
This function is meant to be used with the Simple card type.
Convenience method to add response.card to the response with the type set to LinkAccount.
Convenience method to add response.outputSpeech to the response with the type set to PlainText.
Convenience method to add response.reprompt to the response with the type set to PlainText.
Add sessionAttributes field to the response.
Add response.shouldEndSession field to the response set to true.
Add response.shouldEndSession field to the response set to false.
Convenience method to add response.card to the response with the type set to Simple.
Convenience method to add response.outputSpeech to the response with the type set to SSML.
Convenience method to add response.reprompt to the response with the type set to SSML.