Direct Messaging Platform

What I’m trying to do:
Looking for a general framework on how to achieve direct messaging function between users. If anyone has any code, ideas, or helpful links, please share! Thank you:)

Hi buddy. I’m building an app currently in which I’m trying to do the same thing. Currently I’ve been working on other aspects but today I’ll be working on the messaging service.

My default plan is to use flow or linear panels. When I’ll test it out, I’ll tell you

1 Like

Here’s something to work from: Commenting system in Anvil - #3

Also relevant: Hangouts-like Chat Design

Aight I figured it out

I am not focusing on design right now but rather on making it functional. So I just created a table called Chat having a ‘USER’ column and the rest of the columns will be added automatically and have name of users. So suppose a guy called x want to message a person called y. Then, a row will be added having ‘USER’ as x and in y column there will be a nested list having all the messages and ‘r’ or ‘s’ as per sent or received.

Then I ran a loop in self liner panel in such a way that if if the value at index of 1 is r, it will be aligned left else right.

Tell me if anyone wants a clone.

https://anvil.works/build#clone:BV5HCYPIM3XMOVVA=4QPEFB6MWOSPLVA3XIVZFDKS

Here’s a clone. Try chatting with yourself from two different tabs to test it out. Messages are received instantly

thanks for the follow up! however, the link is invalid :confused:

https://anvil.works/build#clone:BV5HCYPIM3XMOVVA=4QPEFB6MWOSPLVA3XIVZFDKS try this one

Okay, so whenever I run it, it looks like I am getting this error:
“anvil.tables.NoSuchColumn: Row update failed: Column ‘Jake’ does not exist and automatic column creation is disabled.”

You’ll have to go to the data table settings and enable auto-create columns.

ok, that worked, but I got another error:
anvil.tables.TableError: Column ‘Sender’ can only be searched with a string (not a number) in table ‘Chat’

Be sure that you are selecting the names from both dropdowns. By default, ‘Ben’ is set as the default value for both. But you’ll have to change the names in both dropdowns. Even if you want to choose Ben, you’ll have to set the dropdown value to some other name and then get it back to ‘Ben’

okay, now I am getting:
AttributeError: ‘Chat’ object has no attribute ‘timer_1’ at [Chat, line 41](javascript:void(0))

however, i was able to send messages when I commented this line out # self.timer_1.interval=0

The timer is very important for making it functional. Btw I just realised why those problems are being caused. https://anvil.works/build#clone:BV5HCYPIM3XMOVVA=4QPEFB6MWOSPLVA3XIVZFDKS

Build a clone of this app. Then when you run it, copy the url and paste it into a new tab of your browser. Then choose different sender and receiver from both tabs. Like choose Jake as sender and Robin as receiver from one tab and Robin as sender and Jake as receiver from the other tab.

Then you can chat with yourself. And you’ll notice that the messages appear to you almost insantly.