Skip to main content
All docs
V26.1
  • AIChatControl.SendMessageAsync(String, List<IAIChatMessageContextItem>) Method

    Sends a multimodal message to the AI service.

    Namespace: DevExpress.AIIntegration.WinForms.Chat

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

    NuGet Package: DevExpress.AIIntegration.WinForms.Chat

    Declaration

    public Task SendMessageAsync(
        string text,
        List<IAIChatMessageContextItem> contexts = null
    )

    Parameters

    Name Type Description
    text String

    The message text.

    Optional Parameters

    Name Type Default Description
    contexts List<IAIChatMessageContextItem> null

    A collection of context items associated with the message.

    Returns

    Type Description
    Task

    A task that completes when the message is sent.

    Remarks

    To manually process messages sent to an AI service, handle the MessageSending event. For example, you can manually call the AI client or service of choice, and return its responses to the chat.

    Note

    Set the e.Cancel event parameter to true to block automatic message delivery, and call the SendMessageAsync method to send the message to the AI service manually.

    Example

    The following example sends a modified message to the AI service:

    using DevExpress.AIIntegration.Blazor.Chat.WebView;
    
    async void AiChatControl1_MessageSending(object sender, AIChatControlMessageSendingEventArgs e) {
        e.Cancel = true;
        await e.Chat.SendMessageAsync($"Processed: {e.Text}");
    }
    

    Refer to the following help topic for additional information: AI Chat Control

    See Also