Trouble with Amazon Lex chatbot slots

前提是你 提交于 2019-12-24 20:17:26

问题


I am trying to create a chatbot. Chatbot will prompt the question "What is your nationality? (A, B, C)" and if the user says C, I want to straight away end the chat by saying something like "I am sorry, C is not applicable to apply. Only A and B can apply." I know I have to uncheck the "required" checkbox after the said question but I'm not sure what to input in aws lambda for it to happen.


回答1:


After unchecking the required checkbox, in the lambda code do below:

# inside dialogcodehook
slots = intent_request['currentIntent']['slots']
nation = slots['nation']
if nation == 'C':
    return close('I am sorry, C is not applicable to apply. Only A and B can apply.')
# rest of your code

def close(msg):
"dialogAction": {
    "type": "Close",
    "fulfillmentState": "Fulfilled",
    "message": {
      "contentType": "PlainText",
      "content": msg
    }
}

You may want to see this question, this question, this question, this documentation etc..

Play with it and see documentation for other things and comment for further doubts.

Hope it helps.



来源:https://stackoverflow.com/questions/47938140/trouble-with-amazon-lex-chatbot-slots

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!