0

Similar to the question that was asked previously amazon lex transcript wide open slot. This dealing with the solution to that question and the comment under the solution. The intent I want to create has only one slot and I just want to respond appropriately after receiving the reply from the user. in this case, if I don't want to use elicitSlot. What should I do?

I have got the first part down:

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

I tried to use elixit_slot. But it will only prompt me for the same transcript again, which is not what I want. I want to output a reply back to lex after the user entered a set of strings after the first time the inputTranscript is filled up.

user1655072
  • 572
  • 2
  • 10
  • 20

1 Answers1

0

I have a workaround for this problem:

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
        )

Explain: The previous slot is "CaseOneChosen", the value is this slot is "Yes", then line 3 will assign that value to the slot "CaseOneQuestion". Now they both have the same value, so the if statement is TRUE. The bot will let the user elicit slot "CaseOneQuestion" (I assume the user entered "cat"). After this, line 3 will assign "cat" to "CaseOneQuestion" slot. So now the if statement is FALSE. the bot will not re-prompt to ask the user elicit "CaseOneQuestion" slot anymore. And the slot value is now "cat". Hope this helps.

Rajan Sharma
  • 2,211
  • 3
  • 21
  • 33
qt1211
  • 1