Skip to content

Chat New

The Chat element provides a full chat interface, including a message list with date separators, attachment previews, and a built-in input area for sending messages and uploading files

Features

  • Complete chat UI: Optional header, message list with grouping and date separators, and a built-in input area
  • Attachments: Users can attach files; images show previews and other files show name and size
  • Flexible data mapping: Map your data shape for messages, attachments, and participants
  • Localization: Configure locale, time format, and relative date labels (today, yesterday, just now)
  • Header logic: Shows private or group context automatically, with optional close button
  • Auto-scroll: Control smooth or instant scroll when new messages arrive
  • Full styling control: Customize header, messages, input area, buttons, icons, and date separators

Getting started

Using AI

The quickest way to set up the chat is by using AI:

  1. Ask AI to add the chat. Be sure to specify:
    • your data source for messages and participants
    • which participant is the current user
    • styling preferences (colors, fonts, rounded corners)
    • whether attachments should be enabled
  2. The AI will create a styled chat bound to your data:
  3. Continue refining your chat by asking:
    • "Map senderId from my user_id field"
    • "Enable smooth auto-scroll on new messages"
    • "Make my own messages blue with white text and rounded corners"

Manual setup

  1. Add the Chat element to your page from the Add panel
  2. Bind Participants to an array of users involved in the conversation
  3. Bind Messages to your array of chat messages
  4. In Mapping:
    • Set Message mappings (id, text, sender id, timestamp, attachments)
    • If you enabled attachments mapping, set attachment field mappings (id, name, url, type, size)
    • Set Participant mappings (id, name, avatar, location, status, is current user)
  5. (Optional) Enable Allow attachments if users can upload files
  6. Adjust styling in the Style panel for header, messages, date separator, and input area
  7. (Optional) Configure Locale, Time format, and labels like Today, Yesterday, and just now

Binding messages and participants

In the Settings tab, provide two arrays: Participants and Messages:

Participants and Messages

If the names of the fields in your data differ to the names expected, you can manually change the mappings:

Manual Mapping

Participants fields and behavior

Click to view example participants data
json
[
  {
    "id": "u-1",
    "name": "John",
    "avatar": "",
    "status": "online",
    "location": "San Francisco",
    "isCurrentUser": true
  },
  {
    "id": "u-2",
    "name": "Support Assistant",
    "avatar": "https://cdn.weweb-staging-ignis.io/designs/48c20b5b-3c38-442c-b107-606e5f64483f/sections/headshot-assistant.png?_wwcv=1758620031874",
    "status": "online",
    "location": "Paris",
    "isCurrentUser": false
  }
]
  • ID (required): Unique participant ID. Must match the senderId in your messages.

  • Name: Shown above the first message in a sequence and used in the header title. Also used for the group header line “Last message from …”.

  • Avatar URL: Defines the image to show in header.

    if there are 2 or fewer different participants (by senderId in messages), the avatar shown at the top-left is the participant whose isCurrentUser is false (i.e., the “other” person in a private chat)

Defining header visuals
  • Location: Shown as the secondary line under the name in the header for private chats. In group chats, the header’s secondary line becomes “Last message from …”.
Defining Location Text
  • Status: Drives the colored status dot in the header avatar.
Defining Status Icon
  • Is Current User: Marks the current user. Determines own-message styling and which messages are treated as “yours,” and contributes to header logic (in private chats, the header highlights the other participant).
Current User Styling

Messages fields and behavior

