Chat Database Setup
Before adding the chat components to your app, you need to set up two collections in your Adalo database: Conversations and Messages. This guide walks you through every field you need and explains how each one connects to the chat components.
Ask Ada to set this up. Copy the prompt below and paste it into Ada.
Before You Begin
You already have a Users collection in your app (Adalo creates this automatically).
You are using one or more of the following components: Chat Message List, Conversation List, Conversation Action Button, Chat Header Bar, or Chat User Picker.
Conversations Collection
This collection stores each conversation thread โ both 1-on-1 and group chats.
Go to your Database, click Add Collection, and name it Conversations. Then add the following properties:
Name
Text
Default Field from Adalo, can be left blank
Users
Relationship
Many-to-Many relationship to the user collection. This is where you add/remove users from a conversation. This is also the property you reference when sending a notification to the conversation.
Messages
Relationship
One-to-Many relationship with a message collection. A message belongs to one collection, but a collection can have many messages.
User1-ID
Number
Stores the Logged-In User ID when a new conversation is started. They are the conversation owner. This field helps identify which user should be shown in the Chat Suite components.
User1-Name
Text
Stores the Logged-In User Name when a new conversation is started.
User1-ImageURL
Text
Stores the Logged-In User Image URL when a new conversation is started.
User2-ID
Number
Stores the second user added when a new conversation is started. This field helps identify which user should be shown in the Chat Suite components.
User2-Name
Text
Stores the Current User Name when a new conversation is started.
User2-ImageURL
Text
Stores the Current User Image URL when a new conversation is started.
GroupName
Text
Saved when starting a group conversation. Using the Conversation Action Button, a field will appear to save.
GroupImage
Image
The group photo. Leave blank for 1-on-1 chats.
Last_Message_Time
Date & Time
Used to sort conversations newest-first in the Conversation List. Update this every time a new message is sent.
Last_Message_Text
Text
The preview line shown in the Conversation List (e.g., "Sounds good, see you then"). Update this field every time a new message is sent.
Conversation_Key
Text
A sorted string of participant user IDs joined by an underscore โ for example, 12,47 for a 1-on-1 between users 12 and 47, or 12,47,89 for a group. Always put the lowest ID first. Using the Chat User Picker, the ID's are sorted for you. The Conversation Action Button queries this field to check whether a conversation already exists before creating a new one.
TotalUsers
Number
Stores the total number of users in the group. This can be referenced on setup when using the Chat User Picker.
ReadyBy
Text
String of UserIDs who have read the conversation. This helps the Conversation List show a notification dot or not.
Draft
True/False
Stores if a conversation is out of draft mode and can be seen in a user's Conversation List.
Messages Collection
This collection stores every individual message sent in your app.
Go to your Database, click Add Collection, and name it Messages. Then add the following properties:
Message
Text
The message body.
Image
Image
An optional image attachment. Only needed if you are using Text + Image mode in the Chat Message List.
SenderID
Number
Stores the Logged-In User ID of the sender. This is what the Chat Message List references when moving the message to the right of the Logged-In User.
SenderName
Text
Name of the Logged-In User Name who sent the message.
SenderImageURL
Text
Image URL of the Logged-In User Name who sent the message.
Conversation
Relationship
One-to-Many relationship with a conversation collection. A message belongs to one collection, but a collection can have many messages. **This should already be set up if you have already set up a conversation collection from this guide.
Users Collection
You do not need to create the Users collection โ Adalo creates it automatically. Add the following two properties to it:
avatar
Image
The user's profile photo. Shown in the Conversation List and next to received messages in the Chat Message List.
The participant_key Field Explained
The Conversation_Key is a Text field that makes it fast to look up whether a conversation between a specific set of users already exists.
When you create a conversation, build the key by:
Taking all participant user IDs
Sorting them from lowest to highest
Joining them with an comma
Examples:
User 12 and User 47
12,47
User 3 and User 88
3,88
Users 12, 47, and 89
12,47,89
The Conversation Action Button filters the Conversations collection where conversation_key equals the key you build from the selected users. If it finds a match, it shows Continue Conversation. If not, it shows Start Conversation and fires your Create Record action.
Always sort the IDs lowest-first so the key is consistent regardless of who starts the conversation. If User 47 messages User 12, the key is still 12,47 โ not 47,12.
Need help? Visit the Adalo Community Forum or check the individual component help pages for setup walkthroughs.
Last updated
Was this helpful?