Programmatically log off user, after Xmins of inactivity

I am successfully running this query to tell me how many mins have elapsed since the last user activity.

SELECT
users.email,
MAX(users."lastActive") AS last_time_active_timestamp_utc,
EXTRACT(EPOCH FROM (CURRENT_TIMESTAMP - MAX(users."lastActive"))) / 60 AS minutes_elapsed
FROM users
WHERE users."lastActive" IS NOT NULL
GROUP BY users.email
ORDER BY MAX(users."lastActive") DESC

Now, I want to take all the users who had >15mins of inactivity and (a) log them off if their screen is open (b) log them off if they try to do something else at Retool.

Hello @Ori,

You need to create a workflow to monitor user activity and automatically log out users who have been active for more than 15 minutes.

Workflow Requirements:

  1. Track Last Activity: Check how long each user has been active since their last recorded activity.
  2. Filter Users: Identify users whose active duration exceeds 15 minutes.
  3. Logout Inactive Users: Use a JavaScript condition to log out these users by calling utils.openUrl(url, options) in Retool.

You can read more about the utils.openUrl() function in the Retool documentation.

Sample Logout URL:

https://[your-domain].retool.com/logout

Replace [your-domain] with your actual Retool domain.

Here’s a sample visualization for your reference:

Let me know if you have any questions or need further assistance—happy to help!