Dialogflow 中的通用训练短语
Generic Training Phrase in Dialogflow
我正在尝试创建一个模拟面试操作,以特定顺序询问一组特定问题,而不管用户对每个问题的回答是什么。我如何在 Dialogflow 中设置意图以接受用户的任何短语以触发下一个问题作为响应?
对话框路径示例:
User: "I want to practice for an interview"
Google: "Question 1: tell me about yourself"
User: [says literally anything]
Google: "Great job. Question 2..."
User: [says literally anything]
Google: "Okay! Question 3..."
使用 Dialogflow,您可以创建一个接受任何输入的意图,方法是获取用户话语并将其标记为 @sys.any
。
然后您可以执行以下操作之一:
- 使用 Dialogflow 上下文使下一步依赖于第一步(如果您想在 Dialogflow 中执行一切,这很好)
- 使用
app.data
对象在您的 webhook 中跟踪对话状态。
有几种好方法可以满足您的需求,最佳解决方案将取决于您的其他需求。
如果您使用的是 fulfillment webhook,则可以将其作为 Fallback Intent. Make sure the checkbox to use fulfillment is on for the Fallback Intent, and you'll be sent everything that the user says that doesn't meet other structures. You'll need to keep count of how many times you've been called and you can store this as a parameter in a context、app.data
会话存储对象的一部分或 app.userStore
cross-session 存储对象。您的 webhook 将 return 下一个问题作为答复。
如果您想避免履行并通过 Dialogflow 处理它,您可以使用相同的一般想法,但您将需要跟踪每次遇到的问题。您可以通过创建多个后备意图来实现这一点,每个后备意图都有一个 Incoming Context a context named after which question you're expecting the user to answer (say "question_1") and the Outgoing Context 以回复中的问题命名(例如,"question_2")。
我正在尝试创建一个模拟面试操作,以特定顺序询问一组特定问题,而不管用户对每个问题的回答是什么。我如何在 Dialogflow 中设置意图以接受用户的任何短语以触发下一个问题作为响应?
对话框路径示例:
User: "I want to practice for an interview"
Google: "Question 1: tell me about yourself"
User: [says literally anything]
Google: "Great job. Question 2..."
User: [says literally anything]
Google: "Okay! Question 3..."
使用 Dialogflow,您可以创建一个接受任何输入的意图,方法是获取用户话语并将其标记为 @sys.any
。
然后您可以执行以下操作之一:
- 使用 Dialogflow 上下文使下一步依赖于第一步(如果您想在 Dialogflow 中执行一切,这很好)
- 使用
app.data
对象在您的 webhook 中跟踪对话状态。
有几种好方法可以满足您的需求,最佳解决方案将取决于您的其他需求。
如果您使用的是 fulfillment webhook,则可以将其作为 Fallback Intent. Make sure the checkbox to use fulfillment is on for the Fallback Intent, and you'll be sent everything that the user says that doesn't meet other structures. You'll need to keep count of how many times you've been called and you can store this as a parameter in a context、app.data
会话存储对象的一部分或 app.userStore
cross-session 存储对象。您的 webhook 将 return 下一个问题作为答复。
如果您想避免履行并通过 Dialogflow 处理它,您可以使用相同的一般想法,但您将需要跟踪每次遇到的问题。您可以通过创建多个后备意图来实现这一点,每个后备意图都有一个 Incoming Context a context named after which question you're expecting the user to answer (say "question_1") and the Outgoing Context 以回复中的问题命名(例如,"question_2")。