无法在Dialogflow实现中读取上下文

无法在Dialogflow实现中读取上下文

本文介绍了无法在Dialogflow实现中读取上下文(突然未定义)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用google cloud功能作为webhook构建了一个Dialogflow代理,该代理可以正常运行直到昨天晚上。当时我导出了代理,然后稍后重新导入,它工作了一段时间。

We built a Dialogflow agent using google cloud functions as webhook which worked properly until yesterday evening. At that time I exported the agent and reimported it later on and it worked for a while.

停止工作的是 agent.context.get。 ('...'); (也 agent.getContext('...'))确实返回未定义即使根据UI和原始API响应设置了上下文。

What stopped working is that agent.context.get('...'); (also agent.getContext('...')) does return undefined even if the context is set according to the UI and raw API response.

例如,我有一个意图,该意图具有必需的插槽 shop ,启用了用于填充广告位的网络钩。
当我测试代理时,名为 info 的意图正确匹配,并且上下文 info_dialog_params_store 也似乎正确匹配在那里:

As an example I have an intent which has a required slot shop, webhook for slot filling enabled.When I test the agent, the intent named info is matched correctly and also the context info_dialog_params_store seems to be there:

这是输出上下文的一部分根据原始API响应:

And here is part of the output context according to the raw API response:

"outputContexts": [
      {
        "name": "projects/MYAGENTNAME/agent/sessions/0b753e8e-b377-587b-3db6-3c8dc898879b/contexts/info_dialog_params_store",
        "lifespanCount": 1,
        "parameters": {
          "store": "",
          "store.original": "",
          "kpi": "counts",
          "date_or_period": "",
          "kpi.original": "trafico",
          "date_or_period.original": ""
        }
      }

在webhook中,我将意图正确地映射到js fu

In the webhook I mapped the intent correctly to a js function:

let intentMap = new Map();
intentMap.set('info', info);
agent.handleRequest(intentMap);

以及 info 函数的第一行看起来像这样:

And the first line of the info function looks like:

function info(agent) {
    store_context = agent.context.get('info_dialog_params_store');
}

哪个回报

TypeError: Cannot read property 'get' of undefined
    at info (/user_code/index.js:207:36)
    at WebhookClient.handleRequest (/user_code/node_modules/dialogflow-fulfillment/src/dialogflow-fulfillment.js:303:44)
    at exports.dialogflowFirebaseFulfillment.functions.https.onRequest (/user_code/index.js:382:9)
    at cloudFunction (/user_code/node_modules/firebase-functions/lib/providers/https.js:57:9)
    at /var/tmp/worker/worker.js:762:7
    at /var/tmp/worker/worker.js:745:11
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)

我很确定我没有更改任何可能影响代理正常运行的内容,除了一些重构。

I am quite sure that I did not change anything which could affect the proper functioning of agent, except some refactoring.

我还尝试了beta函数的激活以及在我读完该函数后的禁用可能存在环境问题,但这并没有改变。

I also tried the beta functions activated as well as deactivated as I read that there can be issues with environments, but that did not change anything.

任何人都知道我可以进一步研究哪个方向?

Anyone knows in which direction I can investigate further?

推荐答案

我遇到了同样的问题,我解决了该问题,并更新了package.json中的dialogflow-fulfillment:

I had the same issue, I resolved it updating dialogflow-fulfillment in package.json:

来自 dialogflow-fulfillment: ^ 0.5.0
dialogflow-fulfillment: ^ 0.6.0

from "dialogflow-fulfillment": "^0.5.0"to "dialogflow-fulfillment": "^0.6.0"

这篇关于无法在Dialogflow实现中读取上下文(突然未定义)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 00:39