Chat 🆕
Overview
The Avonni Chat component brings real-time messaging to your Lightning Pages. Use it to power internal collaboration, customer communications, or any workflow where threaded conversations add value to Salesforce.
Quick Start: Build a Case Chat in 2 Minutes
Want to see the component in action immediately? Follow these 7 steps to add a functional Case Comment history to a Case Record Page.

Create a New Component
Open the Avonni Dynamic Components App.
Click the New button to create a new component.
Name: Enter a name (e.g., "Case Chat History").
Target Page Object: Select Case.
Critical: The Target Page Object setting tells the component it is operating in the context of a Case record, allowing variables like
{!RecordId}to function correctly.
Configure the Data Source to Query
We need to fetch the Case Comment records from Salesforce.
Select the Chat component on the canvas.
In the Properties Panel (right), set Data Source to Query.
Object: Select
CaseComment.Filter:
Click Add Filter.
Field:
ParentId.Operator:
Equal.Value:
{!$Component.RecordId}.Why: This ensures we only load comments for the specific Case currently being viewed.
Order By:
CreatedDate ASC(Oldest to Newest).

Map the Query Fields
Connect the fields returned by your Query to the Chat component attributes.
Scroll down to the Data Mappings section.
Content: Select
Body.Note: This maps the actual text of the comment to the message bubble.
Date: Select
CreatedDate.
Check the Preview: The canvas should now display the conversation history for the context record. If the preview is empty, ensure the Preview Context is set to a case from the Debug Panel.

Add the "Save" Logic (Interaction)
Make the "Post Comment" button functional.
Click the Interactions tab in the Properties Panel.
Click Add Interaction.
Trigger: Select
On Message Publish.Action: Select
Enter Record Data Manually.Object: Select
CaseComment.
Field Mappings:
ParentId:
{!RecordId}(Links the comment to this Case).CommentBody:
{!event.detail.value}(Captures your typed text).IsPublished:
true(Important: ensure this is set to true so the comment is visible).

