Chat
- 4 minutes to read
Chat is a UI component that allows users to send and receive messages in real time.
Getting Started
The Chat UI Control is based on the DevExtreme Chat component.
To add this control to your project, follow instructions in the following help topics:
- Configure a Visual Studio Project or Configure a non Visual Studio Project
- Add Controls to a Project
- Razor Syntax
Basic Syntax
@model ASP.NET_Core.Models.Chat.ChatModel
@(Html.DevExtreme().Chat()
.DataSource(Model.Messages)
.ReloadOnChange(false)
.User(u => u
.Id(Model.CurrentUser.Id)
.Name(Model.CurrentUser.Name)
)
.OnMessageEntered("onMessageEntered")
)
<script>
function onMessageEntered({ component, message }) {
component.renderMessage(message)
}
</script>
Built-in Capabilities and Configuration Guides
Control Message Feed
Set initial Chat messages and display new ones with the items array, renderMessage method, or dataSource CRUD operations. Use onMessageEntered to define actions after a message is entered.Integrate AI and Chatbots
The DevExtreme Chat component allows you to add AI assistants by configuring AI services in the backend.
Typing Status
Typing triggers typingStart, while stopping or sending a message raises typingEnd. Use these events to manage the typingUsers array, indicating who is typing in the Chat.UI Customization
Customize Chat messages with messageTemplate. Display runtime issues with the alerts array. Control UI elements with properties like showAvatar, and adjust date/time formats with options like messageTimestampFormat.
API
Server-Side API
- Initialization
- Call the Chat() method to create a Chat control. This action initializes a ChatBuilder instance. Use the instance methods to specify Chat options and event handlers.
- Options
- For a complete option list, see Options. For details on how to specify control options, refer to the following help topic: Specify Options.
- Events
- For available events, see Events. For details on how to handle events, refer to the following help topic: Handle Events and Define Callbacks.
Client-Side API
- Options
- If you need to specify the Chat options dynamically on the client side, use client-side API. For a complete option list, see DevExtreme Chat options.
- Methods
- For a list of available methods, see DevExtreme Chat methods. For details on how to call methods, refer to the following help topic: Call Methods.
Accessibility
For more information on Chat accessibility compliance, refer to the following help topic: Accessibility.