Class
TelerikChat<TItem>

A component that enables you to build conversational UIs with messages, suggestions, attachments, and actions. Supports templating (messages, bubbles, header, status), speech-to-text, file upload, message width/layout, context menus and toolbar actions, quick replies, and send/download events.

Definition

Namespace:Telerik.Blazor.Components

Assembly:Telerik.Blazor.dll

Type Parameters:

TItem

Syntax:

cs-api-definition
public class TelerikChat<TItem> : BaseComponent, IComponent, IHandleEvent, IHandleAfterRender, IDisposable

Inheritance: objectComponentBaseBaseComponentTelerikChat<TItem>

Implements: IComponentIDisposableIHandleAfterRenderIHandleEvent

Inherited Members BaseComponent.ShouldRender()BaseComponent.OnInitializedAsync()BaseComponent.InitLocalizer()BaseComponent.ThrowIfParameterIsNull(object, string)BaseComponent.HaveOptionsChanged(IDictionary<string, object>, IDictionary<string, object>)BaseComponent.GetClassString(params string[])BaseComponent.InvokeAsync<T>(string, params object[])BaseComponent.InvokeAsync<T>(string, CancellationToken, params object[])BaseComponent.InvokeVoidAsync(string, params object[])BaseComponent.InvokeVoidAsyncWithoutAwait(string, params object[])BaseComponent.InvokeComponentMethodAsync<T>(string, params object[])BaseComponent.InvokeComponentMethodAsync<T>(string, CancellationToken, params object[])BaseComponent.InvokeVoidComponentMethodAsync(string, params object[])BaseComponent.InvokeComponentVoidMethodAsync(string, object)BaseComponent.InvokeDisposeAsync()BaseComponent.StateHasChanged()BaseComponent.RootComponentBaseComponent.ClassComponentBase.OnInitialized()ComponentBase.OnParametersSetAsync()ComponentBase.OnAfterRender(bool)ComponentBase.InvokeAsync(Action)ComponentBase.InvokeAsync(Func<Task>)ComponentBase.DispatchExceptionAsync(Exception)ComponentBase.SetParametersAsync(ParameterView)

Constructors

TelerikChat()

Declaration

cs-api-definition
public TelerikChat()

Properties

AuthorId

Defines the ID of the current author/user. Set this to the ID of the user who is currently sending messages. Each message in the chat should have an AuthorId that matches this value to indicate that the message was sent by the current user.

Declaration

cs-api-definition
[Parameter]
public string AuthorId { get; set; }

Property Value

string

AuthorIdField

Defines the field in the data source that contains the ID of the author of the message.

Declaration

cs-api-definition
[Parameter]
public string AuthorIdField { get; set; }

Property Value

string

AuthorImageAltTextField

Defines the field in the data source that contains the alt text for the author's image.

Declaration

cs-api-definition
[Parameter]
public string AuthorImageAltTextField { get; set; }

Property Value

string

AuthorImageUrlField

Defines the field in the data source that contains the image URL of the author of the message.

Declaration

cs-api-definition
[Parameter]
public string AuthorImageUrlField { get; set; }

Property Value

string

AuthorMessageContentTemplate

Template for modifying the appearance of the messages in the chat. Applied only to author messages. If defined, it takes precedence over MessageContentTemplate.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatMessageContentTemplateContext<TItem>> AuthorMessageContentTemplate { get; set; }

Property Value

RenderFragment<ChatMessageContentTemplateContext<TItem>>

AuthorMessageTemplate

Template for modifying the appearance of the messages bubbles in the chat. Applied only to author messages. If defined, it takes precedence over MessageTemplate.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatMessageTemplateContext<TItem>> AuthorMessageTemplate { get; set; }

Property Value

RenderFragment<ChatMessageTemplateContext<TItem>>

AuthorNameField

Defines the field in the data source that contains the name of the author of the message.

Declaration

cs-api-definition
[Parameter]
public string AuthorNameField { get; set; }

Property Value

string

ChatFileActions

Defines a render fragment that contains actions for the attachments. Children: ChatFileAction.

Declaration

cs-api-definition
[Parameter]
public RenderFragment ChatFileActions { get; set; }

