Bubble Docs
  • Introduction
  • New? Start Here
  • What is Bubble?
  • The Glossary
  • User manual
    • Getting started
      • What is Bubble?
      • Building your first app
        • Planning features
        • Database structure
        • Design and UX
        • eCommerce and payments
          • Shopping cart
          • Checkout page
          • One-time payments
          • Subscriptions
          • Marketplace
      • Creating and managing apps
      • The Bubble editor
        • Tabs and sections
          • Design tab
            • The element tree
            • The property editor
          • Workflow tab
          • Data tab
          • Styles tab
          • Plugins tab
          • Settings tab
            • Application settings
              • Custom headers/body
              • Visual settings
              • Social media sharing
              • Translating your app
              • Email settings
              • Collaboration
            • Custom domain and DNS
          • Logs tab
        • Tools
          • Key features
          • The search tool
          • The Issue Checker
          • The element tree
          • The element property editor
          • The debugger
          • Notes
        • Previewing your app
      • Transitioning to Bubble from...
        • JavaScript
        • HTML and CSS
        • SQL
    • Design
      • Elements
        • The element hierarchy
          • The element tree
        • The page
        • Containers
          • Groups
          • Repeating groups
          • Table elements
          • Popups
          • Floating groups
          • Group focus
        • Visual elements
        • Input forms
          • Text and numbers
          • Dates and time
          • File uploads
          • Selection controls
        • Reusable Elements
      • Styling
        • Color variables
        • Font variables
        • Styles
        • Custom Fonts
      • Responsive design
        • Building responsive pages
        • Legacy articles
          • The Basics (Legacy)
          • Building Responsive Pages (Legacy)
          • Migrating Legacy Pages
          • Tips When Designing (Legacy)
      • Templates
      • The Component Library
      • Importing from Figma
    • Data
      • The database
        • Data types and fields
        • Creating, saving and deleting data
        • Finding data
        • Displaying data
        • Protecting data with privacy rules
        • The database editor
        • Export/import data
          • Exporting data
          • Importing data (CSV)
        • Working with location data
        • Using Algolia
        • Database structure by app type
          • Marketplace Apps
          • Directory & Listings Apps
          • Social Network Apps
          • SaaS Apps
          • Project Management Apps
          • CRM Apps
          • Professional Services Apps
          • On-demand Apps
          • Documentation/ CMS Apps
          • Applicant Tracking System (ATS) Apps
          • Portfolio Apps
          • Gallery Apps
          • Online Store / Ecommerce Apps
          • Blog Apps
          • Messaging App
          • Dashboards
          • Building Block Apps
          • Bubble as a backend
      • Files
      • Images
      • Static data
        • App texts (translations)
        • Option sets
      • Temporary data
        • Custom states
        • URL parameters
      • User accounts
        • Authentication plugins
          • Facebook plugin
          • Fitbit plugin
          • Google plugin
          • Instagram plugin
          • LinkedIn plugin
          • Pinterest plugin
          • Slack plugin
          • Wistia plugin
          • YouTube plugin
        • Cookies set by Bubble
      • Time, dates and time zones
    • Logic
      • The frontend and backend
      • Workflows
        • Events
          • Frontend events
            • Recurring workflows
            • Custom events
          • Backend events
            • Database trigger events
        • Actions
        • API Workflows
      • Dynamic expressions
      • Conditions
      • Navigation
        • Single-page applications (SPA)
        • Multi-page applications
        • Page slugs
    • Workload
      • Understanding workload
        • Activity types
        • The workload calculation
        • Client-side and server-side processing
      • Tracking workload
        • Measuring
          • Using App Metrics
        • Monitoring
          • Workload notifications
          • Infinite recursion protection
      • Optimizing workload
        • Optimization framework
        • Optimization checklist
          • Page load
          • Searches
          • Workflows and actions
          • Backend workflows
        • Agency showcases
          • Minimum Studio
          • Neam
          • Support Dept
    • Security
      • Bubble's security features
      • Planning app security
      • Client-side and server-side
      • Bubble account security
      • App security
      • Page security
      • Database security
      • API security
        • API Connector security
        • Data API security
        • Workflow API security
      • Flusk
        • Overview
        • Flusk plan features
        • Getting started with Flusk
        • Flusk security tools
          • The Issues Explorer
          • Issue details
          • Tools and settings
            • Pages rating
            • Database rating
        • Flusk FAQ
      • Cookies
      • Security checklist
    • Publishing your app
      • Web app
      • Native mobile app
        • Global native mobile settings
        • iOS App Store
        • Google Play Store
        • Publishing FAQ
    • AI
      • Generate apps with AI
        • About AI app generation
      • AI page designer
      • Connect to AI agents
    • Maintenance
      • Collaborators
      • Version control
        • Best practices: Version control
        • Transitioning from the legacy version control
        • Terminology: Version control
        • Version Control (legacy)
      • Commenting
      • Database maintenance
        • Copying the database
        • Restoring database backups
        • Bulk operations
          • Bulk operation methods compared
        • Wiping change history
      • Performance
        • Hard limits
        • Capacity Usage (legacy)
        • Notes on queries
      • SEO
        • Introduction to SEO
        • SEO: App
        • SEO: Page
      • Testing and debugging
        • Introduction to testing and debugging
        • The debugger
        • The server logs
        • Supported browsers
      • API workflow scheduler
    • Integrations
      • API
        • Introduction to APIs
          • What is a RESTful API?
        • The Bubble API
          • Bubble API terminology
          • Authentication
            • How to authenticate
            • No authentication
            • As a User
            • As an admin
          • The Data API
            • Data API Privacy Rules
            • Data API endpoints
            • Data API requests
          • The Workflow API
            • Workflow API privacy rules
            • Workflow API endpoints
            • API workflows
              • Creating API workflows
              • Scheduling API workflows
              • Recursive API workflows
              • API Workflow Scheduler
              • Case: Stripe notifications
        • The API Connector
          • Authentication
          • API Connector security
          • API guides
            • OpenAI
              • Authentication
              • Calls
                • ChatGPT
                  • Chat
            • Google Translate
              • How to setup Google API keys
          • Streaming API
        • API security
        • Plugins that connect to APIs
        • API Glossary
      • Plugins
        • What Plugins Can Do
        • Installing and using Plugins
        • Authentication plugins
        • Special Plugins
      • SQL Database Connector
      • Bubble App Connector
      • WorkOS
        • WorkOS SSO
        • WorkOS API
    • Infrastructure
      • Sub-apps
      • Bubble release tiers
      • Hosting and scaling
        • How Bubble hosting works
        • Scaling with Bubble
        • CDN (Cloudflare)
        • Bubble app names
        • Domain and DNS
      • Compliance
        • GDPR
        • SOC 2 Type II
        • HIPAA
        • Other frameworks and standards
    • Bubble for Enterprise
      • Hosting and infrastructure
        • Dedicated instance
          • The Dedicated editor experience
          • Technical specs
          • Main cluster dependencies
          • Customizable options
          • Migration process
            • Pre-migration
            • During migration
            • Post-migration
      • Security and compliance
        • Single sign-on (SSO)
        • GDPR
        • SOC 2 Type II
        • HIPAA
        • Other frameworks
        • Bubble's security features
      • Admin and collaboration
      • Priority support
      • Billing and Payment Guideline for Dedicated Instances
  • Core Reference
    • Using the core reference
    • Bubble's Interface
      • Design tab
      • Design tab (Legacy)
      • Workflow tab
      • Data tab
      • Styles tab
      • Styles tab (Legacy)
      • Plugins tab
      • Settings tab
      • Logs tab
      • Template tab
      • Toolbar
      • Top and context menu options
      • Deployment and version control
        • Deployment & Version Control Dropdown (legacy)
      • Notes
    • Elements
      • General properties
      • General properties (Legacy)
      • Styling properties
      • Styling Properties (Legacy)
      • Responsive Properties
      • Responsive Properties (Legacy)
      • Conditional formatting
      • States
      • Page Element
        • Page Element (Legacy)
      • Visual Elements
      • Containers
      • Container Layout Types
      • Containers (Legacy)
      • Input Forms
      • Reusable Elements
      • Element Templates (legacy)
    • Workflows
    • Events
      • General events
      • Element events
      • Custom events
      • Recurring event
      • Database trigger event
    • Actions
      • Account
      • Navigation
      • Data (things)
      • Email
      • Element
      • Custom
    • Data
      • Data Sources
      • Operators and comparisons
      • Search
      • Privacy
    • Styles
    • API
      • The Bubble API
        • The Data API
          • Authentication
          • Data API endpoints
          • Data API requests
        • The Workflow API
      • The API Connector
        • Authentication
        • Adding calls
    • Bubble-made Plugins
      • AddtoAny Share Buttons
      • Airtable
      • API Connector
      • Blockspring
      • Box
      • Braintree
      • Bubble App Connector
      • Chart.js
      • Circle Music Player
      • Draggable Elements
      • Dropzone
      • Facebook
      • Fitbit
      • Full Calendar
      • Google
      • Google Analytics
      • Google Optimize
      • Google Places
      • Ionic Elements
      • iTunes
      • Slidebar Menu
      • LinkedIn
      • Localize Translation
      • Mixpanel
      • Mouse & Keyboard Interactions
      • Multiselect Dropdown
      • Progress Bar
      • Rich Text Editor
      • Rich Text Editor (Legacy)
      • Screenshotlayer
      • SelectPDF
      • Slack
      • Segment
      • Slick Slideshow
      • SQL Database Connector
      • Star Rating
      • Stripe
      • Tinder-like Element
      • Twitter
      • YouTube
      • Zapier
    • Application Settings
      • App plan
      • General
      • Domain / email
      • Languages
      • SEO / metatags
      • API
      • Collaboration
      • Sub-apps
      • Versions
  • Account & Marketplace
    • Account and billing
      • Pricing and plans
        • Plans and billing
        • Billing cycle
        • FAQ: Pricing and Workload
      • Account Management
      • Building Apps for Others
      • Selling on the Marketplace
      • Plans & Billing (legacy)
    • Official Bubble Certification
      • Hiring certified developers
    • Building Plugins
      • The Plugin Editor
      • General Settings
      • Updating to Plugin API v4
      • Adding API Connections
      • Building Elements
      • Building Actions
      • Loading Data
      • Publishing and versioning
      • Github Integration
    • Building Templates
    • Application and data ownership
    • Marketplace policies
    • Bug reports
  • Vulnerability Disclosure Policy
  • Beta features
    • About the Beta features section
    • Native mobile apps 🔒
      • Introduction
        • What is a native mobile app?
        • Native mobile vs. web development
        • Differences in native and web elements
        • Native mobile app terminology
      • Building
        • Views and navigation
        • Native mobile actions
        • Components and gestures
        • Device resources
          • Location services
          • Camera/photo library
      • Previewing
      • Publishing
