首页 > 解决方案 > Google Dialogflow:无法读取未定义的属性“EventInput”

问题描述

我试图通过触发事件意图向谷歌对话流对话发送消息,我的代码在节点 14 运行时的云函数中运行。

  const dialogflow = require('dialogflow');
  const eventName = 'ResultResponse'; 
  const sessionClient = new dialogflow.SessionsClient({projectId: projectId, keyFilename: keypath});
  const session = sessionClient.session_path(projectId,sessionId);
  event_input = dialogflow.types.EventInput(name=eventName, language_code=LANGUAGE_CODE)
  query_input = dialogflow.types.QueryInput(event=event_input)
  response = client.detect_intent(session=session, query_input=query_input)

如本问答中所述: 如何从检测意图 API 触发对话流事件?

但是,我收到此错误:

TypeError: Cannot read property 'EventInput' of undefined at triggerCallback (/workspace/index.js:53:34) at exports.Callback (/workspace/index.js:75:3)

这是我的 package.json:

{
  "name": "Callback",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "engines": {
    "node": "10"
  },
  "dependencies": {
    "actions-on-google": "^2.2.0",
    "dialogflow": "^0.6.0",
    "dialogflow-fulfillment": "^0.5.0",
    "request-promise-native": "^1.0.9",
    "axios": "^0.21.1",
    "@google-cloud/storage": "^5.14.0"
  }
}

这是我的意图:

在此处输入图像描述

我究竟做错了什么?

标签: google-cloud-functionsdialogflow-es

解决方案


推荐阅读