Skip to main content
All docs
V26.1
  • MessageSendingEventArgs Class

    Contains data for the MessageSending event and allows you to intercept message delivery.

    Namespace: DevExpress.AIIntegration.Blazor.Chat

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

    Declaration

    public class MessageSendingEventArgs :
        CancelEventArgs

    Remarks

    Use the MessageSendingEventArgs argument in a MessageSending event handler to access user input, attached files, and reference the AI Chat component.

    Set the MessageSendingEventArgs.Cancel property to true to block automatic message delivery and send the message to the AI service manually.

    The following code snippet logs the original message and sends a modified prompt to the AI service:

    <DxAIChat MessageSending="OnMessageSending" />
    
    @code {
        private async Task OnMessageSending(MessageSendingEventArgs args) {
            args.Cancel = true;
            Console.WriteLine($"Original message text: {args.Text}");
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("Hello!");
            sb.AppendLine(args.Text);
            await args.Chat.AppendMessageAsync(sb.ToString(), ChatRole.User);
        }
    }
    

    Inheritance

    Object
    EventArgs
    CancelEventArgs
    MessageSendingEventArgs
    See Also