alexa
menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Search Results for

    Show / Hide Table of Contents

    Class ToolBlock

    Represents a tool response block that enables custom, structured, or interactive content to be rendered within the SfAIAssistView conversation.

    Inheritance
    object
    ToolBlock
    Implements
    IResponseBlock
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Syncfusion.Blazor.InteractiveChat
    Assembly: Syncfusion.Blazor.InteractiveChat.dll
    Syntax
    public class ToolBlock : IResponseBlock
    Remarks

    The ToolBlock class is used in generative UI scenarios where AI responses include custom visual elements instead of plain text. The block identifies the tool to render through the ToolName property and supplies the corresponding data through the Props property.

    Tool blocks can be rendered using the ToolUIBlock template and may display custom components such as charts, grids, weather cards, forms, or other application-specific UI.

    The structure of the tool data is application dependent and should match the expected schema of the associated tool. Large datasets may increase memory consumption and rendering time.

    Examples

    The following example demonstrates how to create a tool block that renders a chart:

    var responseBlocks = new List<IResponseBlock>()
    {
        new ToolBlock
        {
            ToolName = "chart-tool",
            Props = new
            {
                chartType = "Line",
                title = "Monthly Revenue",
                chartData = new[]
                {
                    new { Month = "Jan", Revenue = 12000 },
                    new { Month = "Feb", Revenue = 15000 }
                }
            }
        }
    };
    
    await aiAssistView.UpdateResponseAsync(string.Empty, responseBlocks);

    Constructors

    ToolBlock()

    Declaration
    public ToolBlock()

    Properties

    BlockType

    Gets or sets the type of the response block.

    Declaration
    public BlockType BlockType { get; set; }
    Property Value
    Type Description
    BlockType

    A BlockType that specifies the category of the response block. The default value is Tool.

    Remarks

    This property is used by the SfAIAssistView component to identify the block as a tool-based response and invoke the corresponding rendering logic.

    For instances of ToolBlock, this value should typically remain Tool.

    Props

    Gets or sets the tool-specific properties used to render the associated tool.

    Declaration
    public object Props { get; set; }
    Property Value
    Type Description
    object

    An object containing the configuration and data required by the tool. The default value is null.

    Remarks

    The structure of this object varies depending on the value of ToolName. Applications are responsible for interpreting and casting the value to the appropriate type before rendering.

    Typical payloads include chart configuration, grid data, weather information, or other custom data models required by a tool template.

    If the value is null, the associated tool may not have sufficient information to render its content.

    Examples
    var toolBlock = new ToolBlock
    {
        ToolName = "grid-tool",
        Props = new
        {
            data = employeeData,
            columns = columnDefinitions
        }
    };

    ToolName

    Gets or sets the name of the tool associated with the response block.

    Declaration
    public string ToolName { get; set; }
    Property Value
    Type Description
    string

    A string representing the tool identifier used to determine how the block is rendered. The default value is string.Empty.

    Remarks

    The value is typically evaluated within a ToolUIBlock template to select the appropriate custom user interface.

    Common examples include "chart-tool", "grid-tool", and "weather-card".

    Examples
    var toolBlock = new ToolBlock
    {
        ToolName = "weather-card"
    };

    Implements

    IResponseBlock
    In this article
    Back to top Generated by DocFX
    Copyright © 2001 - 2026 Syncfusion Inc. All Rights Reserved