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

☆樱花仙子☆ 提交于 2019-12-02 11:03:57

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.

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