0

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

我已经完成了第一部分:

 slots = intent_request['currentIntent']['slots']
 slots['anyString'] = intent_request['inputTranscript']

我尝试使用 elixit_slot。但它只会再次提示我输入相同的成绩单,这不是我想要的。我想在第一次填满 inputTranscript 后用户输入一组字符串后向 lex 输出回复。

4

1 回答 1

0

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

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
        )

说明:前一个槽是“CaseOneChosen”,这个槽的值为“是”,那么第3行将把那个值赋给槽“CaseOneQuestion”。现在它们都具有相同的值,因此 if 语句为 TRUE。该机器人将让用户引出槽“CaseOneQuestion”(我假设用户输入了“cat”)。在此之后,第 3 行会将“cat”分配给“CaseOneQuestion”槽。所以现在 if 语句是 FALSE。机器人不会再提示用户引出“CaseOneQuestion”插槽。槽值现在是“cat”。希望这可以帮助。

于 2019-10-09T06:00:08.280 回答