How to create workflows around whether a user is currently in your web-app or not?

Hello everyone.

I was not sure where to ask this in the forum, but I’d appreciate some help.

I’m working with a client to build an on-demand fuel delivery web-app called JuicedFuel. It is similar in function and feature to on-demand apps like DoorDash and UberEats. Customers submit fuel request for their vehicle and a driver fulfills the request.

Like DoorDash, I’ve built an in-app chat messenger that will allow customers to send messages to a driver during when a fuel request is being delivered. This part works fine, but I need help fine tuning how each user receives a notification when they receive a new message.

There are 2 types of notifications I need help with. One is when the user is actively in the app, and the other is when the user is NOT actively in the app.

Essentially, if a customer/driver is in the app when the driver/customer sends a new message, they’ll receive an in-app notification about the new message. But if the customer/driver is NOT actively in the app when the driver/customer sends a new message, then they’ll receive a text notification about the new message via Twilio instead.

My question is if its possible to build workflows around whether or not a user is actively in the app, in this case web-app?

I hope I explained myself clearly.

Thank you

Hi @randreas I use the following plugin to achieve something similar, Detect Inactivity Plugin | Bubble so you can trigger a WF when a user becomes inactive.

I suggest you use a field in the user table and toggle it if user is active in the app or not and trigger the corresponding WF when a message is sent.

1 Like

That might be exactly what I’m looking for.

And oh look, it’s a free plugin! What a treat! lol.

Thank you. I will try this out.

1 Like

Hello again. That was a great suggestion. I only got it working a little bit.

I built a new field for users simply called “active” and set it as a yes/no. On my index page, where the users will mostly be, I created two workflows. One that changes the “active” field for the current user to “yes” if they are active, and one that is meant to change it to “no” if they are inactive.

I am running into issues with the “no” workflow. I believe it is because I am having it run on a “current user” but if that user does not have the web-app opened they do not count as a “current user”.

Any suggestions on how to get this to work for users who might have closed the web-app/app entirely? This would come in handy for if they’re both logged out and receive a message, or logged in but have either closed the browser or tab for the web-app, or app.

Thanks

I get you, you might be able to achieve this without any plugins then, by running a workflow every X minutes and modifying a user field with the timestamp the user was seen.

When running the message notification workflow, you run a check on that timestamp field, if it’s Y seconds/minutes after the last update, you can assume the user is offline and send a push notification.

This will definitely have a slight gap where the user could get an in-app notification but have the app closed. If the user is logged out, there is not much difference since Twilio sends the message to a Device ID which is associated to the user.

Hope I’m clear enough.

Thanks again for you reply. Yes, I believe I understand. I’ve decided to tackle this issue a bit later but will return to your comment for direction.

I hope all is well. I may end up replying again lol