Property Value

RenderFragment

ChatMessageContextMenuActions

Defines a render fragment that contains message actions. Children: ChatMessageContextMenuAction.

Declaration

cs-api-definition
[Parameter]
public RenderFragment ChatMessageContextMenuActions { get; set; }

Property Value

RenderFragment

ChatMessageToolbarActions

Defines a render fragment that contains actions for the attachments. Children: ChatMessageToolbarAction.

Declaration

cs-api-definition
[Parameter]
public RenderFragment ChatMessageToolbarActions { get; set; }

Property Value

RenderFragment

ChatSettings

Declaration

cs-api-definition
[Parameter]
public RenderFragment ChatSettings { get; set; }

Property Value

RenderFragment

Data

The data source for the chat component. The data source should be a collection of items that represent messages.

Declaration

cs-api-definition
[Parameter]
public IEnumerable<TItem> Data { get; set; }

Property Value

IEnumerable<TItem>

EnableAIChatClient

Enables the built-in integration.

Declaration

cs-api-definition
[Parameter]
public bool EnableAIChatClient { get; set; }

Property Value

bool

EnableActionButton

Enables or disables the send/action button in the chat input box. When disabled, the button can be manually placed inside an affix template using PromptBoxActionButton.

Declaration

cs-api-definition
[Parameter]
public bool EnableActionButton { get; set; }

Property Value

bool

EnableFileUpload

Enables or disables the file upload functionality in the chat component. Renders a file upload icon in the chat input box that allows users to upload files.

Declaration

cs-api-definition
[Parameter]
public bool EnableFileUpload { get; set; }

Property Value

bool

EnableMessageCollapse

Enables the collapse functionality for messages in the chat component. By default, messages are expanded and can be collapsed by clicking on them.

Declaration

cs-api-definition
[Parameter]
public bool EnableMessageCollapse { get; set; }

Property Value

bool

EnableScrollToBottom

Specifies whether the chat should enable the scroll to bottom button.

Declaration

cs-api-definition
[Parameter]
public bool EnableScrollToBottom { get; set; }

Property Value

bool

EnableSpeechToText

Enables or disables the speech-to-text functionality in the chat component. Renders a microphone icon in the chat input box that allows users to convert speech to text.

Declaration

cs-api-definition
[Parameter]
public bool EnableSpeechToText { get; set; }

Property Value

bool

EndIndex

The exclusive end index in the full dataset marking the end of the current batch. Only relevant in remote mode (OnLoadMoreMessages). Typically StartIndex + Data.Count. The developer must update this after fetching data and when appending/prepending messages.

Declaration

cs-api-definition
[Parameter]
public int EndIndex { get; set; }

Property Value

int

EndlessScrollDebounceDelay

The debounce delay in milliseconds for the endless scroll handler. Controls how long the component waits after the user stops scrolling before checking if a new page should be loaded. Default value is 150.

Declaration

cs-api-definition
[Parameter]
public int EndlessScrollDebounceDelay { get; set; }

Property Value

int

FilesField

Defines the field in the data source that contains the attachments of the message. The field should be a collection of objects of type FileSelectFileInfo.

Declaration

cs-api-definition
[Parameter]
public string FilesField { get; set; }

Property Value

string

HeaderTemplate

Template for modifying the content of the header of the chat component.

Declaration

cs-api-definition
[Parameter]
public RenderFragment HeaderTemplate { get; set; }

Property Value

RenderFragment

Height

Defines the height of the chat component.

Declaration

cs-api-definition
[Parameter]
public string Height { get; set; }

Property Value

string

IdField

Defines the field in the data source that contains the ID of the message.

Declaration

cs-api-definition
[Parameter]
public string IdField { get; set; }

Property Value

string

InputValue

The value of the chat input field.

Declaration

cs-api-definition
[Parameter]
public string InputValue { get; set; }

Property Value

string

IsDeletedField

Defines the field in the data source that indicates whether the message is deleted.

Declaration

cs-api-definition
[Parameter]
public string IsDeletedField { get; set; }

Property Value

string

IsFailedField

Defines the field in the data model that indicates whether the message sending has failed.

Declaration

