# Chat function

**URL:** https://community.glideapps.com/t/chat-function/63216
**Category:** Ask for Help
**Created:** [June 27, 2023, 4:46pm UTC](https://community.glideapps.com/t/chat-function/63216 "2023-06-27T16:46:17Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![nathanaelb](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nathanaelb/32/43079_2.png) [@nathanaelb](https://community.glideapps.com/u/nathanaelb)
#### Post date: [June 28, 2023, 2:04pm UTC](https://community.glideapps.com/t/chat-function/63216/3 "2023-06-28T14:04:46Z")

</div>

With the new comments collection, you can achieve both a global chat and 1:1 chats.

**Data Editor**

In both cases, in the Data Editor, you’ll need one Comments table. All messages of all chats will appear in this Comments table.

 ![CleanShot 2023-06-28 at 15.57.06@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/0/b052f574f6e06dc59c45190b2d91633aa0479ba3.jpeg)

- For the global chat, 4 basic columns: Comment, Timestamp, User Name, User Photo
- For 1:1 chats, 3 additional basic columns: ChatPerson1, ChatPerson2, ChatID. In the ChatPerson columns, write the email addresses of the people chatting. ChatID is a template column. My ChatIDs are not the best since I actually have two possible IDs per unique (X-Y and Y-X), there might be a better way to do this.

**Display Editor**

- Global chat: new screen with the Comments table as source, add Comments component, point to data, filter the data to show only rows where ChatPerson1 _or_ ChatPerson2 are empty (or ChatID is “-”).

![CleanShot 2023-06-28 at 15.48.37@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/a/0ae598180810f9f2ace17cdb84d5d91bb00d6ed5.png)

- 1:1 chat: Add the Comments component to the User Profile screen, adjust visibility (email isn’t signed-in user), filter data along the ChatID (ChatID includes user email _and_ ChatID includes screen email).

 ![CleanShot 2023-06-28 at 15.50.25@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/2/f2358d703f1652d75395b4b1ece2eb445764a052.png)

---

_[View the full topic](https://community.glideapps.com/t/chat-function/63216)._
