Last active
December 1, 2018 13:43
-
-
Save crazyrohila/aa606c8fa61777aa525142c4ed5242d5 to your computer and use it in GitHub Desktop.
Alexa skill Re-prompt/Confirmation - Voice and Display
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lambda_handler(event, context): | |
if event["request"]["type"] == "LaunchRequest": | |
return handleLaunchRequest(event) | |
if event["request"]["type"] == "IntentRequest": | |
if ('AMAZON.' in event["request"]["intent"]["name"]): | |
return handleInBuiltIntents(event) | |
else: | |
return handleCustomIntents(event) | |
elif event["request"]["type"] == "Display.ElementSelected": | |
tokenValue = event["request"]["token"] | |
handleInBuiltIntents(tokenValue) | |
def handleInBuiltIntents(intent): | |
speech = title = "Thank you!" | |
resp = echoShow_response.response(speech, title = title, sessionEnd = True) | |
if (intent == 'AMAZON.YesIntent' or intent == 'open_session'): | |
speech = title = "Go Ahead, Ask Me!" | |
resp = echoShow_response.response(speech, title = title, sessionEnd = False) | |
return resp | |
def handleCustomIntents(event): | |
intent = event["request"]["intent"]["name"] | |
if (intent == 'claim_expenses'): | |
speech = "Yeah, sure. You can claim expenses through Keka." | |
title = "Expenses Claim" | |
textContent = { | |
"primaryText": speech | |
} | |
reprompt = "do you want to ask another question?" | |
resp = echoShow_response.response(speech, title = title, textContent, reprompt = reprompt, sessionEnd = False) | |
return resp | |
# echoShow_response.response will build the actual final response - with directive, reprompt and action links. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment