Heya nefer!
After watching your recording, reproducing your current flow, thinking of and implementing the solution I had in mind, I can tell you I found a fix to your issue (and why yours was happening)!
Let me walk you through it:
Initial Issue- For some reason, even when defining your
cancelRefresh
function in the same script block as the setTimeout
, cancelRefresh
seems to not "exist" in the client like it does in the local console (the Typebot error stating that the function doesn't exist confirms my guess)
Solution- Instead of a
Script
Block to define your timerId
JS variable that holds the setTimeout
, I created a Set variable
block that sets a new Typebot variable timeId
, with the following code:
setTimeout(function() {
window.location.reload(true);
}, 3000);
We are now sure it would store that Timeout as a Typebot variable for later use.
- Next, after your button, use a
Script
Block (like you currently have), and put the following code in it:
clearTimeout({{timerId}})
This would clear the saved timeout.
I tested and it works. Hopefully it works for you too!
Here's a screenshot of the final flow: