Python 如何让Alexa正确回应:Alexa,询问(告诉)[调用名称](链接词,如果有)[意图话语]?

Python 如何让Alexa正确回应:Alexa,询问(告诉)[调用名称](链接词,如果有)[意图话语]?,python,aws-lambda,alexa,alexa-skill,Python,Aws Lambda,Alexa,Alexa Skill,当我说,“Alexa,打开/启动/启动强大的Righty” 她按原意回答。当我说“Alexa,问问Wighty Righty谁是对的,我还是你”,她没有启动应用程序,只是说:“对不起,我不知道那个。”我实际上无法通过亚马逊应用程序认证的功能验证,因为(我想)。以下是功能测试的结果: 需要1个修复程序 技能会话保持打开时,技能不应在reprompt中使用空文本或SSML响应意图请求。 当技能会话打开时,该技能会以一个空的语音提示回应用户。请注意,当技能会话打开时,技能不应针对技能中任何受支持的

当我说,“Alexa,打开/启动/启动强大的Righty” 她按原意回答。当我说“Alexa,问问Wighty Righty谁是对的,我还是你”,她没有启动应用程序,只是说:“对不起,我不知道那个。”我实际上无法通过亚马逊应用程序认证的功能验证,因为(我想)。以下是功能测试的结果:


需要1个修复程序
技能会话保持打开时,技能不应在reprompt中使用空文本或SSML响应意图请求。
当技能会话打开时,该技能会以一个空的语音提示回应用户。请注意,当技能会话打开时,技能不应针对技能中任何受支持的意图返回空文本或静默ssml响应。
下面是以无声责备回应的意图列表。
意图名称-playerBio,话语-谁对我或她
意图名称-playerBio,话语-alexa问强大的righty谁对我或我的孩子
意图名称-playerBio,话语-谁对我还是你

我尝试过使用LaunchRequest 意图探索 SessionEndRequest 但我不是一个编码员。我只是跟着一个教程走了这么远。我只需要修复Amazon“运行”测试发现的错误。我将能够发布该应用程序

#------------------------------Part1--------------------------------
# In this part we define a list that contains the player names, and 
# a dictionary with player biographies

Player_LIST = ["me or my wife", "me or my husband", "me or you"]

Player_BIOGRAPHY = {"me or my wife": ["She is. Do as she says, and you'll be OK.", "You", "Of course, your wife", "No doubt, it's you"],

"me or my husband": ["He is", "You are right", "He is not right", "Your husband. He is always right."],

"me or you": ["me", "You are, ... I mean... you are wrong, of course", "of course me", "It's me, don't you know that, my friend?", "you yourself, what do you think? Of course it's me", "I always know who is right, me or not me, so, it's meeeeee", "what do you think? I am Mighty Righty, so I am RIGHT"]}

#------------------------------Part2--------------------------------
# Here we define our Lambda function and configure what it does when 
# an event with a Launch, Intent and Session End Requests are sent. # The Lambda function responses to an event carrying a particular 
# Request are handled by functions such as on_launch(event) and 
# intent_scheme(event).

def lambda_handler(event, context):
    if event['session']['new']:
        on_start()
    if event['request']['type'] == "LaunchRequest":
        return on_launch(event)
    elif event['request']['type'] == "IntentRequest":
        return intent_scheme(event)
    elif event['request']['type'] == "SessionEndedRequest":
        return on_end()

#------------------------------Part3--------------------------------
# Here we define the Request handler functions

def on_start():
    print("Session Started.")

def on_launch(event):
    onlunch_MSG = "Hi, start with the word. Me. For example: who is right, me or my husband?"
    reprompt_MSG = "you can say, who is right, me or my wife?"
    card_TEXT = "Who is right, me or... ?."
    card_TITLE = "Choose your question."
    return output_json_builder_with_reprompt_and_card(onlunch_MSG, card_TEXT, card_TITLE, reprompt_MSG, False)

def on_end():
    print("Session Ended.")

#-----------------------------Part3.1-------------------------------
# The intent_scheme(event) function handles the Intent Request. 
# Since we have a few different intents in our skill, we need to 
# configure what this function will do upon receiving a particular 
# intent. This can be done by introducing the functions which handle 
# each of the intents.

def intent_scheme(event):

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

    if intent_name == "playerBio":
        return player_bio(event)        
    elif intent_name in ["AMAZON.NoIntent", "AMAZON.StopIntent", "AMAZON.CancelIntent"]:
        return stop_the_skill(event)
    elif intent_name == "AMAZON.HelpIntent":
        return assistance(event)
    elif intent_name == "AMAZON.FallbackIntent":
        return fallback_call(event)

