- Configure messages
- Define timestamp
- Define message status
- Setting auto scroll
- Setting suggestions
- Configure message options
Contact Support
Messages in Angular Chat UI component
27 Jun 202524 minutes to read
The Chat UI allows to add messages using the <e-message>
selector. The message collection stores all the messages being sent and received.
Configure messages
You can use the text property to add message content for the user. Each message can be configured with options such as id, text, author, timestamp and more.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
top: 45%;
left: 45%;
}
Setting pinned
You can use the isPinned property to highlight the important message in the chat. Once a message is pinned, you can access the options menu to continue the chat or unpin it.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" >
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I'll review it and send feedback by today." [author]="currentUserModel" [isPinned]="true" ></e-message>
</e-messages>
</div>
Setting reply to
You can use the replyTo property to respond to the original message preserving context and creating a threaded conversation.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, MessageModel, MessageReplyModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public replyTo: MessageReplyModel = {
user: this.michaleUserModel,
text: 'Yes, the design phase is complete.',
messageID: 'chat-message-2'
};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" >
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel" id="chat-message-1"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel" id="chat-message-2"></e-message>
<e-message text="I'll review it and send feedback by today." [author]="currentUserModel" [replyTo]="replyTo" ></e-message>
</e-messages>
</div>
Setting forward
You can use the isForwarded property to specify the user when the message is forwarded.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" >
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I'll review it and send feedback by today." [author]="currentUserModel" [isForwarded]="true" ></e-message>
</e-messages>
</div>
Setting compact mode
You can use the enableCompactMode
property to align all messages to the left in the chat for creating a streamlined layout ideal for group conversations or space-constrained interfaces. By default, the value is false
.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public enableCompactMode: boolean = true;
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [enableCompactMode]="enableCompactMode">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I'll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Defining current user
You can use the author property to identify the current user of the chat. Each user can be configured with options such as id, user, avatarUrl and more.
You can use the user property to display the user name and id property is necessary to differentiate between the multiple users.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
top: 45%;
left: 45%;
}
Setting avatar URL
You can use the avatarUrl property to define the image URL’s for the user avatar. If no URL is provided, fallback initials of the first and last name from the user’s name will be used.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2', avatarUrl: 'https://ej2.syncfusion.com/demos/src/avatar/images/pic03.png' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
top: 45%;
left: 45%;
}
Setting avatar background color
You can use the avatarBgColor property to set a specific background color for user avatars using hexadecimal values. If no color is set, a custom background color is set based on specified theme.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2', avatarBgColor: '#ccc9f7' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
top: 45%;
left: 45%;
}
Setting CSS class
You can use the cssClass property to customize the appearance of the chat user.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2', cssClass: 'custom-user' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
top: 45%;
left: 45%;
}
Setting status icon css
You can use the statusIconCss property to identify the user’s presence, including online
, offline
, busy
, and away
status in the Chat UI.
The following are the predefined status styles that can be defined using the statusIconCss
property.
Status | Icon class |
---|---|
Available |
e-user-online |
Away |
e-user-away |
Busy |
e-user-busy |
Offline |
e-user-offline |
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1', statusIconCss: 'e-icons e-user-online' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2', statusIconCss: 'e-icons e-user-away' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" >
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I'll review it and send feedback by today." [author]="currentUserModel" ></e-message>
</e-messages>
</div>
#container {
visibility: hidden;
margin: 20px auto;
}
#loader {
color: #008cff;
height: 40px;
width: 30%;
position: absolute;
top: 45%;
left: 45%;
}
Define timestamp
You can use the timeStamp property to indicate the date and time of each message being sent. By default it is set to the current date and time when the message is sent.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public timeStamp1: Date = new Date("December 25, 2024 7:30");
public timeStamp2: Date = new Date("December 25, 2024 8:00");
public timeStamp3: Date = new Date("December 25, 2024 11:00");
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [showTimeStamp]="false">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel" [timeStamp]="timeStamp1"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel" [timeStamp]="timeStamp2"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel" [timeStamp]="timeStamp3"></e-message>
</e-messages>
</div>
Setting timestamp format
You can use the timeStampFormat to display specific time format for the timestamp. The default format is dd/MM/yyyy hh:mm a
, but this can be customized to meet different localization and display needs.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel" timeStampFormat="MMMM hh:mm a"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Define message status
You can use the status property to update the status for the message(e.g., sent, received, read). It helps in managing message delivery and read receipts within the chat interface.
Setting icon CSS
You can use the iconCss property to update the styling of status icons associated with messages, aiding visual differentiation between statuses.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, MessageStatusModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public status: MessageStatusModel = { iconCss: 'e-icons e-chat-seen'};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel" [status]="status"></e-message>
</e-messages>
</div>
Setting text
You can use the text property to provide information about the messages through descriptive text, providing users with the context of the message.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, MessageStatusModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public status: MessageStatusModel = { text: 'Seen'};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel" [status]="status"></e-message>
</e-messages>
</div>
Setting tooltip
You can use the tooltip property to provide information about the messages by tooltips while hovering the status icon, providing users with additional data upon hovering.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel, MessageStatusModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public status: MessageStatusModel = { iconCss: 'e-icons e-chat-seen', tooltip: 'Seen'};
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I’ll review it and send feedback by today." [author]="currentUserModel" [status]="status"></e-message>
</e-messages>
</div>
Setting auto scroll
You can use the autoScrollToBottom property to automatically scroll the chats when a new message is received in a conversation. By default, the value is false, requires manual scrolling or the FAB button to quick access to the bottom of the view.
- By default, it scrolls to bottom for each message being sent or when the scroll is maintained at the bottom in the chat, in order to prevent the automatic scroll for different user messages you can use the
autoScrollToBottom
property.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [autoScrollToBottom]="true">
<e-messages>
<e-message text="Want to get coffee tomorrow?" [author]="currentUserModel"></e-message>
<e-message text="Sure! What time?" [author]="michaleUserModel"></e-message>
<e-message text="How about 10 AM?" [author]="currentUserModel"></e-message>
<e-message text="Perfect." [author]="michaleUserModel"></e-message>
<e-message text="See you!" [author]="currentUserModel"></e-message>
<e-message text="Bye!" [author]="michaleUserModel"></e-message>
</e-messages>
</div>
Setting suggestions
You can use the suggestions property, to add the suggestions in both initial and on-demand which help users to quick-reply options above the input field.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public suggestions: string[] = ["Okay will check it", "Sounds good!"];
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [suggestions]="suggestions">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
</e-messages>
</div>
Configure message options
The messageToolbarSettings
property allows customization of the message toolbar for richer chat experience in the Chat UI. It provides options to define the toolbar width
, configure a set of toolbar items
, and handle itemClick
events for enhanced interactivity. By default, the message options available are Copy
, Reply
, Pin
, and Delete
.
Copying a message
You can copy the message item to quickly duplicate the message, by using the toolbar copy icon in the message options.
Deleting a message
You can delete a message item to remove it from the chat conversation, by using the toolbar trash icon in the message options.
Setting width
You can use the width
property to set width of the message toolbar in the chat. By default, the value is 100%
.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule, MessageToolbarSettingsModel } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public messageToolbarSettings: MessageToolbarSettingsModel = {
width:'50%'
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [messageToolbarSettings]="messageToolbarSettings">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I'll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Setting items
You can use the items
property to specify the toolbar item in the message toolbar of the chat.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule, MessageToolbarSettingsModel } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component } from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public messageToolbarSettings: MessageToolbarSettingsModel = {
items: [
{ type: 'Button', iconCss: 'e-icons e-chat-forward', tooltip: 'Forward', },
{ type: 'Button', iconCss: 'e-icons e-chat-copy', tooltip: 'Copy' },
{ type: 'Button', iconCss: 'e-icons e-chat-reply', tooltip: 'Reply' },
{ type: 'Button', iconCss: 'e-icons e-chat-pin', tooltip: 'Pin' },
{ type: 'Button', iconCss: 'e-icons e-chat-trash', tooltip: 'Delete' }
]
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui [user]="currentUserModel" [messageToolbarSettings]="messageToolbarSettings">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I'll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>
Setting itemClick
You can use the itemClicked
event when the toolbar item is clicked in the message toolbar of the chat.
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ChatUIModule, ChatUIComponent, MessageToolbarSettingsModel, MessageToolbarItemClickedEventArgs } from '@syncfusion/ej2-angular-interactive-chat';
import { UserModel } from '@syncfusion/ej2-interactive-chat';
import { Component, ViewChild} from '@angular/core';
@Component({
imports: [ FormsModule, ReactiveFormsModule, ChatUIModule ],
standalone: true,
selector: 'app-root',
templateUrl: './app.component.html'
})
export class AppComponent {
@ViewChild('chatUIComponent')
public chatUI!: ChatUIComponent;
public currentUserModel: UserModel = { user: 'Albert', id: 'user1' };
public michaleUserModel: UserModel = { user: 'Michale Suyama', id: 'user2' };
public messageToolbarSettings: MessageToolbarSettingsModel = {
items: [
{ type: 'Button', iconCss: 'e-icons e-chat-forward', tooltip: 'Forward', },
{ type: 'Button', iconCss: 'e-icons e-chat-copy', tooltip: 'Copy' },
{ type: 'Button', iconCss: 'e-icons e-chat-reply', tooltip: 'Reply' },
{ type: 'Button', iconCss: 'e-icons e-chat-pin', tooltip: 'Pin' },
{ type: 'Button', iconCss: 'e-icons e-chat-trash', tooltip: 'Delete' }
],
itemClicked: (args: MessageToolbarItemClickedEventArgs) => {
if (args.item.prefixIcon === 'e-icons e-chat-forward') {
const newMessageObj = {
id: 'chat-message-' + (this.chatUI.messages.length + 1).toString(),
isForwarded: true,
isPinned: args.message.isPinned,
author: args.message.author,
text: args.message.text,
timeStamp: args.message.timeStamp,
timeStampFormat: args.message.timeStampFormat,
status: args.message.status,
replyTo: args.message.replyTo
};
this.chatUI.addMessage(newMessageObj);
}
}
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
<div id="chatui" ejs-chatui #chatUIComponent [user]="currentUserModel" [messageToolbarSettings]="messageToolbarSettings">
<e-messages>
<e-message text="Hi Michale, are we on track for the deadline?" [author]="currentUserModel"></e-message>
<e-message text="Yes, the design phase is complete." [author]="michaleUserModel"></e-message>
<e-message text="I'll review it and send feedback by today." [author]="currentUserModel"></e-message>
</e-messages>
</div>