无法读取 Dialogflow Fulfillment 中的上下文(突然未定义) [英] Cannot Read Context in Dialogflow Fulfillment (Suddenly Undefined)

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

问题描述

我们使用谷歌云函数作为 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('...'))确实返回undefined 即使上下文是根据 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.

举个例子,我有一个 Intent,它有一个必需的插槽 shop,启用了插槽填充的 webhook.当我测试代理时,名为 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 函数:

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 Fulfillment 中的上下文(突然未定义)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