Powered by GitBook
On this page
  • Data types recommended
  • CHAT-MESSAGE
  • CHAT-CHANNEL
  • CHAT-REACTION
  • CONTACT
  • USER
  • Option sets recommended
  • Type (of CHAT-MESSAGE)
  • Emoji
  • Example uses in your app
  • Additional notes
  • About the author: Rémi Fossembas

Was this helpful?

  1. User manual
  2. Data
  3. The database
  4. Database structure by app type

Messaging App

Last updated 3 years ago

Was this helpful?

by Rémi Fossembas from Apeable an official Bubble coach

Various members of the Bubble ecosystem contributed these use case-oriented database guides. There's always more than one way to do something in Bubble, but the advice here can help you get started if you're new to Bubble!

Instant messaging apps include ones like Messenger, Whatsapp or Slack. This is a chat application that enables users to instant message and connect with each other. Users send text messages, images, videos, links or files to each other, and other users can reply and react with emojis.

This guide’s data structure and logic can be used:

  • as a stand-alone app whose purpose is to connect people with each other. By pushing it to a new target population, you will be able to take a slice of the communication market

  • or as an additional feature of your app. This module will ease communication between your users and make your app more fun

These suggested data types and option sets should help you build common functionality for messaging apps in a way that keeps things scalable. Preview this messaging app’s data structure by following this link:

