Best way to send a message to multiple users?

For reference, these are my data types and fields for Conversations and Messages:

The problem is in my workflow show above, I equated my conversations to a Do a search for :first item. So it ends up searching for only one conversation because my data field is not a list. Should I just change the conversation field to a list of conversations or is there a better fix to this? Or maybe the problem is elsewhere. Please let me know.

What happens before the create a new message action?

It is hard to understand the problem otherwise.

Perhaps you can elaborate a bit more what you are aiming for and how this action fits into its overall context?

Sure, so the module I am building here is an item search → select items → send inquiry to all selected suppliers.

Before the create a new message action:
All the selected items go into a data field called Products which is under the data type Pending Materials

then a pop up shows and searches for the last modified Pending Materials.

The user would then click the “Send Inquiry” button under the multiline input and that triggers the workflow to create a message. I have another workflow for the Send Inquiry button having the opposite of this Only when function that replaces contains with ‘doesn’t contain’, to create a conversation for users who don’t have one with each other yet.

A message is part of one conversation. Hard to think otherwise.

It seems that the problem is the locating of all users that would need to receive a message.

If the above is so, it seems that the challenge that you are facing is coming up with a way to identify these users. Correct?

I believe the problem lies in searching for the participants’ conversation with the current user. I was able to create a message and add all the needed participants, but it does not show up in their conversation.

Under my create a message workflow, Conversation = search for conversations: first item. I need it to search for each conversation the current user has with the selected items

Then I am confused. You are referring to a solution not working.

What is the problem?

A. Finding all participants of conversations where the current user is also a participant in to send them a common message? If not … what is B?
B. ?

Yes, A is the problem sir. My bad for not making sense :sweat_smile:

This expression gives you all conversationsParticipatingUsers where the currentUser is also a participatingUser

Hide this rg in a hidden popup and you can use the list of users it generates in further logic or actions like sending them a common message. Rename it to something like listOfPartcipantsToMessage.

Hope this helps :smiley:

yes, make it so that the two participants will only ever have One single conversation. You achieve this when creating a conversation to do so conditionally based on a search of existing conversations where the two participants are already the two participants, if yes, then do not create a new conversation, just add the message to the existing conversation, if no, then create a new conversation.

Also, it is not necessary to have the participants on the message as well as the conversation. Better to just be on the conversation.

I would not recommend having a hidden RG because that will just be loading data unnecessarily. Instead just put the do a search for conversations onto a conditional portion of a workflow trigger.

1 Like

is it possible to make the condition so that it would look for all conversations that the current user shares with the selected users and then send a message to all of those users?

then do not create a new conversation, just add the message to the existing conversation, if no, then create a new conversation.

Also, it is not necessary to have the participants on the message as well as the conversation. Better to just be on the conversation.

This would make a lot of sense but unfortunately Bubble isn’t that performant when it comes to long lists. Also a list can only have a maximum of 10K items. In theory, a conversation could have thousands of messages. Plus, having the participants on the message data type as well adds an extra layer of security. :slight_smile:

So you actually want to keep the DB structure that you currently have @kindlevega12

Nobody said anything about searching messages, it is to search conversations. Nobody said anything about making a data type of conversation have a list of messages as a field. No need to have the extra data on the message as it really doesn’t make any difference to security if you set everything else up properly.

Correct structure

Data type of conversation has field for participants which is a list of users

Data type of message has a field which is related to conversation, a field for body, and if you want include the IsRead…so yes, his data structure is correct, except for the part where the Particpants field is unnecessary on the message data type.

100% correct :+1:t2:

Many ways to change how things work. The suggestion on running a dynamic search is about getting those users through the current dB structure. Another way to avoid running this on page load is to display it via an action.

Still though …. Kudos on changing how things are done …. It may be the correct way to go in this case :+1:t2:

Nobody said anything about searching messages, it is to search conversations. Nobody said anything about making a data type of conversation have a list of messages as a field.

I’m genuinely curious now. You mentioned to “add the message to the existing conversation”. How would you set this logic up if not done with a list data field? Also, if you won’t be searching messages and you won’t be structuring these messages as a list on the conversation data type. How will you retrieve them from the db?

Regarding security, how would you structure the privacy rules of a message if you won’t be protecting them with this message participants contains current user?

You would be adding to the message data entry the conversation as a related field. This is for the purposes of being able to select a conversation and then display all messages that are part of that conversation.

When the search is done for conversations to see if both users are on a participant list together, that is just for the purposes of fixing the main issue as I saw it, which was that the two participants as the poster has set it up, are having multiple conversations and so the display of messages is a mess.

Because of that statement, it is clear the setup as is is generating more than one conversation, which is the main issue as far as I see it.

Additionally, the issue lies at the creation of a new message which is happening via a button click, so to search for existing conversations at the click of the button, you can either allow the user to be navigated to the messaging system where they would be immediately shown the conversation and can send a new message. Alternatively, if no previous conversation existed between the two users, a popup can be shown to send the first message, which when sent will also create a conversation.

I’d put privacy rules onto the Conversations so their conversations do not show up unless the user is part of the conversation which in turn handles the issue of messages privacy. Additionally on the Inbox page where the full list of conversations is displayed, I’d do a search for conversations and participant list field contains current user.

I’m not sure if Bubble made a change to this or not. I feel like I recall they made it so that hidden elements data are not fetched until made visible, but I get confused on what was old and what is new behaviors.

But one other way to do it is to have a conditional on an element that when page is loaded entire is yes to add the data source there instead of having the datasource on the main section.

… yeap another one to the list :+1:t2:

I have only when functions on 2 ‘button is clicked’ workflows. One that creates a conversation if the current user does not have one with the participant, and the other that goes straight to a message if the current user already has a conversation with the participant.

My problem still lies on how to message multiple participants by clicking one button

How many participants are in a conversation? Are you only ever having two participants, or is it dynamic because a team of people from a supplier may be involved in the conversation?

Basically, when you create a message in the database and have it assigned to a conversation properly via a data field of Conversation, any user that is part of that conversation as a participant would be, if everything else for displaying data is done properly, be able to see the message. You DO NOT need to create a separate message for each user that is a participant of a conversation, which means, you simply just need to create the single message and have the correct conversation added to the data field of conversation.

Click button and create message and assign the data field of conversation to the appropriate conversation.

There are only two participants in a conversation. I need the app to send the same message to multiple conversations in one click.