Aws lambda 使用Amazon Lex';s inputTranscript允许一个大开口插槽。只有一个插槽

Aws lambda 使用Amazon Lex';s inputTranscript允许一个大开口插槽。只有一个插槽,aws-lambda,aws-lex,Aws Lambda,Aws Lex,与之前提出的问题类似。这涉及到该问题的解决方案以及解决方案下的评论。我想要创建的意图只有一个槽,我只想在收到用户的回复后做出适当的响应。在这种情况下,如果我不想使用插槽。我该怎么办 我记下了第一部分: slots = intent_request['currentIntent']['slots'] slots['anyString'] = intent_request['inputTranscript'] 我试着使用elixit_插槽。但这只会再次提示我要同样的成绩单,这不是我想要的。 我

与之前提出的问题类似。这涉及到该问题的解决方案以及解决方案下的评论。我想要创建的意图只有一个槽,我只想在收到用户的回复后做出适当的响应。在这种情况下,如果我不想使用插槽。我该怎么办

我记下了第一部分:

 slots = intent_request['currentIntent']['slots']
 slots['anyString'] = intent_request['inputTranscript']
我试着使用elixit_插槽。但这只会再次提示我要同样的成绩单,这不是我想要的。
我想在用户第一次填写inputTranscript后输入一组字符串后,向lex输出一个回复

我有一个解决此问题的方法:

if ChooseCase == 'Case 1' and CaseOneChosen == 'Yes' and not CaseOneQuestion:
    # Assign current inputTranscript to slots
    intent_request['currentIntent']['slots']['CaseOneQuestion'] = intent_request['inputTranscript']
    CaseOneQuestion = intent_request['inputTranscript']
    # After the user enter the text, check if the current slot value is the same as the previous slot, 
    # if it is, then this is the first time the user elicit this slot
    # Else, assign the current inputTranscript to the current slot (done above)
    if intent_request['currentIntent']['slots']['CaseOneQuestion'] == intent_request['currentIntent']['slots']['CaseOneChosen']:
        return elicit_slot(
            output_session_attributes,
            intent_request['currentIntent']['name'],
            intent_request['currentIntent']['slots'],
            'CaseOneQuestion',
            {'contentType': 'PlainText', 'content': 'Answer for case 1'},
            None
        )
解释:前一个插槽为“CaseoneSelected”,值为该插槽为“Yes”,然后第3行将该值分配给插槽“CaseOneQuestion”。现在它们都具有相同的值,因此if语句为TRUE。bot将允许用户引出slot“CaseOneQuestion”(我假设用户输入了“cat”)。在此之后,第3行将“cat”分配给“CaseOneQuestion”插槽。现在if语句是假的。机器人将不再重新提示要求用户引出“CaseOneQuestion”槽。插槽值现在为“cat”。 希望这有帮助