node.js - Fulfillment 中的 DialogFlow - DeepLink 未定义

标签 node.js dialogflow-es actions-on-google

我尝试在 DialogFlow 的 Fulfillment 内联编辑器中使用 DeepLink,但收到错误“DeepLink 未定义”。问题是如何将DeepLink导入到项目中?

有关深层链接类的更多信息: deeplink class

我的index.js:

'use strict';

// Import the Dialogflow module from the Actions on Google client library.
const {dialogflow} = require('actions-on-google');

// Import the firebase-functions package for deployment.
const functions = require('firebase-functions');

// Instantiate the Dialogflow client.
const app = dialogflow({debug: true});


// Handle the Dialogflow intent named 'favorite color'.
// The intent collects a parameter named 'color'.
app.intent('favorite color', (conv, {color}) => {

此处出现错误“DeepLink 未定义”

  conv.ask(new DeepLink({
    destination: 'Google',
    url: 'http://my.deep.link',
    package: 'my.package.name',
    reason: 'handle this for you',
  }))
})

// Set the DialogflowApp object to handle the HTTPS POST request.
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);

我的package.json

{
  "name": "dialogflowFirebaseFulfillment",
  "description": "This is the default fulfillment for a Dialogflow agents using Cloud Functions for Firebase",
  "version": "0.0.1",
  "private": true,
  "license": "Apache Version 2.0",
  "author": "Google Inc.",
  "engines": {
    "node": "~6.0"
  },
  "scripts": {
    "start": "firebase serve --only functions:dialogflowFirebaseFulfillment",
    "deploy": "firebase deploy --only functions:dialogflowFirebaseFulfillment"
  },
  "dependencies": {
    "actions-on-google": "^2.2.0",
    "firebase-admin": "^4.2.1",
    "firebase-functions": "^0.5.7",
    "dialogflow": "^0.1.0",
    "dialogflow-fulfillment": "^0.4.1"
  }
}

谢谢!

最佳答案

我去啦! :) 第 4 行应如下所示:

const {dialogflow, DeepLink} = require('actions-on-google');

关于node.js - Fulfillment 中的 DialogFlow - DeepLink 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52307746/

相关文章:

node.js - 在 Sequelize 中创建与其关联的模型

google-bigquery - Dialogflow 与 BigQuery 集成 - 将整数参数传递给 BQ

dialogflow-es - 用户实体在 Alpha 版中不起作用

javascript - 如何从 .map 返回对象数组

node.js - Node JS mongoose 创建博客文章评论系统

javascript - 将 G Analytics 集成到 Node.js API

firebase - Actions-on-Google user.storage 未保存在 Dialogflow SDK 上

javascript - 如何解决此 dialogflow 错误 : text input not set?

具有自定义查询模式的 Android 应用程序操作

android - 将 Google Home 响应转换到电视上的 Chromecast