#---------------------------Part3.1.1-------------------------------
# Here we define the intent handler functions

import random # this can be at the top of the file too
def player_bio(event):
    name=event['request']['intent']['slots']['player']['value']
    player_list_lower=[w.lower() for w in Player_LIST]
    if name.lower() in player_list_lower:
        reprompt_MSG = ""
        card_TEXT = "You've picked " + name.lower()
        card_TITLE = "You've picked " + name.lower()
        return output_json_builder_with_reprompt_and_card(random.choice(Player_BIOGRAPHY[name.lower()]), card_TEXT, card_TITLE, reprompt_MSG, False)
    else:
        wrongname_MSG = "Some questions may not yet be present in my database. Try to rephrase your sentence."
        reprompt_MSG = "For example, who is right, me or my wife?"
        card_TEXT = "Use the full question."
        card_TITLE = "Wrong question."
        return output_json_builder_with_reprompt_and_card(wrongname_MSG, card_TEXT, card_TITLE, reprompt_MSG, False)

def stop_the_skill(event):
    stop_MSG = "Bye for now and feel free to ask mighty righty who is right"
    reprompt_MSG = ""
    card_TEXT = "Bye."
    card_TITLE = "Bye Bye."
    return output_json_builder_with_reprompt_and_card(stop_MSG, card_TEXT, card_TITLE, reprompt_MSG, True)

def assistance(event):
    assistance_MSG = "start with the word. Me."
    reprompt_MSG = "For example, who is right me or him"
    card_TEXT = "You've asked for help."
    card_TITLE = "Help"
    return output_json_builder_with_reprompt_and_card(assistance_MSG, card_TEXT, card_TITLE, reprompt_MSG, False)

def fallback_call(event):
    fallback_MSG = "Try to say, for example, who is right, me or him?"
    reprompt_MSG = "Certain answers may not yet be in my database. Use personal pronouns, for example: me, or her, me, or him, me, or them. They can cover pretty much everybody"
    card_TEXT = "You've asked a wrong question."
    card_TITLE = "Wrong question."
    return output_json_builder_with_reprompt_and_card(fallback_MSG, card_TEXT, card_TITLE, reprompt_MSG, False)

#------------------------------Part4--------------------------------
# The response of our Lambda function should be in a json format. 
# That is why in this part of the code we define the functions which 
# will build the response in the requested format. These functions
# are used by both the intent handlers and the request handlers to 
# build the output.

def plain_text_builder(text_body):
    text_dict = {}
    text_dict['type'] = 'PlainText'
    text_dict['text'] = text_body
    return text_dict

def reprompt_builder(repr_text):
    reprompt_dict = {}
    reprompt_dict['outputSpeech'] = plain_text_builder(repr_text)
    return reprompt_dict

def card_builder(c_text, c_title):
    card_dict = {}
    card_dict['type'] = "Simple"
    card_dict['title'] = c_title
    card_dict['content'] = c_text
    return card_dict    

def response_field_builder_with_reprompt_and_card(outputSpeach_text, card_text, card_title, reprompt_text, value):
    speech_dict = {}
    speech_dict['outputSpeech'] = plain_text_builder(outputSpeach_text)
    speech_dict['card'] = card_builder(card_text, card_title)
    speech_dict['reprompt'] = reprompt_builder(reprompt_text)
    speech_dict['shouldEndSession'] = value
    return speech_dict

def output_json_builder_with_reprompt_and_card(outputSpeach_text, card_text, card_title, reprompt_text, value):
    response_dict = {}
    response_dict['version'] = '1.0'
    response_dict['response'] = response_field_builder_with_reprompt_and_card(outputSpeach_text, card_text, card_title, reprompt_text, value)
    return response_dict

我希望错误消息“1 Fixed Required”消失。我将能够向亚马逊提交我的应用程序。请帮助我发布我的应用程序

问题很清楚,并显示在代码中。你有不允许的空责备。你需要在所有你有
reprompt\u MSG=”“

的地方放一条reprompt文本,我想这是另一个我必须回答的问题,如何让Alexa做出反应:Alexa,问问强大的Righty谁是对的,我还是我的妻子?而不是一个漫长的过程:Alexa,打开强大的Righty。(欢迎来到这里)谁是对的,我还是我的妻子?所以我的问题是:你能在这里回答吗,或者我需要在这个网站上打开另一个问题?谢谢你的帮助!你好功能测试通过这一事实与认证团队(人类)将发现的某些方面无关,他们将拒绝该技能,并向您发送您收到的关于空重新验证的反馈。功能测试自动运行。认证测试由人类完成。这可能会对你有所帮助:请用另一个主题创建另一个问题,我会给你发一个例子谢谢你的建议。我提出了另一个问题。