Chat Functionality Help

Hey, i’m creating an e-commerce app like amazon and wanted to add a feature to it:

How can I create a button on the product page that says “Contact Seller”
When clicked it should create a conversation between the buyer and the seller where they can chat about the product and sell it.

In terms of database, relationships and click actions. How can this be made possible?

What i’m mainly stuck at: When I add a relationship with “User” and “Conversation”
Should I do this twice to add “Seller” once and then “Buyer” the second time? (One to many)

Any help is appreciated. Thank you

Hi Aryan,

You can create a Many to Many relationship and add two Update actions to add the logged in user (buyer) and the seller.

Thank you

1 Like

Thank you so much for the help!

1 Like

Your Welcome!

I recently implemented a similar functionality. I thought about the many-to-many collections approach but somehow couldn’t make it work to properly manage an “unread” status and display Icons accordingly.

I ended up using two one-to-many fields for the two participants in the conversation and two unread fields for both participants.

Now that I think of it, I might give the many-to-many approach another try.

How did you manage to have an icon show for when messages are read and unread? That’s a feature that would be great for this!

Maybe this thread will helps you.

This is amazing and very helpful! You sure do know your way around Adalo and it’s great to see you helpout!

1 Like

@dilon_perera is there also the possibility to notify multiple users at the same time in a group chat?

Yeah

@njimmy10 not very helpful! can you please explain?!

@Victor I’ve seen your great video on chat app enhancements. My problem is, that the unread and read status is only updated upon a refresh of the website and not immediately. The same goes for new messages, they are only displayed upon reloading the app.

Also: if the messages are sorted chronologically (latest message at the bottom), how can I tell the list component to scroll down to the bottom or start at the bottom (like whatsapp)?

@silentdrummer The badge or a notification like trigger notifications?

In that screen go to the Edit Styles and enable the Reverse Scrolling.

Hi @silentdrummer,

You need to turn the list auto-refresh on (see “advanced” section of the list).
As for the scroll to the bottom - Dilon has already answered, you need to turn the reverse scrolling on.

In general I’d avoid using Adalo for massive chats - there is a big chance this will become very slow when you have 100+ messages in a chat.

Best,
Victor.

1 Like

And this will stop working when you have approx. 200+ users with 10-20 M2M relationships each. Adding a relationship will take several seconds then.

I would not recommend using many-to-many unless it is absolutely required and would try to use junction tables whenever possible.

Best,
Victor.

1 Like

Thanks @Victor and @dilon_perera!

As for the Reverse Scrolling: this actually loads the normal way but then just scrolls down to the bottom, “bouncing” up and down several times when the end is reached. looks like a cheap workaround to me which probably doesn’t work along with “only load & display visible items” and will most likely result in poor performance in longer chats.

As for the Auto-Refresh: I have had auto-refresh turned on, and it does work quite well on the chat screen. I do, however, have a text component on the message overview where the last message of each chat is displayed, and this doesn’t get updated automatically when another user writes a message although I have auto-refresh on for both nested lists. I need to reload the app in order for the last message (and the unread status) to be updated.

@Victor, I’ll give your suggestion for the junction table a try as soon as I notice performance problems, but the chat probably won’t be too big anyways.

thanks a lot!

2 Likes

For this there’s a component called Real Time Chat made by Pragmaflow.

Working very well.

Thanks @dilon_perera , but unfortunately it seems that Pragmaflow has removed all components from the marketplace:

1 Like

Yeah. Hope they will come back very soon!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.