cs-api-definition
[Parameter]
public string IsFailedField { get; set; }

Property Value

string

IsPinnedField

Defines the field in the data source that indicates whether the message is deleted.

Declaration

cs-api-definition
[Parameter]
public string IsPinnedField { get; set; }

Property Value

string

IsTypingField

Defines the field in the data source that indicates whether the author of the message is currently typing.

Declaration

cs-api-definition
[Parameter]
public string IsTypingField { get; set; }

Property Value

string

MessageBoxTemplate

A render fragment that allows customization of the whole message box section in the chat.

Declaration

cs-api-definition
[Parameter]
public RenderFragment MessageBoxTemplate { get; set; }

Property Value

RenderFragment

MessageContentTemplate

Template for modifying the appearance of the messages in the chat.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatMessageContentTemplateContext<TItem>> MessageContentTemplate { get; set; }

Property Value

RenderFragment<ChatMessageContentTemplateContext<TItem>>

MessageFilesLayoutMode

Specifies the layout of the files attached to a message. The available options are:

  1. Vertical - Files are displayed in a vertical list.
  2. Horizontal - Files are displayed in a horizontal list.
  3. Wrap - Files are displayed in a wrapping layout.

The default value is Vertical.

Declaration

cs-api-definition
[Parameter]
public ChatMessageFilesLayoutMode MessageFilesLayoutMode { get; set; }

Property Value

ChatMessageFilesLayoutMode

MessageStatusTemplate

Template for modifying the appearance of the message status indicators in the chat.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatMessageStatusTemplateContext<TItem>> MessageStatusTemplate { get; set; }

Property Value

RenderFragment<ChatMessageStatusTemplateContext<TItem>>

MessageTemplate

Template for modifying the appearance of the messages bubbles in the chat.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatMessageTemplateContext<TItem>> MessageTemplate { get; set; }

Property Value

RenderFragment<ChatMessageTemplateContext<TItem>>

MessageWidthMode

Defines the width mode of the messages in the chat. The available options are:

  1. Standard - Messages will have a width that fits their content.
  2. Full - Messages will take the full width of the chat container.

The default value is Standard.

Declaration

cs-api-definition
[Parameter]
public MessageWidthMode MessageWidthMode { get; set; }

Property Value

MessageWidthMode

NoDataTemplate

Container for content rendered in place of the message list when no messages or data are provided.

Declaration

cs-api-definition
[Parameter]
public RenderFragment NoDataTemplate { get; set; }

Property Value

RenderFragment

OnDownload

Event callback that is triggered when a file is downloaded. Triggered upon clicking on a file download action or when the Download button is clicked.

Declaration

cs-api-definition
[Parameter]
public EventCallback<ChatDownloadEventArgs> OnDownload { get; set; }

Property Value

EventCallback<ChatDownloadEventArgs>

OnInputValueChanged

Event callback that is triggered when the input value changes.

Declaration

cs-api-definition
[Parameter]
public EventCallback<string> OnInputValueChanged { get; set; }

Property Value

EventCallback<string>

OnLoadMoreMessages

Fires when the component needs a new page of messages (initial load, scroll up/down, scroll to bottom). The developer must update Data, StartIndex, and EndIndex in this handler. Requires Total to be set.

Declaration

cs-api-definition
[Parameter]
public EventCallback<ChatLoadMoreMessagesEventArgs> OnLoadMoreMessages { get; set; }

Property Value

EventCallback<ChatLoadMoreMessagesEventArgs>

OnMessageUnpin

Event callback that is triggered when a message is unpinned.

Declaration

cs-api-definition
[Parameter]
public EventCallback<ChatMessageUnpinEventArgs> OnMessageUnpin { get; set; }

Property Value

EventCallback<ChatMessageUnpinEventArgs>

OnReferencedMessageClick

Fires when the user clicks a referenced message (pinned message indicator or reply-to preview). In built-in mode, the Chat handles in-DOM navigation automatically — the event is informational. In remote mode, the developer must resolve the message location, fetch data, and update Data, StartIndex, and EndIndex.

Declaration

cs-api-definition
[Parameter]
public EventCallback<ChatReferencedMessageClickEventArgs> OnReferencedMessageClick { get; set; }

