How can I implement a social network style new activity red bubble?

Like this:

Screen Shot 2020-09-21 at 6.32.49 PM

Hello again @GB44 :slight_smile:

This should also be relatively simple to achieve. It depends on how you have set up your data base so I’ll go with a generic example.

  1. we have a field under User, called notifications. Each time a workflow runs that would trigger a notification. You would add to that workflow an action with something along the lines of “Change thing > User > Notifications +1” This will increase the number of notifications each time the workflow is run.

  2. You can now add a little red group, make it round by setting the roundness to 100 of course. Then add a text element inside the little red group. Call for dynamic data “User’s notification” and voila. You will now display how many notifications a user has.

  3. When a user reads a notification, you can clear it by running a workflow “Make changes to thing > User > notifications -1”

There are several ways to achieve this, this is just one way, so play around with what works for your set up :slight_smile:

1 Like

@casheets123 has proposed a nice way to go about it. I build a notification system in a slightly different way.

  1. A notifications DB
  2. A nested DB for notifications inside the user (list of notifications)
  3. A “last seen” data type in the user that gets updated with the current time when you open the notification’s group

This method allows a little more flexibility where you can filter notification types, show users different :count based on different criteria, etc.

So the notifications :count is all notifications inside the user’s DB that were created after the last seen.

Both approaches are good, I think, and depends on how much complexity you want.

1 Like


Screen Shot 2020-09-21 at 8.35.20 PM

Thanks. Yes I think I’ll want something more than a counter since I’d like to provide notification details. Egs:

  • user x commented on your post y
  • user x upvoted your post y
  • user x added a new post for a tag you follow
  • Etc.

I’m thinking a need an Notifications data type along the following lines:

  • User to be notified (it’s their feed)
  • User performing action (eg user x)
  • Action performed (eg commented on post, upvoted post, etc.)
  • Subject of action (eg post y)

Yup, I’ve a similar notification system for my site (users interact with other user’s posts) and I’ve set it up the way you have described.

1 Like

Good to hear. Do you ever clear out that Notification data type? Eg only keep say the last 6 months’ of data? I can imagine it getting pretty big over time.

As the number of users and activity increased, I removed the list of notifications from within users. Now I use inverse linking, and that works fine. So Notification is a table, each Notification has a recipient (user), and the Notification RG uses a “Do a search for” recipient=current user.

Not that list within users had problems, I read a post by Josh (Bubble co-founder) recommending not to use lists if >100 or so.

I have been actually thinking about my retention policy for notifications. I noticed that there were a few cases where a user logged on after 45 days. So I’m thinking of keeping my retention window to 60 days for read notifications and 120 days for unread. As the activity increases, I’ll make it more aggressive.

@deadpoetnsp I’d love to know how you implemented this. Specifically appending new activities to the Notification table when a qualifying event (eg user posts).

Eg IF I User X submits a new post AND Users A, B, and C are all following User X…

How do I add 3 records to the Notification table as follows?

User to be notified | User performing action | Action

User A | User X | New post
User B | User X | New post
User C | User X | New post

In a traditional coded app I imagine I’d call a function that determines who is following User X and then appends an entry to Notifications for each user following User X

might suit some use cases

1 Like