Data types recommended

To connect with each other, users (USER) will create channels (CHAT-CHANNEL) with one another (or with groups). When a user presses the “Send” button a new message (CHAT-MESSAGE) is created to store the value of this message, which can be text, images, who has seen it, etc. Someone in the channel may want to react to this message by selecting an emoji which will create a (CHAT-REACTION) stored as a list into the message’s record.

We’ll also cover the feature allowing you to create a list of your favorite contact users (CONTACT).

CHAT-MESSAGE

CHAT-MESSAGE is where the visual information of a message is stored in the database. It belongs to a CHAT-CHANNEL so that you can perform a “Do a search for” all messages in a channel to find all of a specific thread. This data is protected by the field VISIBLE BY that allows only users in this list to search, view files and view fields of this message. Everyone else has no access to it.

Suggested fields on this type

  • Type (type, an option set): this field is used for identifying what kind of message content it is, also so that we can control how the message is rendered visually. For instance if the message type is “image” you won’t show the text element of the message.

  • Value-text (text): this is the content of the message when this message has Type = text. For instance this field will be empty when your message Type = image, but if Type = text it could be “Hello John”. You could also set Type = link to use BBcode, a special way of storing text that allows for rich text content like links or formatting, for example, “Look at this nice car: [url=https://tesla.com/]Tesla.com[/url]”.

  • Value-image (image): this is the content of the message if this message’s Type is image (or link with a preview).

  • Value-file (file): this is the content of the message if this message’s Type is file. The value of this field can be displayed as a link in the text element of the message.

  • CHAT-CHANNEL (CHAT-CHANNEL, another data type): is the reference of the thread this message belongs to.

  • VISIBLE BY (list of USERS): is set for privacy purposes: only users of this list can view this message. Every time a message is created, set this list of users to all users that belong to this chat channel. When a user is added to the channel, add this user to all previous messages.

  • OWNER (USER): is often the Current User but that field allows you to create messages on behalf of someone else. It can be useful if you need automated messages sent by a bot for instance.

  • SEEN BY (list of USERS): is set to Current User when the message is created, then users are added when they have read the message.

This allows for helpful features like displaying the number of unread messages a user has: Perform a “Do a search for” CHAT-MESSAGE: count, with Constraints:

  • CHAT-CHANNEL = XXX

  • SEEN BY doesn’t contain Current User

  • VISIBLE BY contains Current User (not needed if previous Privacy Rules is set properly)

  • CHAT-REACTIONS (list of CHAT-REACTIONS): allows users to react to a specific message with Emojis or Likes.

  • CHAT-REPLY (CHAT-MESSAGE): stores the reference of a message that this one was a reply to. In the case where a user wants to reply to a message, you need to store that relationship somewhere. Let's say the original message is A and the reply is B, then save in message B's CHAT-REPLY the message A's value.

Privacy rules for this data type

  • Make this data type private by default: uncheck all the boxes under “Everyone else (default permissions)”

  • Create a rule:

  • When: This CHAT-MESSAGE’s VISIBLE BY contains Current USER, they can “View all fields”, “Find this in searches” and “View attached files”

CHAT-CHANNEL

This Data Type is the primary way to keep messages organized by threads.

Suggested fields on this type

  • Name (text): especially useful if threads are organized into channels with a list of Users.

  • PARTICIPANTS (list of USERS): is set for privacy purposes: only users of this list can view this channel. Add users to this list so they can see the thread and participate in the conversation.

  • ARCHIVED BY (list of USERS): allows each PARTICIPANT of the channel to archive a thread but can still unarchive the thread if desired. This data type isn't mandatory for the messaging system to work, but it's an option that allows each user to mute threads and no longer receive notifications.

Privacy rules for this data type

  • Make this data type private by default: uncheck all boxes under “Everyone else (default permissions)”

  • Create a rule:

  • When: This CHAT-CHANNEL’s PARTICIPANTS contains Current USER, they can “View all fields”, “Find this in searches”, and “View attached fields”

CHAT-REACTION

This Data Type allows users to react to a message with some Emojis. This is a separate Data Type instead of a field on CHAT-MESSAGE because multiple users might react to the message, each with a different reaction (emoji). Because we need to store at least two pieces of information about each reaction (the person reacting and their emoji), we can’t store it simply as one field on CHAT-MESSAGE and instead have to use a new Data Type.

Suggested fields on this type

  • OWNER (USER): is the creator of this reaction

  • CHAT-MESSAGE (CHAT-MESSAGE): the message that the reaction belongs to

  • Emoji (Emoji, an option set): this will have choices like 👍 👎 😂 💙

Privacy rules for this data type

  • Since this data type alone will not contain information that is too sensitive (since the CHAT-MESSAGE’s contents are not stored with each reaction, just a pointer to the relevant message), we could just leave this visible to everyone

CONTACT

This Data Type allows users to have a list of contacts.

Suggested fields on this type

  • OWNER (USER): is the creator of the contact list.

  • CONTACT (USER): is the user added to this list.

Privacy rules for this data type

  • Make this data type private by default: uncheck all boxes under “Everyone else (default permissions)”

  • Create a rule:

  • When: This CONTACT’s OWNER is Current USER, they can “View all fields”, “Find this in searches”, and “View attached fields”

USER

Standard built-in Bubble app User.

Suggested fields on this type

  • First name (text)

  • Last name (text)

  • Profile picture (image)

  • Email (built-in field)

Privacy rules for this data type

  • Make this data type private by default: uncheck all boxes under “Everyone else (default permissions)”

  • Create a rule:

  • When: Current User is logged in, they should be able to view “First name”, “Last name” and “Profile picture” fields if you want all users to be able to see each others’ information. “Find this in searches” should also be checked if you want users to be able to find each other, such as by name.

Option sets recommended

Type (of CHAT-MESSAGE)

  • text

  • image

  • link

  • file

  • video

This option set is used for saving what format a message is. This helps when it comes time to build what the page looks like, and you want to render different formats of messages differently. For instance if a message Type is “image” you won’t show a text element of the message.

Emoji

  • 👍

  • Text: &#128077

  • 👎

  • Text: &#128078

  • 😂

  • Text: &#128514

  • 💙

  • Text: &#10084

You can of course add as many emojis you want. You can display them in a text element using the option set’s Display or in a HTML element using the text’s value.

If you want to allow your users to create their own list of reactions, you would use a new Data Type instead of an option set.

Example uses in your app

  • Display the list of channels the Current User belongs to: You actually don't need to apply a constraint filter when doing a search with the current user because the privacy rules already ensure that a user can only see channels they are a member of.

  • Display the list of messages of a specific Channel. In the screenshot below, the value of the CHAT-CHANNEL is given by the Parent group that this Repeating Group is in.

  • Display the list of reactions to a specific Message. In this case, the value of the CHAT-MESSAGE is given by the Parent group that this group is in.

Additional notes

You might want to allow your users to bookmark some specific messages, like you can on Slack or on Bubble forum, so they can easily access a list of bookmarked messages at any time without having to go through all the threads to find them.

To do so, follow similar logic to how we set up CONTACT, namely a new data type for storing just this information:

  • OWNER: (USER) is the creator of the bookmarked message.

  • MESSAGE: (CHAT-MESSAGE) is the bookmarked message the owner wants to add to his list.

About the author: Rémi Fossembas

Rémi is from and is an

Apeable
official Bubble coach
Messaging app