Property Value

EventCallback<ChatReferencedMessageClickEventArgs>

OnResendMessage

Event callback that is triggered when a message is sent. The arguments are of type ChatResendMessageEventArgs.

Declaration

cs-api-definition
[Parameter]
public EventCallback<ChatResendMessageEventArgs> OnResendMessage { get; set; }

Property Value

EventCallback<ChatResendMessageEventArgs>

OnSendMessage

Event callback that is triggered when a message is sent. The arguments are of type ChatSendMessageEventArgs.

Declaration

cs-api-definition
[Parameter]
public EventCallback<ChatSendMessageEventArgs> OnSendMessage { get; set; }

Property Value

EventCallback<ChatSendMessageEventArgs>

OnSuggestionClick

An event callback that is triggered when a suggestion is selected from the suggestions list. The arguments are of type ChatSuggestionClickEventArgs.

Declaration

cs-api-definition
[Parameter]
public EventCallback<ChatSuggestionClickEventArgs> OnSuggestionClick { get; set; }

Property Value

EventCallback<ChatSuggestionClickEventArgs>

PageSize

The number of messages to load per page when ScrollMode is Endless. Default value is 20.

Declaration

cs-api-definition
[Parameter]
public int PageSize { get; set; }

Property Value

int

PinnedMessages

A separate collection of pinned messages. Use this when pinned messages may not be part of the currently loaded Data (e.g., in OnLoadMoreMessages scenarios). When not set, the component falls back to looking for pinned messages in Data via the IsPinnedField. The component displays the last item from this collection as the active pinned message.

Declaration

cs-api-definition
[Parameter]
public IEnumerable<TItem> PinnedMessages { get; set; }

Property Value

IEnumerable<TItem>

Placeholder

Defines the placeholder text displayed in the chat input when it is empty. Use this to provide hints about the expected input to users.

Declaration

cs-api-definition
[Parameter]
public string Placeholder { get; set; }

Property Value

string

ReceiverMessageContentTemplate

Template for modifying the appearance of the messages in the chat. Applied only to receiver messages. If defined, it takes precedence over MessageContentTemplate.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatMessageContentTemplateContext<TItem>> ReceiverMessageContentTemplate { get; set; }

Property Value

RenderFragment<ChatMessageContentTemplateContext<TItem>>

ReceiverMessageTemplate

Template for modifying the appearance of the messages bubbles in the chat. Applied only to receiver messages. If defined, it takes precedence over MessageTemplate.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatMessageTemplateContext<TItem>> ReceiverMessageTemplate { get; set; }

Property Value

RenderFragment<ChatMessageTemplateContext<TItem>>

RepliedToMessages

Messages that are reply targets for messages in the current batch but live outside Data. Only needed in remote mode (OnLoadMoreMessages). The developer resolves missing reply targets after each data fetch. Scoped per batch — rebuilt on each OnLoadMoreMessages or batch replacement.

Declaration

cs-api-definition
[Parameter]
public IEnumerable<TItem> RepliedToMessages { get; set; }

Property Value

IEnumerable<TItem>

ReplyToIdField

Each message in the chat should have a unique ID. This field value is optional and it is used to identify the other message to which the current message is a reply.

Declaration

cs-api-definition
[Parameter]
public string ReplyToIdField { get; set; }

Property Value

string

ScrollMode

Controls how the Chat handles scrolling and message rendering. Scrollable (default) renders all messages. Endless loads messages in pages as the user scrolls.

Declaration

cs-api-definition
[Parameter]
public ChatScrollMode ScrollMode { get; set; }

Property Value

ChatScrollMode

StartIndex

The index in the full dataset that Data[0] corresponds to. Only relevant in remote mode (OnLoadMoreMessages). The developer must update this after fetching data and when appending/prepending messages.

Declaration

cs-api-definition
[Parameter]
public int StartIndex { get; set; }

Property Value

int

StatusField

Defines the field in the data source that contains the status of the message.

Declaration

cs-api-definition
[Parameter]
public string StatusField { get; set; }

Property Value

string

SuggestedActionsField

Defines the field in the data source that contains the quick actions for the message.

