Aleksa helper functions
February 11, 2017 ยท View on GitHub
Speech
val speech: OutputSpeech = outputSpeech("Hello world")
Creates an output speech from a given string. Automatically detects
SSML and creates a SsmlOutputSpeech if necessary. SSML must start with
<speak>
val speech: PlainTextOutputSpeech = plaintext("Hello world")
Creates a plaintext output speech from a given string.
val speech: SsmlOutputSpeech = ssml("<speak>Hello world</speak>")
Creates a SSML output speech from a given string.
Intents
// intent is read from the request
val value: String? = slotValue(intent, "Name")
Reads the slot Name from the intent. Returns null if either the slot or the slot value is missing.
Responses
val speech: OutputSpeech = outputSpeech("What's it gonna be?")
val reprompt: Reprompt = reprompt(speech)
Creates a reprompt from the given speech.
val response: SpeechletResponse = tell("Hello world")
Creates a tell response from the given string. You can use SSML in the string,
just start it with <speak>.
val response: SpeechletResponse = ask("What's your name?")
Creates an ask response from the given string. You can use SSML in the string,
just start it with <speak>. You can optionally provide a reprompt:
val response: SpeechletResponse = ask("What's your name?", "Don't be shy, what's your name?")
By default the reprompt is the same as the question.
Session
// Request is the request from the speechlet
val value: String? = getSessionString(request, "name")
Reads the value with the key name from the session. Returns null if the key
doesn't exist or the value isn't a string.
Miscellaneous
val telephoneSSML: String = telephoneNumber("030 22732152")
Returns the SSML for a digit-spoken telephone number with reasonable pauses
between them. Filters all non-digit characters from the given string. The
SSML doesn't include the <speak> tags.