- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试将dialog-fulfillment-library与express一起使用,而不使用firebase功能。不过,我无法找到如何解决该代理的问题。
const { WebhookClient, Card, Suggestion } = require('dialogflow-fulfillment');
module.exports = function () {
let self = {};
self.create = function (req, res, next) {
const agent = new WebhookClient({request: req, response: res});
agent.add(new Suggestion(`Quick Reply`));
agent.add(new Card({
title: `Title: this is a card title`,
imageUrl: 'https://developers.google.com/actions/images/badges/XPM_BADGING_GoogleAssistant_VER.png',
text: `This is the body text of a card. You can even use line\n breaks and emoji! 💁`,
buttonText: 'This is a button',
buttonUrl: 'https://assistant.google.com/'
})
);
res.json(agent);
};
return self;
};
我收到一个类型错误:将循环结构转换为 JSON我尝试过回收代理,但它在对话流端不起作用。使用:
res.send(JSON.stringify(agent, decycle()));
返回:Webhook 调用失败。错误:无法解析 Webhook JSON 响应:在消息 google.cloud.dialogflow.v2.WebhookResponse 中找不到字段:request_。
有人用过这种方法吗,还是不行?
最佳答案
我已提交Pull Request对于同样的。
以下代码适用于我。
package.json
{
"name": "Test_Agent",
"version": "0.0.1",
"description": "Test Agent webhook",
"main": "server.js",
"author": "Abhinav Tyagi, New Delhi, India",
"dependencies": {
"dialogflow-fulfillment": "^0.4.1",
"body-parser": "^1.18.3",
"express": "^4.16.3",
"actions-on-google": "^2.2.0"
}
}
server.js
'use strict';
const {WebhookClient} = require('dialogflow-fulfillment');
const express = require('express');
const bodyParser = require('body-parser');
const app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
function welcome (agent) {
agent.add(`Welcome to Express.JS webhook!`);
}
function fallback (agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
function WebhookProcessing(req, res) {
const agent = new WebhookClient({request: req, response: res});
console.info(`agent set`);
let intentMap = new Map();
intentMap.set('Default Welcome Intent', welcome);
intentMap.set('Default Fallback Intent', fallback);
// intentMap.set('<INTENT_NAME_HERE>', yourFunctionHandler);
agent.handleRequest(intentMap);
res.status(200).send(agent);
}
// Webhook
app.post('/', function (req, res) {
console.info(`\n\n>>>>>>> S E R V E R H I T <<<<<<<`);
WebhookProcessing(req, res);
});
app.listen(8080, function () {
console.info(`Webhook listening on port 8080!`)
});
确保同时使用action-on-google 和dialogflow-fulfillment 模块。intentMap
键是 intent.displayName
。
关于node.js - dialogflow-fulfillment-library 和express,需要什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51406463/
自从我将 Dialogflow 升级为使用 v2 API 后,出现以下错误: Dialogflow IntentHandler not found for intent: myIntent 由于某些原
PermissionDenied:拒绝了“projects/XXXX-live/agent”上的403 IAM权限“dialogflow.sessions.detectIntent”。 创建服务时,我
基本上,我的代理人是法国人,当我输入 10h(12 小时格式为上午 10 点)时,我的 DialogFlow 代理人理解 22h(晚上 10 点),但我希望他理解上午 10 点。 (我想要 24 小时
我和我的团队正在使用 Dialogflow 为 Facebook Messenger 构建一个机器人,但由于我们的用户不会说同一种语言(西类牙语是项目中的默认语言),我们想要实现我们项目的英文版本,但
我是新来的 DialogFlow ,我开始创建代理,从smaltalk从头开始。问题是如何将更多预构建代理(例如警报和应用程序管理,以及货币转换器)附加到新创建的代理中? 谢谢你的帮助。 最佳答案 您
在 Dialogflow 中,通过扩展设置为自动化的“训练实体”的最佳方法是什么。在训练短语中添加实体和在实体屏幕中简单地添加示例值之间有什么区别吗? Dialogflow 培训是否比另一个更重视?创
我正在尝试训练 Dialogflow 机器人来识别不同的旅行请求(航类预订、酒店预订等)。我发现如果没有将时间指定为 12 小时格式(使用 AM/PM),它就不能正确解析时间。 我需要周六 08:00
我正在使用 webhook 在 dialogflow 上制作一个机器人。我收到一个错误:DEADLINE_EXCEEDED。我的 webhook 需要 5 秒多一点的时间来返回响应。有没有办法允许超过
我正在使用 Dialogflow 为银行创建一个机器人。我想保留与客户代表交谈的选择权。如果客户想与客户代表交谈,机器人应该停止,客户代表开始与客户聊天。在 Dialogflow 中如何实现。 最佳答
每当我输入 6 月 37 日作为输入时,它都不会给出错误,而是将日期视为 6 月 30 日。我想要做的是在输入 6 月 37 日时创建一个错误提示。 我在一个非常简单的意图上使用@sys.date,它
有没有办法以编程方式获取 Dialogflow 代理的对话历史记录? 我使用 Dialogflow 制作了一个聊天机器人。现在我需要以编程方式获取代理的对话历史记录。 最佳答案 That featur
我正在研究 dialogflow 跟进意图。结构是这样的。 它为每个新意图创建新上下文。 例如在重复意图中看到 每当我创建任何新意图时,它都会为其创建新上下文。正如你在图片中看到的那样。当我尝试删除这
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 4 年前。 Improve this qu
例如,如果您有 IntentA 并添加了 2 个后续意图:IntentB、IntentC,它工作正常,它应该添加一个上下文,因为它还没有输出上下文。但这就是问题所在。有时如果你添加另一个,例如 Fal
我正在使用 dialogflow 开发语音助手,我对意图的生命周期有疑问。据我了解,生命周期值为我提供了此意图中可能的交互次数。它在每次交互时递减,当等于 0 时,该值不能被识别为意图的可能值。 生命
我创建了一个聊天机器人,它会通知用户我(大)家庭成员的姓名以及他们的生活地点。我用 MySQL 创建了一个小型数据库,其中存储了这些数据,并在适当的时候使用 PHP 脚本获取它们,具体取决于用户与聊天
我想使用 dialogflow 进行注册。例如:我想让机器人问以下问题: 你叫什么名字?你的邮箱是多少? 等等。 我尝试实现此功能,但无法正确管理意图。我应该怎么做才能实现这一目标?谢谢 最佳答案 首
我希望尽可能生成动态文本而不需要创建 webhook。我知道创建动态文本的唯一方法是根据参数创建不同的路由或通过 using inline system functions像文本实现中的 $sys.f
我使用 创建了一个聊天机器人对话流 并与 集成Telegram、Facebook Messenger 和 Web . Dialogflow 的响应是通过 创建的履行用 Python 编写。 在 Tel
我使用 Dialogflow 创建了多个代理,其中许多都在生产中。但是,Dialogflow 项目突然消失了,现在我只能看到创建新代理的选项。 但是,我看到生产代理运行良好。我通过我创建的连接到 Di
我是一名优秀的程序员,十分优秀!