Sha*_*ank 6 asynchronous request-timed-out sendasynchronousrequest dialogflow-es
我正在使用Dialogflow创建一个代理/机器人,它响应不同类型的用户查询,其中包含"我需要从HR获取地址证明的信件"等操作项.这需要机器人从公司的数据库中获取一些信息,并通过在人力资源提供的模板化字母文件中填充检索到的信息来生成文档/字母.执行此操作的逻辑已经写在python文件中.使用Webhooks完成数据库集成.
问题是,解释用户请求,打开数据库和检索所需信息的完整过程需要5秒以上,这恰好是Dialogflow代理的响应超时限制.我对此做了一些研究,发现我们不能增加这个限制,但我们可以通过异步调用保持会话存活.我无法找到提供答案的正确资源.
所以,我的问题是 -
我们可以在对话框流中进行异步调用吗?
如果是,那么我们如何通过json将异步数据发送到Dailogflow代理?
有没有其他方法可以解决这个5秒响应超时限制?
提前致谢!
我刚检查了Google文档上的操作和Fulfillment文档页面,确实有5秒的超时限制.
这可能不是最好的解决方案,可能不适合您的情况,但考虑给定严格的5秒窗口(我们希望确保动态对话,而不会让用户等待太长时间)
您以异步方式使用第一个意图开始计算,然后返回给用户并告诉他们在几秒钟内请求结果,同时计算完成时.它将被保存在一个私人空间给用户,此时用户将触发第二个目的是将请求的结果,在此期间将已预先计算的,所以你可以获取并返回它们.
小智 5
您可以通过设置多个后续事件将 5 秒 Intent 限制延长至 15 秒。目前只能设置3个后续事件一个接一个(可以将超时时间延长到15秒)。
以下是您如何在运营中心执行此操作的示例:
function function1(agent){
//This function handles your intent fulfillment
//you can initialize your db query here.
//When data is found, store it in a separate table for quick search
//get current date
var currentTime = new Date().getTime();
while (currentTime + 4500 >= new Date().getTime()) {
/*waits for 4.5 seconds
You can check every second if data is available in the database
if not, call the next follow up event and do the
same while loop in the next follow-up event
(up to 3 follow up events)
*/
/*
if(date.found){
agent.add('your data here');//Returns response to user
}
*/
}
//add a follow-up event
agent.setFollowupEvent('customEvent1');
//add a default response (in case there's a problem with the follow-up event)
agent.add("This is function1");
}
let intentMap = new Map();
intentMap.set('Your intent name here', function1);;
agent.handleRequest(intentMap);Run Code Online (Sandbox Code Playgroud)
要了解有关自定义事件的更多信息,请访问此页面:https : //dialogflow.com/docs/events/custom-events
| 归档时间: |
|
| 查看次数: |
6730 次 |
| 最近记录: |