Adalo Chat App Template - How to Remove Duplicate 'conversations'

I created a new app using the template after your message.

The template app as is doesn’t have any actions for the ‘Friends’ relation, which may be the bug.

But I get the general concept now -

  1. Friends is a M:M relationship within Users
  2. when a user initiates a new conversation with a new user in the ‘Start Conversation’ Screen, along with the set of actions present in the template, both the initiating user & the newly selected user should be updated by adding each other to their ‘Friends’ column (these actions are currently missing from template)
  3. then apply the filters as you mentioned.

I think that should work. Let me know if I’m wrong.

Pardon me if am wrong,

i think the issue here is how to continue an existing conversation and how to prevent a double appearance of a conversation.

Let me use the example of my app:

An admin views a list of people he can chat with. He/she selects the person with whom they want to talk with.They then are directed to a screen where there is more information about the person. They then click a button to message the person and the database creates a new conversation, adds the two users (Current user + Logged in user) and then links to the chatting inbox .

There are few options for this:

  1. In the chatting inbox,filter the messages so that it appears like the conversation exists to the user.
  2. Create two buttons and toggle their visibility; one to show when the conversation exists (Link to the chatting inbox and populate the list with the messages from both two users) and another button to show if no conversation exists between the two users (chatting inbox appears empty)
  3. Create a true/false field in users and toggle it once a new conversation is created. Then add a filter to 2 above

But i have tried and none seems to work. If only there was a way to control the creation of a new conversation each time, i,d be very far :no_mouth: :no_mouth: :no_mouth: :no_mouth:

Help guys!

Hi Caleb

The reason for me initiating this thread was to talk specifically about the standard template, so everyone is looking at exactly the same database, actions, screens, etc.

So within the context of this standard app template, what Ben has suggested has worked. I have implemented the changes - with a few minor visibility filter modifications, and adding current user + logged in user as each other ‘Friends’ in new M:M collection column - and can confirm it works.

The way you want to implement your User Flow + UX sounds like it should work in theory. I’ve not implemented your logic or seen your app, so I can’t say why it doesn’t work. Perhaps you can share a video of your app (via loom etc) & others can help.

https://previewer.adalo.com/5e449fae-7de5-4278-93f7-0dd8782aeb4f

Hi, this is a dummy of the app maybe you can explore

Everytime you click the chat with user button, it creates a new conversation, adds both users and creates a read status.
Is there a way ican control the creation of conversations such that if the conversation already exists, it shows the conversation messages and if the conversation does’t exist, it creates a new one.

1 Like

Bump this please. Is there a known solution to this? Seems like the chat template has been out for a while. Even @pford’s Instagram Clone does this as well.

This being:

“Everytime you click the chat with user button, it creates a new conversation, adds both users and creates a read status.
Is there a way ican control the creation of conversations such that if the conversation already exists, it shows the conversation messages and if the conversation does’t exist, it creates a new one.”

Yes actually there is a solution for this although it is not an elegant one. I’m working to update the Instagram course to fix this issue. Basically you have a list of conversations that shows only the conversations between you and that user(s). The conversation is shown as a button identical to the one that creates a new conversation however the visibility is determined by the count of the conversations you share between you. If it’s less than 1, the button for creating a conversation shows. If it’s 1 or more, the list of conversations shows with only one item. Clicking it takes you to the current conversation.

5 Likes

Amazing - thank you Patrick. You’ve been an inspiration and I’m currently building my dream app in Adalo now because of your fantastic teaching on No Codery @pfordmedia

@pford I’ll be waiting to preview your changes.
@Ben
…is there a way we can fix without having the conversation lists?

Sample use case:

https://previewer.adalo.com/5e449fae-7de5-4278-93f7-0dd8782aeb4f

Can i toggle the chat button here so thati have two, one which creates the conversation whenever the conversation does not exist…and make it visible whn no conversation exists

Or
A second button which connects to the chat inbox with messages of existing conversation?

Video recording here

found a soluiton. Thank’s so much for this pford

@pford

You sir, are a GENIUS! :raised_hands: :raised_hands: :raised_hands: :grin:

Hey Ben and @pford ,

I am trying to do the solution you mentioned on the Chat template but somehow I am not seeing the "Current User’’ to be selected.

Hmmm. Are you linking to this page from a list of users somehow?

Hi - How exactly did you count the number of conversations between two users, apologies for the dumb question its been a long day!

Great question. It actually uses a text field in the conversations collection called Participants Index that is a concatenated field of both users emails. The Conversation count is then filtered by if the Participant’s Index contains the current user email and also the Logged in use email. If the count is greater than 1, the list appears. If the convo count is 0 then the button to create a new convo appears.

2 Likes

@pfordmedia Thank you for the explanation! I managed to make the buttons appear/disappear based on the Participants index, but I still have an issue of redirecting the logged in user directly into the current conversation in case it exists as the current conversation data is not in the transferred data as I am trying to send that message from a different screen, not the one that has a list of conversations… so the only way I can do it, as it seems, is to redirect to the list of conversations first… but if there are already many of them there then it is not user friendly… what am I doing wrong or how is it possible to still redirect directly into the current conversation like it is in instagram? Thanks again for all your support! It is really helpful:)

Yes it’s kind of weird, but basically the button itself needs to be a list of conversations that is limited to show only the conversations where both people’s email is in the participants index. Rather than just changing the visibility of the button, these will be filters on the list. You can make the button a list by clicking on the button, then the three dots, then Make List. That button within the list will send the user directly to the messages screen.

Sorry for the way late reply. To count the conversations you share with another user, you’ll need an Index (text field) of all the user’s emails. You will then count the number of conversations where the Index contains both the Logged in user’s email and the current user’s email.

@pford now it works! I really did not have the button as a list… Thanks!!

The only question left is how to make the buttons always invisible at all if a user sees his/her own post with no possibility to set a chat with him/herself? It still sends to a chat but to the conversation with the other user. Could you please advise? I thought that would happen by default but somehow I still see that button and it redirects to one of the existing conversation with one of the users… thanks again!

I fixed it! So there is no issue anymore. Thanks again!