Configuration
Select the Chat component on the canvas to access its properties in the Properties Panel. Configuration involves defining where the messages come from, how the publisher behaves, and how to handle new messages.
Connecting to Message Data (Data Source)
You can populate the chat history using either the Manual or Query method.
Option A: Manual Data Source
Use this for static displays or prototyping.
Select Data Source: Choose Manual.
Configure Resources: Resources represent the people or entities involved in the chat.
Label: The display name of the person/user.
Avatar Source: URL for the user image.
Avatar Fallback Icon: An icon name (e.g.,
standard:user) to display if no image is available.Avatar Initials: Text to display (e.g., "JD") if no image is available.
Configure Messages: Create the specific message bubbles.
Author: The name or ID of the resource who sent the message.
Type: Explicitly set as
inbound(received) oroutbound(sent).Date: The timestamp of the message.
Content: The actual text body of the message.
Option B: Query Data Source
Use this to dynamically fetch records from Salesforce (e.g., pulling all comments related to a Case).
Select Data Source: Choose Query.
Define Query: Select the Object (e.g.,
CaseComment) and set filters (e.g.,ParentId equals recordId) to fetch the correct records.Data Mappings: Map the fields from your query to the chat display.
Content: Select the field containing the message body (e.g.,
CommentBody).Date: Select the field containing the timestamp (e.g.,
CreatedDate).
General Settings
These settings control the overall behavior of the chat component, including how messages are attributed and displayed.
Current Resource ID
ID of the message author; determines sent vs. received positioning. Defaults to current user if empty.
{!$User.Id}
Read Only
Hides publisher; users can view but not send
falase
Disabled
Grays out component; prevents all interaction
false
Message Date Format
How timestamps display on messages
"MMM d, yyyy h:mm a" → "Jan 15, 2025 2:30 PM"
Publisher Settings
Customize the input area where users type new messages.
Mode
ID of the message author; determines sent vs. received positioning. Defaults to current user if empty.
{!$User.Id}
Placeholder
Hides publisher; users can view but not send
falase
Publish Button Label
Grays out component; prevents all interaction
false
Maximum Length
How timestamps display on messages
"MMM d, yyyy h:mm a" → "Jan 15, 2025 2:30 PM"
Minimum Length
Required characters before sending
10
Show Character Count
Display character counter
True
Toolbar Position
Where formatting tools appear
Top
Categories
Select which formatting tool groups appear in the Rich mode toolbar:
Font: Font family and size options.
Text: Bold, italic, underline, strikethrough.
Body: Lists, alignment, indentation.
Remove Formatting: Clear all formatting from selected text.
Header: Heading level options.
Color: Text color picker.
Highlight Color: Background highlight color picker.
Blocked Words
Define words that cannot be included in published messages. When users attempt to send messages containing blocked words, the publish action is prevented.
Real-Time Updates (Platform Events)
By default, the Chat component updates when you post a message. However, if a colleague or a customer posts a reply while you are looking at the screen, you usually wouldn't see it until you refresh the page.
Platform Events solve this. They allow the Chat component to "listen" for changes and update instantly when a new message is created in the database.
How to Enable Real-Time Chat
By default, the chat updates only when you post a message or refresh the page. To create a live, "Instant Messaging" experience where replies from others appear immediately, you can enable Platform Events.
This is configured in the Data Source settings:
Set Data Source to Query.
Expand Advanced Options and locate Query Refresh EMP.
Channel Name: Enter the API name of your Platform Event (e.g.,
Chat_Notification__e).Key Field Name: Enter the API name of the field containing the Record ID (e.g.,
RecordId__c).
Need help setting this up? Using this feature requires creating a Platform Event and a Trigger Flow in Salesforce. 👉 Read the Full Setup Guide: How to Configure Real-Time Updates
Interaction Configuration
By default, the Chat component displays data. To make it functional (i.e., actually saving a message when the user clicks "Send"), you must configure an Interaction.
Scenario: Creating a Record on Publish
Navigate to the Interactions tab in the properties panel.
Add a new interaction with the trigger "Publish a New Message".
Action: Select Create Record.
Select:
Enter Record Data Manually.Object: Choose the object where messages should be stored (e.g.,
CaseComment,FeedItem, or a customChat_Log__cobject).Field Mappings: Map the data from the Chat component to your Salesforce Object.
Example (Case Comment):
ParentId: Map to
{!Record.Id}(to link it to the current record).CommentBody: Map to the Chat Component Attribute
Value(this carries the text the user just typed).IsPublished: Set a constant value of
true.
Note: Once the record is created via the Interaction, the Chat Query (if configured) will automatically refresh to display the new message in the timeline
Example
Project Discussion Log
Goal: Create a chat interface on a custom "Project" object. This allows the project team to discuss updates and have those messages saved to a custom "Project Update" object.
Create the Component
Open the Avonni Dynamic Components App.
Click New.
Name: Enter "Project Team Chat".
Target Page Name: Select your custom object (e.g., Project or
Project__c).Why: This is critical. It tells the component it is operating in the context of a Project record, enabling the use of the
{!RecordId}variable.
Map Data
Unlike standard objects, custom objects require explicit mapping to ensure the user's name and picture appear correctly.
Content:
Message_Body__c(Rich Text Area field)Date:
CreatedDateAuthor Name:
CreatedBy.NameAuthor Avatar:
CreatedBy.SmallPhotoUrlWhy: This dynamically pulls the user who posted the update's Salesforce profile picture
Add the "Save" Logic (Interaction)
Configure the component to create a new Project_Update__c record when the button is clicked.
Interaction Trigger: Publish a new message
Action: Create Record
Select: Create
Enter Record Data Manually.Target Object:
Project_Update__cField Mappings:
Project__c: Map to
{!RecordId}Context: Links the update to the specific Project.
Message_Body__c: Map to
{!event.detail.value}Context: Saves the typed content.
Type__c:
Team Chat(Static Value)Context: If your object supports multiple update types, you can hardcode a specific type for this chat window.
Key Considerations
Data Model Planning: For Query mode, ensure your Salesforce objects have the necessary fields to store message content, timestamps, and author information, along with lookup relationships to parent records.
Resource Identification: The Current Resource ID determines message positioning. For customer-facing implementations, consider how you'll identify external participants versus internal users.
Character Limits: Set appropriate maximum lengths based on your target object's field limits to prevent data truncation.
Blocked Words: Review and update your blocked words list regularly to maintain communication standards without being overly restrictive.
Performance: For conversations with extensive history, use query filters to limit the number of messages loaded initially, or consider pagination strategies for very active threads.
In Summary
The Avonni Chat component transforms your Lightning Pages into collaborative communication hubs. Whether you're building internal team tools or customer-facing interfaces, the combination of flexible data sources, rich publishing options, and actionable interactions lets you create sophisticated messaging experiences that integrate directly with your Salesforce data model—all without writing code
Last updated
Was this helpful?

