Forum Academy Marketplace Showcase Pricing Features

How to create a private direct message system between users

Hello, I need a little guidance on how to build private messages for Bubble. Please show screenshots if you can. I’ve already used the forum search function and didn’t find anything. I searched bubble through Google and didn’t find anything either.

I figure that it’s a ubiquitous feature so it should be easy to build.

Sorry I don’t have any screenshots at the moment. But I’ll give it a go explaining with words.

First you’ll need a data type, something like “messages”:

Data Type — Message
Fields —
Message Body = text
Message sender = user
Message recipient = user
Sent Date = date (or just use the created date)

Now within the data type “user,” make sure you have a field Message which is a list of messages (from the DB).

When a user send a message, create a new Message populating the fields listed above. Then make changes to the users (sender and recipient) — add message to user.

In terms of notifying the recipient about the new message, perhaps an email, push notification, and/or text message will do the trick. The last two requiring you to connect the API yourself.

In terms of designing your message box on the users page. I’ve used pop ups and floating groups in the past. Using a repeating group at the top to display the messages, I’d create two groups within the cell—one for sent messages, and one for received messages. You can add a condition to show one of the groups based off “current cells sender” — so if current cells sender is current user, show the group that displays sent messages, and vice versa.

Lastly, a simple multi line input should do the trick for the user to type the message body.

Hope this helps. Sorry for the ramble, and good luck!

1 Like

Great stuff.

As a suggestion … a list of messages in the user data-type can load up pretty fast and slow down the app’s performance.

An alternative data structure could be to avoid having messages under a list in no data type. A … reverse relationship where each message has a field to … a thread perhaps could work much better. The thread has a list of users in it … and each message with a list of viewed users belongs to a thread. This could be more scalable. :+1:

1 Like