Alexa 只调用 LauchRequest 而不是意图

Alexa only invokes LauchRequest and not intents

您好,我正在学习使用 Python for Alexa 的事实技能教程 link: https://github.com/alexa/skill-sample-python-fact

我的问题是 Alexa 只启动 "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()

但它不会为 "GetNewFactIntent"

执行 "IntentRequest"
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()

因此,调用函数时只有调用名称有效,"GetNewFactIntent" 中的示例语句不调用函数。 我的猜测是它在传递给 AWS Lambda 的 JSON 方面存在问题。它没有得到 "IntentRequest" 或找不到

intent_name = request['intent']['name']

JSON 架构:

{
    "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": []
        }
    }
}

我的问题是我没有告诉我的调用名称。所以教训是:在意图之前,先调用。