如何根据用户做出的选择在Amazon Lex中对用户做出响应?
例如:如果用户已结婚,则系统应询问您有几个孩子,如果用户未结婚,则系统应询问您何时结婚.
有什么办法吗?
解决方案如果它的目的只是简单地对用户做出响应,而没有任何引人注意的槽口或链接意图,则可以在Lambda函数中使用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')
如果您打算触发一些不同的intent,则在if-else内编写用于intent切换的代码.您将需要通过lambda传递confirmIntent对话框动作,并带有您想要切换的意图. 在此链接中查看有关意图切换的详细信息.
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?
解决方案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.
更多推荐
如何基于Amazon Lex中的用户响应给出响应?
发布评论