Share feedback, ideas and get community help

Updated 2 days ago

Execute a script when user abandons chatbot flow?

I encountered a problem where a user abandons their chatbot flow (ex: closes their tab).

Since I'm managing a queue of users to perform an action (make payment) with an array, their position in the array gets stuck there.

With my current chatbot setup, the only way a user can get removed from the array (queue) is to restart or complete the chatbot flow.

Btw, I'm managing the queue via API calls to my database using Twidget.io.

With Typebot, is it possible to execute a script when a user abandons their chatbot session? Something like an event listener?

I would love to be able to execute a script to remove the current user from the array (queue).

Thanks!
A
B
n
6 comments
Heya nefer,
With your current setup, since your queue's updates relies on an API call, you said that the only way a user can get removed from the array is to restart or complete the flow.

However, if they restart the flow (eg. refresh the page, if that's what you meant), does it really remove them from the queue? That would mean you're making an API call at the start of the flow to check if the user is already in the queue?

I'm trying to understand what happens when currently and what should happen when (expectation/desired result)
Not really possible to execute a HTTP request when user kills the tab
Hey Anthony πŸ‘‹πŸ»

You're right. Refreshing the page doesn't remove the user from the array (queue).

However, when the user goes back to their email and clicks on the link with the two keys I provided them, they start the chatbot flow, then I immediately clean out their keys (ids) from all arrays they are included in. This helps me manage the queue and keep it in the order of First In, First Out.

For context, I'm emailing the user a link with two url parameters like this:

domain.com/page?id_a="111"&id_b="222"

id_a and id_b are the keys to start the chatbot flow. If a user refreshes the page, the keys will not be included and the user will get a message to go back to their email and click the link to start the chatbot.
Update: I found a suitable solution.

I ended up using an external service (ActivePieces) that monitors my payment queue.

It's only job is to clear the new user when they reach the payment queue.

It gets the job done for now πŸ™‚
Add a reply
Sign up and join the conversation on Discord