Hi I am following the fact-skill tutorial using Python for Alexa in this link: https://github.com/alexa/skill-sample-python-fact
My problem is that Alexa only launches the "LaunchRequest"
def lambda_handler(event, context):
# App entry point
#print(event)
if event['session']['new']:
on_session_started()
if event['request']['type'] == "LaunchRequest":
return on_launch(event['request'])
elif event['request']['type'] == "IntentRequest":
return on_intent(event['request'], event['session'])
elif event['request']['type'] == "SessionEndedRequest":
return on_session_ended()
But it does not execute the "IntentRequest" for "GetNewFactIntent"
def on_intent(request, session):
""" called on receipt of an Intent """
intent_name = request['intent']['name']
# process the intents
if intent_name == "GetNewFactIntent":
return get_fact_response()
elif intent_name == "AMAZON.HelpIntent":
return get_help_response()
elif intent_name == "AMAZON.StopIntent":
return get_stop_response()
elif intent_name == "AMAZON.CancelIntent":
return get_stop_response()
elif intent_name == "AMAZON.FallbackIntent":
return get_fallback_response()
else:
print("invalid Intent reply with help")
return get_help_response()
Because of this only the invocation name is valid when calling the function and the sample utterance from "GetNewFactIntent" does not call the function. My guess is that it has problems regarding the JSON that gets passed to the AWS Lambda. It is not getting the "IntentRequest" or it cannot find
intent_name = request['intent']['name']
JSON schema:
{
"interactionModel": {
"languageModel": {
"invocationName": "space facts",
"intents": [
{
"name": "AMAZON.CancelIntent",
"samples": []
},
{
"name": "AMAZON.HelpIntent",
"samples": []
},
{
"name": "AMAZON.StopIntent",
"samples": []
},
{
"name": "AMAZON.FallbackIntent",
"samples": []
},
{
"name": "GetNewFactIntent",
"slots": [],
"samples": [
"a fact",
"a space fact",
"tell me a fact",
"tell me a space fact",
"give me a fact",
"give me a space fact",
"tell me trivia",
"tell me a space trivia",
"give me trivia",
"give me a space trivia",
"give me some information",
"give me some space information",
"tell me something",
"give me something"
]
}
],
"types": []
}
}
}
My problem was I am not telling my invocation name. So the lesson was: Before the intent, invocation first.