Share feedback, ideas and get community help

Updated last month

Execute a script when user abandons chatbot flow?

At a glance

The community member is managing a queue of users for a payment action using an array, and the issue is that when a user abandons the chatbot flow, their position in the array gets stuck. The only way to remove a user from the array is to restart or complete the chatbot flow. The community member is using Twidget.io to manage the queue via API calls to a database, and they are wondering if it's possible to execute a script when a user abandons their chatbot session in Typebot.

In the comments, another community member suggests that refreshing the page doesn't actually remove the user from the queue, and they are trying to understand the current setup and the desired result. Another community member notes that it's not really possible to execute an HTTP request when a user kills the tab. They suggest exploring the Navigator.sendBeacon() API, which could be a potential solution.

The original community member provides more context, explaining that they are emailing users a link with two URL parameters to start the chatbot flow, and when the user goes back to their email and clicks the link, they can immediately clean out the user's keys (IDs) from all arrays they are included in. This helps manage the queue and keep it in the order of First In, First Out.

In the final comment, the

Useful resources
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