💬 Chat Component: A Complete Walkthrough

:wave: Hey fellow Gliders!

The Comments/Chat component is a one-of-a-kind component that acts as both a Collection Component and a Form Container. The uniqueness of this component requires that we understand both its strengths and quirkiness.

The video tutorial below walks you through:

  1. Setting up a messages table and table hierarchy
  2. Setting up the comments component
  3. Differentiating between the comments and chat views
  4. The After Submit action
  5. Hacking the component to add images to chat messages

:popcorn: Enjoy!

20 Likes

Instant bookmark. Thank you!

3 Likes

Thank you Bob :pray:.
This is gold for me at this point. :hugs:.

1 Like

Let me know if you have any questions!

1 Like

Great video Robert! Legend.

Just thought I’d add a little extra to the ‘add image’ to a chat/comment if it helps anyone. This relates to the section when adding html to a template column.

When adding an image to a comment (Not chat) component it doesn’t have a container binding the content so using e.g. “width=90%” doesn’t seem to work.

After some tweaking I found the following html works well to make the images fit well and be rounded like the default Glide format so it all matches nicely.

<!img src=“image_path” style=“max-width: 200px; max-height: 200px; object-fit: contain; border-radius: 10px; float: right;” alt=“Image with Rounded Corners”>

(Please remove the ! symbol at the start if copying this code)

Just an extra hint for folks is to be sure that you don’t use a number or symbol to replace in your template that is in your html. Something like replace with ‘Z’ might be a safe bet. So just replace the “image path” with e.g. “Z” and you should have a nice looking comments with the add image option.

Cheers

3 Likes

If you would like to just click on the image and open it in a new browser use the following html in the template column.

<!a href=“link_path”>
<!img src=“image_path” style=“max-width: 200px; max-height: 200px; object-fit: contain; border-radius: 10px; float: right;” alt=“Image with Rounded Corners”>

(Remove the ! if copying)

Replace “link_path” and image_path with e.g. “Z” and that should do it.

Also, adjust the px width to whatever works for your APP.
Cheers

2 Likes

Amazing tutorial as always! Thanks so much for putting it together. A great complement to the Social Profile and Group Chat template I bought a while back.

Quick question on private chat. I have an app which has a Users table, protected by row owners, and a Public Profile table which is effectively a replica of some of the information from the Users table (without email addresses, but does include the Row ID from the Users table). I’m using Glide Tables exclusively.

I’d like to create a private chat which uses Row Owners for Chats and Messages, but - as the email field isn’t available from the Users table, even with lookups from the Public Profile table - it’s not possible to populate the “Recipient” column with the recipients email address (the owner of the public profile), when initiating chats from Public Profiles.

Would love your thoughts on alternative options for this, bearing in mind Row Owners can be email addresses only, not User IDs/Row IDs. Thanks :raised_hands:

I completely understand where you’re coming from. I wish that Glide allowed us to use the RowID of the Users Table as an alternative to the email address when enabling row owners. Perhaps I should make a formal feature request if it doesn’t already exist.

To make a truly private chat, you’ll need to use row owners. The only way to enable row owners (in this use case) is by leveraging email address. The only way you could allow email address and maintain user privacy is by enabling “anonymous emails” in the app settings.

Perhaps someone else can chime in here.

Thanks, Robert - I think a formal feature request would be great. I’ve had a look and I’ve not seen any formal requests in the community. Quite a few threads (example) from folks trying to work around it.

RowID of the Users Table feels like just as solid an identifier as email. But they offer an additional level of privacy-friendliness that would be appreciated.

I haven’t watched the video so thank you for your patience if this is out of context. I’ll often use a user’s row ID as their role, and then use their role/rowID as a row owner in another table. Might be a good fix if you aren’t already using roles or don’t have a lot of users, or don’t have any public users… or or or or… :crazy_face:

1 Like

Using rowID as role is interesting. Yes, ias long as

  1. your users are already private users and
  2. You don’t need roles for anything else
    This could work.

The other roles I use are Admin, Manager, or something that has access to everything. I use a column for each on each table that I want to give them access to and the rowID role for users. Doesn’t apply to every app, but it works well for those that do.

1 Like

Interesting suggestions - thanks so much, really appreciate it!

This would be a public app with 000’s of users so it might not suit. But has definitely inspired me to try some other options… Thanks again.

Hi Robbert!

Great built! Thank you for that!

Question: Do you have suggestions to control the used rows? After using in a production environment for a while the rows limit will be in effect.

Sure, there is a way to delete older rows automatically when adding a new row, but can you think of a way to control the quantity of the rows and still keeping them?

Regards, Ronald

You could add some really tricky logic (using a helper table) to set a threshold of messages and then auto delete ones outside that threshold.

Or, you could create a shadow copy of all rows into a big table, but that would really only deplete your row quota faster.

1 Like

Thanks for the demo Robert! Very helpful!

Two issues I’m having…

  1. When chats get long, the chat page opens at the top of the page and users have to scroll all the way down to see the bottom of the chat. I’d like to keep newest comments at the bottom of the chat, any ideas on how to get the chat to open at the bottom of the chat?

  2. When creating a new chat comment that is more than two lines, text input box drops below the top of the phone keyboard and users can’t see what they’re typing. Has anyone else had this issue? Is there a fix?

Thanks!!

Edit: I had a header image with the chat name and image, plus an edit button. Once I deleted that the message box works now and the page opens to the most recent message at the bottom of the page. I think the header forced the chat to open and display the header and forced the text box to be pushed down as well.

This is what I was going to ask. I mentioned this in the video. I wish it weren’t the case, but ya, the chat component has to be the ONLY component on the screen for it to work properly.

1 Like

Yeah, it kinda stinks. Even without the header image, there are still small issues. When the app is first opened, the first chat you open shows the top of the comment screen, which in my case is the oldest comments. If you go back to the chats page and reopen the same chat, then it shows the bottom of the screen, which is a clunky work around to scrolling to the bottom of the page.

Does anyone know if it is at all possible to link to another tab without the app refreshing. Usually you could just use a button or a component to link to a page. I’ve built a chat bot that says you can “go to the events page, to see what future events are coming up” but instead of saying that is there a way to use HTML text to show a “click HERE to view events” I could use slug of the TAB but it reloads the app.

Sorry it’s a bit confusing

TIA

Can you not use a Go to Tab action?