-
Notifications
You must be signed in to change notification settings - Fork 81
docs: add info about chat new features #12450 #3328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -21,6 +21,21 @@ Enable file uploads by setting the `EnableFileUpload` parameter to `true`: | |||||
| </TelerikChat> | ||||||
| ```` | ||||||
|
|
||||||
| ## Message Files Layout | ||||||
|
|
||||||
| The `MessageFilesLayoutMode` parameter controls how file attachments are displayed within chat messages. Choose from three layout options to best fit your application's design: | ||||||
|
|
||||||
| * `ChatMessageFilesLayoutMode.Vertical` - Files are displayed in a vertical stack (default) | ||||||
| * `ChatMessageFilesLayoutMode.Horizontal` - Files are displayed in a horizontal row | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| * `ChatMessageFilesLayoutMode.Wrap` - Files wrap to the next line when they exceed the message width | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ````RAZOR.skip-repl | ||||||
| <TelerikChat Data="@ChatData" | ||||||
| EnableFileUpload="true" | ||||||
| MessageFilesLayoutMode="@ChatMessageFilesLayoutMode.Horizontal"> | ||||||
| </TelerikChat> | ||||||
| ```` | ||||||
|
|
||||||
| ## File Upload Settings | ||||||
|
|
||||||
| Configure file upload behavior using the `ChatFileSelectSettings` component: | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -12,6 +12,70 @@ position: 5 | |||||
|
|
||||||
| The Telerik UI for Blazor Chat component provides comprehensive control over message display, interactions, and styling to create rich conversational experiences. | ||||||
|
|
||||||
| ## Typing Indicator | ||||||
|
|
||||||
| The Chat component supports displaying a typing indicator to show when another user is composing a message. Set the `IsTypingField` parameter to specify which field in your data model indicates typing status, and set that field to `true` on a message to display the typing indicator instead of message content. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, create a numbered list of steps from the last two sentences. |
||||||
|
|
||||||
| ````Razor | ||||||
| <TelerikButton OnClick="@AddTypingMessage">Show Typing Indicator</TelerikButton> | ||||||
|
|
||||||
| <TelerikChat Data="@ChatData" | ||||||
| @ref="@ChatRef" | ||||||
| AuthorId="@CurrentUserId" | ||||||
| IsTypingField="@nameof(ChatMessage.IsTyping)" | ||||||
| OnSendMessage="@OnChatSendMessage"> | ||||||
| </TelerikChat> | ||||||
|
|
||||||
| @code { | ||||||
| private TelerikChat<ChatMessage> ChatRef { get; set; } | ||||||
| private List<ChatMessage> ChatData { get; set; } = new(); | ||||||
| private string CurrentUserId { get; set; } = "user1"; | ||||||
|
|
||||||
| private void AddTypingMessage() | ||||||
| { | ||||||
| var typingMessage = new ChatMessage | ||||||
| { | ||||||
| Id = Guid.NewGuid().ToString(), | ||||||
| Content = null, | ||||||
| AuthorId = "support", | ||||||
| AuthorName = "Support Agent", | ||||||
| Timestamp = DateTime.Now, | ||||||
| IsTyping = true | ||||||
| }; | ||||||
|
|
||||||
| ChatData.Add(typingMessage); | ||||||
| } | ||||||
|
|
||||||
| private void OnChatSendMessage(ChatSendMessageEventArgs args) | ||||||
| { | ||||||
| ChatData.RemoveAll(m => m.IsTyping); | ||||||
|
|
||||||
| var newMessage = new ChatMessage | ||||||
| { | ||||||
| Id = Guid.NewGuid().ToString(), | ||||||
| Content = args.Message, | ||||||
| AuthorId = CurrentUserId, | ||||||
| Timestamp = DateTime.Now | ||||||
| }; | ||||||
|
|
||||||
| ChatData.Add(newMessage); | ||||||
| ChatRef?.Refresh(); | ||||||
| } | ||||||
|
|
||||||
| public class ChatMessage | ||||||
| { | ||||||
| public string Id { get; set; } | ||||||
| public string AuthorId { get; set; } | ||||||
| public string AuthorName { get; set; } | ||||||
| public string Content { get; set; } | ||||||
| public bool IsTyping { get; set; } | ||||||
| public DateTime Timestamp { get; set; } | ||||||
| } | ||||||
| } | ||||||
| ```` | ||||||
|
|
||||||
| When a message has `IsTyping` set to `true`, the Chat will display an animated typing indicator (typically three dots) instead of the message content. This provides visual feedback that enhances the conversational experience, especially in real-time chat scenarios. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This paragraph should ideally be way above, at the beginning of the section. |
||||||
|
|
||||||
| ## Context Menu Message Actions | ||||||
|
|
||||||
| Configure context menu actions that appear when users right-click on messages. These actions provide quick access to common message operations. | ||||||
|
|
@@ -179,6 +243,145 @@ Control the width behavior of chat messages using the `MessageWidthMode` paramet | |||||
| * `MessageWidthMode.Standard` - Messages take up a portion of the available space for better readability (default behavior) | ||||||
| * `MessageWidthMode.Full` - Messages span the full width of the chat container | ||||||
|
|
||||||
| ## Author and Receiver Message Settings | ||||||
|
|
||||||
| The Chat component allows you to configure settings specifically for author messages (sent by the current user) and receiver messages (received from other users) using `ChatAuthorMessageSettings` and `ChatReceiverMessageSettings` components. These settings take precedence over global Chat settings, enabling different configurations for sent and received messages. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Lets" is preferable to "allows to" because "allows" carries the nuance of permission, while "lets" leans toward a capability or enablement. |
||||||
|
|
||||||
| Use these settings to customize message behavior, appearance, and available actions based on whether the message was sent or received. For example, you might want different context menu actions, toolbar actions, or file actions for your own messages versus messages from others. | ||||||
|
|
||||||
| ````Razor | ||||||
| <TelerikChat Data="@ChatData" | ||||||
| @ref="@ChatRef" | ||||||
| AuthorId="@CurrentUserId" | ||||||
| OnSendMessage="@OnChatSendMessage"> | ||||||
| <ChatSettings> | ||||||
| <ChatAuthorMessageSettings EnableMessageCollapse="true" | ||||||
| MessageWidthMode="@MessageWidthMode.Full"> | ||||||
| <ChatMessageContextMenuActions> | ||||||
| <ChatMessageContextMenuAction Name="Edit" Text="Edit" Icon="@SvgIcon.Pencil" /> | ||||||
| <ChatMessageContextMenuAction Name="Delete" Text="Delete" Icon="@SvgIcon.Trash" /> | ||||||
| </ChatMessageContextMenuActions> | ||||||
| <ChatMessageToolbarActions> | ||||||
| <ChatMessageToolbarAction Icon="@SvgIcon.Pin" OnClick="@PinMessage" Text="Pin My Message" /> | ||||||
| </ChatMessageToolbarActions> | ||||||
| <ChatFileActions> | ||||||
| <ChatFileAction Name="Download" Text="Download My File" /> | ||||||
| </ChatFileActions> | ||||||
| </ChatAuthorMessageSettings> | ||||||
|
|
||||||
| <ChatReceiverMessageSettings EnableMessageCollapse="false" | ||||||
| MessageWidthMode="@MessageWidthMode.Standard"> | ||||||
| <ChatMessageContextMenuActions> | ||||||
| <ChatMessageContextMenuAction Name="Reply" Text="Reply" Icon="@SvgIcon.Undo" /> | ||||||
| <ChatMessageContextMenuAction Name="Forward" Text="Forward" Icon="@SvgIcon.Forward" /> | ||||||
| </ChatMessageContextMenuActions> | ||||||
| <ChatMessageToolbarActions> | ||||||
| <ChatMessageToolbarAction Icon="@SvgIcon.Heart" OnClick="@ReactToMessage" Text="Like" /> | ||||||
| </ChatMessageToolbarActions> | ||||||
| <ChatFileActions> | ||||||
| <ChatFileAction Name="Download" Text="Download Shared File" /> | ||||||
| </ChatFileActions> | ||||||
| </ChatReceiverMessageSettings> | ||||||
| </ChatSettings> | ||||||
| </TelerikChat> | ||||||
|
|
||||||
| @code { | ||||||
| private TelerikChat<ChatMessage> ChatRef { get; set; } | ||||||
| private List<ChatMessage> ChatData { get; set; } = new() | ||||||
| { | ||||||
| new ChatMessage() | ||||||
| { | ||||||
| Id = "1", | ||||||
| AuthorId = "support", | ||||||
| Content = "Hello! How can I assist you today?", | ||||||
| Timestamp = DateTime.Now.AddMinutes(-10) | ||||||
| }, | ||||||
| new ChatMessage() | ||||||
| { | ||||||
| Id = "2", | ||||||
| AuthorId = "user1", | ||||||
| Content = "Hi, I have a question about the new features.", | ||||||
| Timestamp = DateTime.Now.AddMinutes(-5) | ||||||
| } | ||||||
| }; | ||||||
| private string CurrentUserId { get; set; } = "user1"; | ||||||
|
|
||||||
| private void OnChatSendMessage(ChatSendMessageEventArgs args) | ||||||
| { | ||||||
| var newMessage = new ChatMessage | ||||||
| { | ||||||
| Id = Guid.NewGuid().ToString(), | ||||||
| Content = args.Message, | ||||||
| AuthorId = CurrentUserId, | ||||||
| Timestamp = DateTime.Now | ||||||
| }; | ||||||
|
|
||||||
| ChatData.Add(newMessage); | ||||||
| } | ||||||
|
|
||||||
| private void PinMessage(ChatMessageActionClickEventArgs args) | ||||||
| { | ||||||
| var message = ChatData.FirstOrDefault(m => m.Id == args.MessageId); | ||||||
| if (message != null) | ||||||
| { | ||||||
| message.IsPinned = true; | ||||||
| ChatRef?.Refresh(); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| private void ReactToMessage(ChatMessageActionClickEventArgs args) | ||||||
| { | ||||||
| Console.WriteLine($"Liked message: {args.MessageId}"); | ||||||
| } | ||||||
|
|
||||||
| public class ChatMessage | ||||||
| { | ||||||
| public string Id { get; set; } | ||||||
| public string AuthorId { get; set; } | ||||||
| public string Content { get; set; } | ||||||
| public bool IsPinned { get; set; } | ||||||
| public DateTime Timestamp { get; set; } | ||||||
| } | ||||||
| } | ||||||
| ```` | ||||||
|
|
||||||
| Available settings for both `ChatAuthorMessageSettings` and `ChatReceiverMessageSettings`: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These non-sentence fragments are not exactly ideal. Consider going with something like "ChatAuthorMessageSettings and Chat... provide the following settings:" |
||||||
|
|
||||||
| * `EnableMessageCollapse` - Enables the collapse functionality for long messages | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch the hyphens to mdashes across the list. |
||||||
| * `MessageWidthMode` - Controls message width (`Standard` or `Full`) | ||||||
| * `ChatMessageContextMenuActions` - Define context menu actions for right-click interactions | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, all bullets should follow a unified structure. If the previous were "enables" and "controls", the remaining should be "defines". |
||||||
| * `ChatMessageToolbarActions` - Define toolbar actions that appear on hover or selection | ||||||
| * `ChatFileActions` - Define actions available for file attachments | ||||||
|
|
||||||
| If no author or receiver-specific setting is provided, the component falls back to the global Chat settings. | ||||||
|
|
||||||
| ## Send Message Button Customization | ||||||
|
|
||||||
| Customize the appearance of the send message button using the `ChatSendMessageButtonSettings` component. The `Class` parameter allows you to apply custom CSS classes for styling. | ||||||
|
|
||||||
| ````Razor | ||||||
| <TelerikChat Data="@ChatData" | ||||||
| AuthorId="@CurrentUserId" | ||||||
| OnSendMessage="@OnChatSendMessage"> | ||||||
| <ChatSettings> | ||||||
| <ChatSendMessageButtonSettings Class="custom-send-button" /> | ||||||
| </ChatSettings> | ||||||
| </TelerikChat> | ||||||
|
|
||||||
| <style> | ||||||
| .custom-send-button { | ||||||
| background-color: #4CAF50; | ||||||
| color: white; | ||||||
| border-radius: 50%; | ||||||
| padding: 10px; | ||||||
| } | ||||||
|
|
||||||
| .custom-send-button:hover { | ||||||
| background-color: #45a049; | ||||||
| } | ||||||
| </style> | ||||||
| ```` | ||||||
|
|
||||||
| ## Message Box Value Persistence | ||||||
|
|
||||||
| The message box value represents the text that users have typed but haven't sent yet. | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,101 @@ The Telerik UI for Blazor Chat component supports quick actions and message sugg | |
|
|
||
| Message suggestions provide users with quick reply options that appear below the message input area. | ||
|
|
||
| ## Suggestions Layout Mode | ||
|
|
||
| The `SuggestionsLayoutMode` parameter controls how suggestions are displayed in the chat interface. Choose from three layout options to optimize the presentation based on the number and length of your suggestions: | ||
|
|
||
| * `ChatSuggestionsLayoutMode.Wrap` - Suggestions wrap to the next line if they exceed the container width (default) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to mdashes. |
||
| * `ChatSuggestionsLayoutMode.Scroll` - Suggestions are displayed in a single line with horizontal scrolling | ||
| * `ChatSuggestionsLayoutMode.ScrollButtons` - Suggestions are displayed in a single line with horizontal scrolling and navigation buttons | ||
|
|
||
| ````Razor | ||
| <TelerikChat Data="@ChatData" | ||
| Suggestions="@QuickReplies" | ||
| SuggestionsLayoutMode="@ChatSuggestionsLayoutMode.Scroll" | ||
| OnSuggestionClick="@HandleSuggestionClick"> | ||
| </TelerikChat> | ||
|
|
||
| @code { | ||
| private List<ChatMessage> ChatData { get; set; } = new(); | ||
|
|
||
| private List<string> QuickReplies = new List<string> | ||
| { | ||
| "Request project status update", | ||
| "Schedule a follow-up meeting", | ||
| "Review document", | ||
| "Send report", | ||
| "Approve changes" | ||
| }; | ||
|
|
||
| private void HandleSuggestionClick(ChatSuggestionClickEventArgs args) | ||
| { | ||
| // Handle suggestion click | ||
| } | ||
|
|
||
| public class ChatMessage | ||
| { | ||
| public string Id { get; set; } | ||
| public string AuthorId { get; set; } | ||
| public string Content { get; set; } | ||
| public DateTime Timestamp { get; set; } | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
| Use `Scroll` or `ScrollButtons` mode when you have many suggestions or longer text that won't fit comfortably in the available width. The `ScrollButtons` mode is particularly helpful for users who prefer button navigation over scrolling gestures. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, these seem more appropriate toward the start of the section. |
||
|
|
||
| ## Suggested Actions Layout Mode | ||
|
|
||
| The `SuggestedActionsLayoutMode` parameter controls how suggested actions (quick actions attached to specific messages) are displayed. Similar to `SuggestionsLayoutMode`, it offers three layout options: | ||
|
|
||
| * `ChatSuggestedActionsLayoutMode.Wrap` - Suggested actions wrap to the next line (default) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Switch to mdashes :) |
||
| * `ChatSuggestedActionsLayoutMode.Scroll` - Suggested actions are displayed in a single line with horizontal scrolling | ||
| * `ChatSuggestedActionsLayoutMode.ScrollButtons` - Suggested actions are displayed in a single line with horizontal scrolling and navigation buttons | ||
|
|
||
| ````Razor | ||
| <TelerikChat Data="@ChatData" | ||
| SuggestedActionsLayoutMode="@ChatSuggestedActionsLayoutMode.ScrollButtons" | ||
| OnSendMessage="@HandleSendMessage"> | ||
| </TelerikChat> | ||
|
|
||
| @code { | ||
| private List<ChatMessage> ChatData { get; set; } = new() | ||
| { | ||
| new ChatMessage | ||
| { | ||
| Id = "1", | ||
| AuthorId = "bot", | ||
| Content = "How would you like to proceed?", | ||
| Timestamp = DateTime.Now, | ||
| SuggestedActions = new List<string> | ||
| { | ||
| "Option 1: Quick action", | ||
| "Option 2: Detailed review", | ||
| "Option 3: Schedule later", | ||
| "Option 4: Request more info" | ||
| } | ||
| } | ||
| }; | ||
|
|
||
| private void HandleSendMessage(ChatSendMessageEventArgs args) | ||
| { | ||
| // Handle send message | ||
| } | ||
|
|
||
| public class ChatMessage | ||
| { | ||
| public string Id { get; set; } | ||
| public string AuthorId { get; set; } | ||
| public string Content { get; set; } | ||
| public DateTime Timestamp { get; set; } | ||
| public List<string> SuggestedActions { get; set; } | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
| Suggested actions are contextual quick replies that appear below specific messages, helping guide users through conversations or workflows. The layout mode ensures they are displayed effectively regardless of their number or length. | ||
|
|
||
| >caption Basic message suggestions | ||
|
|
||
| ````razor | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.