0

以前に尋ねられた質問と同様に、Amazon lex トランスクリプト ワイド オープン スロット. これは、その質問に対する解決策と、解決策の下のコメントを扱います。作成したいインテントにはスロットが 1 つしかなく、ユーザーからの返信を受け取った後に適切に応答したいだけです。この場合、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」で、このスロットの値は「Yes」です。3 行目でその値をスロット「CaseOneQuestion」に割り当てます。両方とも同じ値になったので、if ステートメントは TRUE になります。ボットは、ユーザーにスロット「CaseOneQuestion」を引き出しさせます (ユーザーが「cat」と入力したと仮定します)。この後、3 行目で「cat」を「CaseOneQuestion」スロットに割り当てます。したがって、if ステートメントは FALSE になります。ボットは、ユーザーに "CaseOneQuestion" スロットを引き出すように求めるプロンプトを再表示しなくなりました。スロットの値は「cat」になりました。お役に立てれば。

于 2019-10-09T06:00:08.280 に答える