Declaration

cs-api-definition
[Parameter]
public string SuggestedActionsField { get; set; }

Property Value

string

SuggestedActionsLayoutMode

Controls the layout of the suggestions displayed below message with suggested actions. The available options are:

  1. Wrap - Suggestions will wrap to the next line if they exceed the width of the container.
  2. Scroll - Suggestions will be displayed in a single line with horizontal scrolling.
  3. ScrollButtons - Suggestions will be displayed in a single line with horizontal scrolling and navigation buttons.

The default value is Wrap.

Declaration

cs-api-definition
[Parameter]
public ChatSuggestedActionsLayoutMode SuggestedActionsLayoutMode { get; set; }

Property Value

ChatSuggestedActionsLayoutMode

SuggestionTemplate

Template for modifying the appearance of the suggestions displayed in the chat input.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatSuggestionTemplateContext> SuggestionTemplate { get; set; }

Property Value

RenderFragment<ChatSuggestionTemplateContext>

Suggestions

Use this parameter to provide a collection of suggestions that will be displayed as quick reply options in the chat input.

Declaration

cs-api-definition
[Parameter]
public IEnumerable<string> Suggestions { get; set; }

Property Value

IEnumerable<string>

SuggestionsLayoutMode

Controls the layout of the suggestions displayed in the chat input. The available options are:

  1. Wrap - Suggestions will wrap to the next line if they exceed the width of the container.
  2. Scroll - Suggestions will be displayed in a single line with horizontal scrolling.
  3. ScrollButtons - Suggestions will be displayed in a single line with horizontal scrolling and navigation buttons.

The default value is Wrap.

Declaration

cs-api-definition
[Parameter]
public ChatSuggestionsLayoutMode SuggestionsLayoutMode { get; set; }

Property Value

ChatSuggestionsLayoutMode

TextField

The field in the data source that contains the text of the message.

Declaration

cs-api-definition
[Parameter]
public string TextField { get; set; }

Property Value

string

TimestampField

Defines the field in the data source that contains the timestamp of the message.

Declaration

cs-api-definition
[Parameter]
public string TimestampField { get; set; }

Property Value

string

TimestampTemplate

Defines a render fragment that contains the content of the chat time stamps displayed between messages.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatTimestampTemplateContext> TimestampTemplate { get; set; }

Property Value

RenderFragment<ChatTimestampTemplateContext>

Total

The total number of messages in the full dataset. Required when OnLoadMoreMessages has a delegate. Ignored for client-side endless scrolling.

Declaration

cs-api-definition
[Parameter]
public int Total { get; set; }

Property Value

int

UserStatusTemplate

Content rendered next to the user avatar. Useful for rendering badges indicating user status.

Declaration

cs-api-definition
[Parameter]
public RenderFragment<ChatMessageUserStatusTemplateContext<TItem>> UserStatusTemplate { get; set; }

Property Value

RenderFragment<ChatMessageUserStatusTemplateContext<TItem>>

Width

Defines the width of the chat component.

Declaration

cs-api-definition
[Parameter]
public string Width { get; set; }

Property Value

string

Methods

BuildRenderTree(RenderTreeBuilder)

Declaration

cs-api-definition
protected override void BuildRenderTree(RenderTreeBuilder __builder)

Parameters

__builder

RenderTreeBuilder

Overrides ComponentBase.BuildRenderTree(RenderTreeBuilder)

Dispose()

Declaration

cs-api-definition
public override void Dispose()

Overrides BaseComponent.Dispose()

OnAfterRenderAsync(bool)

Declaration

cs-api-definition
protected override Task OnAfterRenderAsync(bool firstRender)

Parameters

firstRender

bool

Returns

Task

Overrides BaseComponent.OnAfterRenderAsync(bool)

OnParametersSet()

Declaration

cs-api-definition
protected override void OnParametersSet()

Overrides ComponentBase.OnParametersSet()

Refresh(bool)

Refreshes the chat component, causing it to re-render.

Declaration

cs-api-definition
public void Refresh(bool scrollToBottom = true)

Parameters

scrollToBottom

bool

When true, the chat scrolls to the bottom after re-rendering. Default is true.