Click to view example messages data
json
[
  {
    "id": "m-1",
    "text": "Hi there 👋",
    "senderId": "u-2",
    "timestamp": "2025-09-22T09:00:00Z"
  },
  {
    "id": "m-2",
    "text": "How can I help today?",
    "senderId": "u-2",
    "timestamp": "2025-09-22T09:00:10Z"
  },
  {
    "id": "m-3",
    "text": "I just logged in, I love the platform!.",
    "senderId": "u-1",
    "timestamp": "2025-09-22T09:01:00Z"
  },
  {
    "id": "m-4",
    "text": "Can you share a screenshot?",
    "senderId": "u-2",
    "timestamp": "2025-09-22T09:01:20Z"
  },
  {
    "id": "m-5",
    "text": "Sure, this platform!.",
    "senderId": "u-1",
    "timestamp": "2025-09-22T09:01:40Z",
    "attachments": [
      {
        "id": "att-1",
        "url": "https://cdn.weweb-staging-ignis.io/designs/48c20b5b-3c38-442c-b107-606e5f64483f/sections/weweb-logo-wordmark-black.png?_wwcv=1758617489652",
        "name": "error.png",
        "size": 183221,
        "type": "image/png"
      }
    ]
  },
  {
    "id": "m-6",
    "text": "Thanks! glad you like it.",
    "senderId": "u-2",
    "timestamp": "2025-09-22T09:02:10Z"
  },
  {
    "id": "m-7",
    "text": "Here's a short getting started guide.",
    "senderId": "u-2",
    "timestamp": "2025-09-22T09:02:40Z",
    "attachments": [
      {
        "id": "att-2",
        "url": "https://example.com/files/login-guide.pdf",
        "name": "getting-started.pdf",
        "size": 532188,
        "type": "application/pdf"
      }
    ]
  },
  {
    "id": "m-8",
    "text": "Hey! This conversation will now automatically close",
    "senderId": "u-2",
    "timestamp": "2025-09-23T09:02:10Z"
  }
]
  • ID (required): Unique message ID
  • Message Text: The message body shown in the bubble.
  • Sender ID (required): Must match a participant id. Determines own-message styling and groups consecutive messages from the same sender.
  • Timestamp: ISO format recommended. Used for the time label on each message, date separators (Today/Yesterday/relative), ordering, and the group header “Last message from …”.
  • Attachments (optional): Array of attachment objects. Images (type starting with image/) show previews; other files show name and size. Clicking an attachment emits On attachment click.

Attachment fields when attachments are bound:

  • ID (optional)
  • Name
  • URL
  • Type (MIME)
  • Size (bytes)

Header behavior

One-to-one chat

In a one-to-one chat, the header shows the other participant’s name, avatar, and optional location/status. The 'other' participant is whichever participant's Is Current User is not true.

Related properties:

  1. Avatar URL (from item in Participants)
  2. Name (from item in Participants)
  3. Location (from item in Participants)
  4. Status (from item in Participants)
One to one header

Group chat

In a multi-participant chat, it shows a group label. Set a custom Group chat text, or the chat will generate one automatically. The location line can show “Last message from …”.

Props used here:

  1. Group Chat Text
  2. Name (from item in Participants with most recent timestamp)
  3. Group Avatar URL (from item in Participants)
Group header

If no Group Avatar URL is defined, then the avatar will default to using the intials of the Group Chat Text:

Group heade no avatar

Sending messages and attachments

To save a message, you need to utilize the On message sent trigger.

Use this pattern to persist messages and keep the chat in sync:

  1. Create a workflow on the chat element using the On message sent trigger.

  2. If any attachments exist in the message, encode them into data URLs so they can be sent to your backend.

  3. Send the message contents and the data URLs of any attachments to your backend for saving.

  4. After a successful response, refetch the data you bound to the chat’s Messages property:

    • if Messages is bound to a collection: add a Refetch collection action
    • if Messages is bound to a variable: update that variable with the latest server data
  5. (Optional) If you implemented optimistic UI (see below), reconcile with the server response (e.g., replace a temporary id with the saved id).

Optimistic UI

To make messages appear right away after the user presses Send. Bind Messages to a variable and update it immediately so the new message appears instantly. Then, save the message to your backend in the background.

If saving fails, show a clear error and remove (or mark) the temporary message. This approach is called an “optimistic update”. it keeps your chat feeling fast while staying accurate.

Dates, times, and separators

  • Each day is separated with a date chip (e.g., Today, Yesterday, relative labels, or a formatted date).
  • Configure:
    • Locale (e.g., enUS, fr, de, ja, zhTW, ar, etc.)
    • Time format (e.g., h:mm a)
    • Today, Yesterday, and Just now labels
  • Style the date separator’s text, line, background, and radius.
Date in chat

Auto-scrolling

  • New messages scroll the list to the bottom.
  • Choose your default behavior with Auto scroll behavior:
    • auto: instant jump
    • smooth: smooth scrolling
  • Use the component action Scroll to bottom programmatically. Passing no argument uses the default behavior. Passing true or false forces smooth/instant.

Example use cases

In-app support chat

Create a support chat where users can message your team:

  1. Bind Participants to the current user and the support agent
  2. Bind Messages to your conversation data
  3. Use the On message sent trigger to save new messages

Group team room

Build a team conversation with multiple participants:

  1. Bind Participants to all team members and flag the current user
  2. Bind Messages to the room's messages
  3. Set a custom Group chat text
  4. Use the On message sent trigger to save new messages

Best practices

