šŸ’¬ 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!

18 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?