How to give response based on user response in Amazon Lex?

心不动则不痛 提交于 2019-12-02 16:31:51

问题


How do I give response to a user in Amazon Lex based on the choice that the user have made?

For example: If user is married then system should ask how many children do you have, if user is not married the system should ask when are you getting married.

Is there any way to do this?


回答1:


If it's purpose is simply responding to the user without any elicit slot or chaining intents then it can be done simply in Lambda function with an if condition.

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

if user['married'] == True:
    return close('how many children do you have')
else:
    return close('when are you getting married')

If you are planning to trigger some different intent then inside if-else write code for intent switching. You will need to pass the confirmIntent dialog action from the lambda with the intent you want to switch to.
Check this link for details about intent switching.



来源:https://stackoverflow.com/questions/47706177/how-to-give-response-based-on-user-response-in-amazon-lex

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