Do:

  • localize the chat for your audience with Locale and labels
  • match senderId in messages to id in participants
  • handle the saving of messages using the On message sent trigger

Don't:

  • forget to mark the current user (the chat uses this to style “own” messages)
  • attach huge files without size checks on the backend

Forking

While the Chat element offers extensive built-in customization options, there may be cases where you need functionality beyond what's natively available. In these situations, you can fork the element and modify it to meet your specific requirements.

If you are unsure how to fork an element, you can learn more in the dedicated documentation.

Properties reference

Chat Settings

PropertyTypeDescription
Group Chat TextTextCustom label for group chats (fallback is auto-generated)
Group Avatar URLTextImage URL for the group avatar (optional)
Allow AttachmentsToggleAllow users to add files when sending messages
DisabledToggleDisable the input and actions
Auto-scroll BehaviorSelectInstant or Smooth scrolling when new messages arrive

Chat Data

PropertyTypeDescription
MessagesArrayCollection of messages to display
Message IDPath/FormulaField to use as message ID
Message TextPath/FormulaField to use as message content
Sender IDPath/FormulaField to use as the sender’s ID
TimestampPath/FormulaField to use as the message timestamp
AttachmentsPath/FormulaField to use as attachments (array)

Attachments Data

PropertyTypeDescription
IDPath/FormulaField to use as attachment ID
NamePath/FormulaField to use as attachment name
URLPath/FormulaField to use as attachment URL
MIME TypePath/FormulaField to use as MIME type
Size (bytes)Path/FormulaField to use as size in bytes

Participant Data

PropertyTypeDescription
ParticipantsArrayCollection of participants in the conversation
IDPath/FormulaField to use as participant ID
NamePath/FormulaField to use as participant name
Avatar URLPath/FormulaField to use as avatar URL
LocationPath/FormulaField to use as location
StatusPath/FormulaField to use as status (online, offline, away, busy)
Is Current UserPath/FormulaWhether this participant is the current user

Localization

PropertyTypeDescription
LocaleSelectDate-fns locale key (e.g., enUS, fr, de, ja, etc.)
Time FormatTextFormat for message timestamps (e.g., h:mm a)
Today TextTextLabel for today in date separators
Yesterday TextTextLabel for yesterday in date separators
Just Now TextTextLabel for very recent times

Styling

General

PropertyDescription
Font familyGlobal font for the chat interface
PropertyDescription
Header backgroundHeader background color
Header text colorText color in the header
Header borderBorder at the bottom of the header
Header paddingPadding inside the header
Header name font sizeFont size for the name
Header name font weightFont weight for the name
Header location font sizeFont size for the location line
Header location opacityOpacity of the location line
Group avatar colorBackground color used for group avatar initials
Display Close ButtonShow or hide the close icon in the header
Header close button colorColor of the close icon
Header close button hover backgroundBackground on close hover

Messages area

PropertyDescription
Messages backgroundBackground color of the message list
Messages paddingInner padding for the message list

Attachment thumbnails (inside messages)

PropertyDescription
Attachment Max WidthMax width for image attachment previews
Attachment Max HeightMax height for image attachment previews
Attachment Border RadiusCorner radius for image attachment previews

Others’ messages

PropertyDescription
Message backgroundBackground color of other users’ messages
Message text colorText color
Message font sizeFont size
Message font weightFont weight
Message font familyFont family
Message borderBorder
Message radiusBorder radius

Your messages

PropertyDescription
Message backgroundBackground color of your messages
Message text colorText color
Message font sizeFont size
Message font weightFont weight
Message font familyFont family
Message borderBorder
Message radiusBorder radius

Date separator

PropertyDescription
Date separator text colorText color
Date separator line colorLine color (left/right lines)
Date separator backgroundBackground behind the label
Date separator border radiusChip radius

Input area

PropertyDescription
Input area backgroundBackground color of the input container
Input area borderTop border of the input container
Textarea borderTextarea border
Textarea border hoverBorder when hovering
Textarea border focusBorder when focused
Input text colorText color
Input font sizeFont size
Input font weightFont weight
Input font familyFont family
Input placeholder colorPlaceholder color
Input heightFixed height of the textarea
Input border radiusTextarea radius

Icons and buttons

