Skip to main content
All docs
V25.1
  • DxAIChat.SendMessage(String, ChatRole, List<AIChatUploadFileInfo>) Method

    Sends a message to the chat.

    Namespace: DevExpress.AIIntegration.Blazor.Chat

    Assembly: DevExpress.AIIntegration.Blazor.Chat.v25.1.dll

    NuGet Package: DevExpress.AIIntegration.Blazor.Chat

    Declaration

    public Task SendMessage(
        string messageContent,
        ChatRole role,
        List<AIChatUploadFileInfo> files = null
    )

    Parameters

    Name Type Description
    messageContent String

    The message text to be sent.

    role Microsoft.Extensions.AI.ChatRole

    The role of the message owner.

    Optional Parameters

    Name Type Default Description
    files List<AIChatUploadFileInfo> null

    A collection of files to be uploaded.

    Returns

    Type Description
    Task

    A task that is completed when the message is sent.

    Remarks

    Call the SendMessage method to send a message to the chat.

    <DxAIChat @ref="Chat" CssClass="demo-chat" />
    <DxButton Text="Start dialog" Click="StartDialog" />
    
    @code {
        DxAIChat Chat { get; set; }
    
        void StartDialog(MouseEventArgs args) {
            var filePath = "C:\\Users\\Public\\images\\AlbertEinstein.jpg";
    
            var fileBytes = File.ReadAllBytes(filePath);
    
            var testFiles = new List<AIChatUploadFileInfo> {
                new AIChatUploadFileInfo(
                    name: Path.GetFileName(filePath),
                    type: "image/jpeg",
                    size: fileBytes.Length,
                    data: new ReadOnlyMemory<byte>(fileBytes)
                )
            };
            Chat.SendMessage("What is s on the image?", Microsoft.Extensions.AI.ChatRole.User, testFiles);
        }
    }
    

    AI Chat - Send Messages Pragrammatically

    See Also