【问题标题】:Alexa only invokes LauchRequest and not intentsAlexa 只调用 LauchRequest 而不是意图
【发布时间】:2018-12-05 23:01:56
【问题描述】:

您好,我正在关注此链接中使用 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": []
        }
    }
}

【问题讨论】:

  • 你在 aws 控制台上测试了吗?
  • 嗨!我不知道该怎么做?您是说 CloudWatch 吗?还是测试时的日志?是的,我看到了技能 I/O 日志,问题是它只在技能成功时显示。在这种情况下,只有 LaunchRequest 事件技能输入及其响应作为技能输出。
  • 不,您必须在 aws lambda 控制台上对其进行测试,请参阅这些:第 1 步:ibb.co/iMr1eo 第 2 步:ibb.co/hBd3s8 第 3 步:ibb.co/keYEzo 第 4 步:ibb.co/hU99X8
  • 如图所示测试它并告诉我输出。
  • 我一看到它就会在这里再次发表评论。 :)

标签: python json aws-lambda alexa alexa-skills-kit


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-03-27
    • 2018-02-19
    • 2019-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-03
    相关资源
    最近更新 更多