PropertyDescription
Send iconIcon name for send
Send icon colorColor of send icon
Send icon sizeSize of send icon
Attachment iconIcon name for attachment
Attachment icon colorColor of attachment icon
Attachment icon sizeSize of attachment icon
Remove iconIcon name for removing a pending attachment
Remove icon colorColor of remove icon
Remove icon sizeSize of remove icon
Send button backgroundBackground/gradient of send button
Send button hover backgroundBackground/gradient on hover
Send button borderBorder
Send button border radiusRadius
Send button sizeWidth/height
Send button box shadowShadow
Attachment button backgroundBackground of attachment button
Attachment button hover backgroundHover background
Attachment button borderBorder
Attachment button border radiusRadius
Attachment button sizeWidth/height
Attachment button box shadowShadow

Empty state

PropertyDescription
Empty message textText shown when there are no messages
Empty message colorColor for the empty message

Component actions

ActionDescriptionParameters
Scroll to bottomScrolls to the latest messagesmooth (Boolean, optional). If omitted, uses Auto scroll behavior.

Exposed variables

This element exposes the following variable automatically:

VariableTypeDescription
chatStateObjectComplete chat state including messages, conversation, current user, and utils

Example variable values

chatState

javascript
{
  "messages": [
    {
      "id": "msg-101",
      "text": "Welcome!",
      "senderId": "agent-1",
      "userName": "Support",
      "timestamp": "2025-09-18T14:22:10.123Z",
      "attachments": [
        { "id": "file-1", "name": "guide.pdf", "url": "https://...", "type": "application/pdf", "size": 532188 }
      ],
      "userSettings": {
        "userName": "Support",
        "userAvatar": "https://...",
        "userLocation": "",
        "userStatus": "online"
      }
    }
  ],
  "conversation": {
    "type": "private",
    "participantCount": 2,
    "otherParticipantCount": 1,
    "participants": [
      { "id": "agent-1", "name": "Support", "avatar": "https://...", "location": "", "status": "online", "lastMessageTime": "2025-09-18T14:22:10.123Z" }
    ],
    "allParticipants": [
      { "id": "me-1", "name": "You", "avatar": "", "location": "", "status": "online", "isCurrentUser": true, "lastMessageTime": null },
      { "id": "agent-1", "name": "Support", "avatar": "https://...", "location": "", "status": "online", "isCurrentUser": false, "lastMessageTime": "2025-09-18T14:22:10.123Z" }
    ]
  },
  "currentUser": { "id": "me-1", "name": "You", "avatar": "", "location": "", "status": "online" },
  "utils": { "messageCount": 1, "isDisabled": false, "allowAttachments": true, "displayHeader": true }
}

Event triggers

EventDescriptionPayload
messageSentFired when the user sends a message{ message }
messageReceivedFired when a new message appears in messages from another sender{ message }
messageRightClickFired on right-click on a message{ message, position: { elementX, elementY, viewportX, viewportY } }
attachmentClickFired when an attachment is clicked{ attachment }
pendingAttachmentClickFired when a pending (unsent) attachment is clicked{ attachment: File, index }
closeFired when the header close button is clicked{}

Example event payloads

messageSent

javascript
{
  "message": {
    "id": "msg-7f3a",
    "text": "Got it, thanks!",
    "senderId": "me-1",
    "userName": "You",
    "timestamp": "2025-09-19T10:15:00.000Z",
    // attachments is an array of File objects when present
    "attachments": [ /* File */ ]
  }
}

messageReceived

javascript
{
  "message": {
    "id": "msg-7f3b",
    "text": "Happy to help!",
    "senderId": "agent-1",
    "userName": "Support",
    "timestamp": "2025-09-19T10:15:05.000Z",
    "attachments": [
      { "id": "file-9", "name": "guide.pdf", "url": "https://...", "type": "application/pdf", "size": 532188 }
    ],
    "userSettings": { "userName": "Support", "userAvatar": "https://...", "userLocation": "", "userStatus": "online" }
  }
}

messageRightClick

javascript
{
  "message": {
    "id": "msg-7f3a",
    "text": "Got it, thanks!",
    "senderId": "me-1",
    "timestamp": "2025-09-19T10:15:00.000Z"
  },
  "position": { "elementX": 120, "elementY": 24, "viewportX": 320, "viewportY": 480 }
}

The elementX and elementY is the position relative to the chat element, and the viewportX and viewportY is the position relative to the page.

attachmentClick

javascript
{
  "attachment": {
    "id": "file-9",
    "name": "guide.pdf",
    "url": "https://...",
    "type": "application/pdf",
    "size": 532188
  }
}

pendingAttachmentClick

javascript
{
  "attachment": File, // The underlying File object of the pending upload
  "index": 0
}

close

javascript
{}