首页 > 解决方案 > 延长后续上下文的生命周期?

问题描述

如果我的意图被误导(不是双关语),请随时指出,但我试图处理一个对话流程,其中提示用户一个是/现在的问题,作为类似意图的搜索的后续行动。

如果响应与他们正在寻找的内容相匹配,他们会说是,如果不匹配,他们会说不。如果不是,我会继续跟进(一段时间)其他选项。

在上下文过期之前,后续意图会被命中几次。我在想,每次我提出新的建议时,我都会将寿命延长 1 倍。

这是一个好方法吗?如果是这样,是否有一种正确的方法来基本上做一个 context.lifespan++ 或者我是否需要查找现有的上下文并覆盖它?

谢谢!

想象一下这样的流程。第一个输入触发父意图。是/否答案应符合后续意图。

> 'Suggest food'  
< 'Potato'   (followup lifespan 1)
> 'No'       
< 'Taco'     (followup lifespan undefined)
> 'No'       
< 'Pizza'    (followup context gone)
> 'No'

最后一个 no 不会触发后续意图 b/c 上下文已过期。

标签: dialogflow-es

解决方案


无需延长上下文的生命周期。在我开始使用它之前,我也为此苦苦挣扎了几个小时:

Intent: question
Trainings phrase: 'May I enter?'
Output context: 'await_olderThan21'
Response: 'Are you older than 21?'

Intent: question.yes
Training phrase: 'yes'
Input context: 'await_olderThan21'
Output context: ''
Response: 'Yes, you may enter'

Intent: question.no
Training phrase: 'no'
Input context: 'await_olderThan21'
Output context: ''
Response: 'No, you may not.'

Intent: question.invalidInput
Training phrase: @sys.any
Input context: 'await_olderThan21'
Output context: 'await_olderThan21'
Response: 'Invalid answer. Please reply with yes or no.'

我希望这是有道理的!


推荐阅读