简体   繁体   English

Dialogflow-给定延迟后添加followupEvent

[英]Dialogflow - Add followupEvent after a given delay

I am trying to add a series of responses inside an intent handler and set a timer of 20 minutes which will trigger(at its end) a followup event. 我试图在意图处理程序中添加一系列响应,并将计时器设置为20分钟,这将触发(在结束时)跟踪事件。

So here is what I've tried: 所以这是我尝试过的:

agent.add(response_1);
//...
agent.add(response_n);
setTimeout(() => {
        console.log("Setting follow up event")
        agent.setFollowupEvent('20_MINUTES_PASSED');
      }, 1200000);

Even though the log was displayed, my function execution stopped before it. 即使显示了日志,我的函数执行仍在此之前停止。 I have checked the logs and I saw the message "Function execution took 26 ms, finished with status code: 200" displayed before "Setting follow up event". 我已经检查了日志,并看到“设置跟进事件”之前显示的消息“函数执行耗时26 ms,状态代码为200:”。

I know that each function has a 3-5 sec timeout and I understand this is why the function finished its execution, but I cannot figure out how to trigger that event after those 20 minutes... 我知道每个函数都有3-5秒的超时时间,这就是为什么函数完成执行的原因,但是我无法弄清楚在那20分钟后如何触发该事件。

There are two issues with this idea: Cloud functions aren't meant to run for that long, you would have to use either a real server or some scheduling service for this. 这个想法有两个问题:云功能并不是要运行那么长时间,为此您必须使用真实的服务器或某些调度服务。 However, Dialogflow doesn't let you do this anyway, webhook requests time out after a few seconds. 但是,Dialogflow仍然不允许您这样做,webhook请求在几秒钟后超时。 If you haven't send a response by then the agent will tell the user that your service is unavailable. 如果您尚未发送答复,则代理将告诉用户您的服务不可用。 You can also not initiate a new session without the users explicit request to do so, presumably because developers would quickly abuse this for spam etc. There is thus no way to trigger an event after 20 minutes. 您也不能在没有用户明确请求的情况下发起新会话,这大概是因为开发人员会迅速将其滥用为垃圾邮件等。因此,在20分钟后无法触发事件。

The closest to what you are looking for are probably push notifications , but they are very limited compared to follow up events. 与您所寻找的内容最接近的可能是推送通知 ,但是与后续事件相比,它们非常有限。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM