dialogflow-es - 如何在对话流中的一段时间后调用事件
问题描述
我正在尝试使用对话流构建一个聊天机器人,我试图在一段时间后调用一个事件,如下面的代码所示:
function createLink(agent) {
setTimeout(cnf, 3000);
agent.add(`Please complete payment by clicking (https://www.aa.bb)`);
}
function cnf(agent) {
console.log('In cnf');
agent.setFollowupEvent('cnf_event');
}
日志显示 cnf 函数已执行,但 dialogflow 从未执行 cnf_event
这里发生了什么,我该怎么做
任何帮助,在此先感谢!
解决方案
您需要agent
在 set-timeout 函数内传递,
function createLink(agent) {
setTimeout((agent) => {
cnf(agent)
}, 3000);
console.log(`Please complete payment by clicking (https://www.aa.bb)`);
}
function cnf(agent) {
console.log('In cnf');
agent.setFollowupEvent('cnf_event');
}
推荐阅读
- java - 如何使用固定输入创建 GraphServiceClient 的 IAuthenticationProvider 对象
- python-3.x - 如何使用 sqlalchemy 和 sqlite 测试 mysql 查询?
- c# - 部署到 EC2 后,NLog 不会发送到 papertrail
- android - 如何删除 android 上的 react native firebase 通知点击操作?
- c++ - 静态编译 GRPC C++ 服务
- rxjs6 - RxJS,无法让 pipe(toArray).subscribe 工作
- macos - Mono 附带的 nunit-console 已弃用,请使用 Nunit Nuget 包或其他获取 NUnit 的形式
- angular - Angular 7 无法访问管理文件夹文件
- mongodb - 我可以用MongoDB官方Golang驱动找到一条记录,但是记录是空的
- angular - 使用 angular-cli 定义一个全局 sass 变量