首页 文章

Alexa只调用LauchRequest而不是意图

提问于
浏览
1

嗨我在这个链接中使用Python for Alexa的事实技巧教程: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": []
        }
    }
}

1 回答

  • 0

    我的问题是我没有告诉我的调用名称 . 所以课程是:在意图之前,先调用 .

相关问题