followupEvent 不匹配任何意图

followupEvent not matching any intent

我正在使用 dialogflow-fulfillment 来实现基于对话流的服务后端。有一点我使用方法 agent.setFollowupEvent(targetIntent)targetIntent 需要一个上下文是可匹配的,我们称之为 targetContext.

我无法确切地说出它什么时候停止工作(一个星期?也许一个月?),但它工作并且现在它不工作(而且我认为我没有改变任何可以解释它的东西) . targetIntent fulfillment 永远不会被调用,我可以在 dialogflow 控制台中看到这是因为 setFollowupEvent 触发的请求与任何意图都不匹配。

如果我从 targetIntent 中删除 targetContext 的要求,它会起作用。

我认为我设置的上下文是正确的:

agent.context.set(targetContext, null, null);
agent.setFollowupEvent(targetIntent);

检查 dialogflow-fulfillment 发送到 dialogflow 的响应正文,我看到:

{
    "outputContexts": [{ "name": "projects/<myprojectid>/agent/sessions/<mysessionid>/contexts/<targetContext>" }],
    "followupEventInput": { "name": "<targetIntent>", "languageCode": "it" }
}

上下文是有的,我觉得是对的。 有什么线索吗?我唯一能想到的是,我们将代理类型从免费更改为企业。

显然,我在提出问题后就找到了解决方案...

问题是上下文的生命周期,我没有设置它,现在它适用于:

                                 |
                                 V
agent.context.set(targetContext, 1, null);
agent.setFollowupEvent(targetIntent);

所以输出变成:

{
    "outputContexts": [{ "name": "projects/<myprojectid>/agent/sessions/<mysessionid>/contexts/<targetContext>", "lifespanCount": 1 }],
    "followupEventInput": { "name": "<targetIntent>", "languageCode": "it" }
}

我仍然很确定它以前有效,也许没有将用于默认的寿命设置为 1?