i
Hi all, I want to know if I can add a timeout inside my chatbot flow, that when a certain point of the flow is reached there is a wait of certain time, I was trying with the CRON but it does not let me connect it to the part where I need it, something that can help me please? Or if you can tell me how to connect the CRON to any part of my flow I would appreciate it too 🙂
w
I think you can do this with a few lines of code in an execute code card
setTimeout(function() { console.log("Five seconds"); }, 5000);
something like that ?
i
Can you be more specific please?
I just ran it from the code, but it doesn't wait for the time it just goes into a loop and throws an error that mentions that part about it being in a loop.
a
Hi Pablo, by timeout do you mean a period of user inactivity? If so, there is a timeout flow available: https://botpress.com/docs/cloud/studio/workflows/
i
Mmmm, en el flujo hago una petición a un webhook para que consulte un dato que puede variar entre algunas opciones, si el valor de ese dato es uno en especifico entonces la funcion del codigo se debe ejecutar nuevamente hasta que ese valor ya sea diferente, normalmente ese valor cambia en 5 minutos, entonces necesito que cuando sea ese valor especifico el nodo de codigo se ejecute nuevamente cada 5 minutos
It is something like this, I have a delay that I tried to set with the previous recommendation but it gives me a loop error because it does not wait the 5 minutes. https://cdn.discordapp.com/attachments/1244655835620315268/1244665103769534464/image.png?ex=6655f035&is=66549eb5&hm=596e4408ba5160f081c389095d3220f5b1b15cd1989405aca25295663226898b&
Mmmm, in the flow I make a request to a webhook to query a data that can vary between some options, if the value of that data is a specific one then the code function must be executed again until that value is already different, normally that value changes in 5 minutes, then I need that when it is that specific value the code node is executed again every 5 minutes.
a
Sounds like you need a pause/delay. Try executing this code
Copy code
await new Promise((resolve) => {
        setTimeout(() => {
            resolve('waiting 5 seconds');
        }, 5000);
    })
i
Now every time the user speaks the Delay code is executed it does not come out of there.
Anything I can do to keep it on a little loop every 5 minutes?
a
Does it send a webhook request after finishing executing the delay node?
i
Yes
a
It means that it successfully completes the loop. Can you show me what is in the AI transition?
i
sorry, I got confused, no, it does not send the request after the end of the delay.
That's the chat, every time I send a message it runs again, and when the time is up, the code to send the request to the webhook is not executed.
What could I do now? @aloof-traffic-22451
a
If you need delay to be triggered when no AI transition categories matched, try to add a transition after the AI transition like on the screenshot https://cdn.discordapp.com/attachments/1244655835620315268/1244701867041230948/Screenshot_2024-05-27_at_1.20.01_PM.png?ex=66561272&is=6654c0f2&hm=608518706a16cc96f0aa65c3aa111e3c5728a33c5d5a9d31945051ebd4f9e751&
i
Yes, this is already configured, the delay is activated correctly, but when the time is over, it is executed again when the conversation is resumed.
a
Can you add a text card at the beginning of availability node to see if it gets executed after the delay?
i
I did it, and it does not run after the delay, it seems that the delay stays executed and does not come out of there.
w
Sounds that it is not possible to add a delay to more than one minute don’t you think ?
That’s what I understand from the error ( maybe there is a timeout for execute code card of 1 minute )
i
It seems that if that was the case, is there any way to set a longer time. THANK YOU VERY MUCH
a
For your particular case the easiest solution might be create a a bunch of cards that wait 45 seconds and stack them until desired time limit is reached
i
Thank you very much!!!!!!
a
You're welcome @important-king-60329 , glad it worked
283 Views