Language

HtmlWidgetHelpers Class

Definition

Helper methods for building and validating HTML widget messages.

public static class HtmlWidgetHelpers
type HtmlWidgetHelpers = class
Public Class HtmlWidgetHelpers
Inheritance
HtmlWidgetHelpers

Methods

Name Description
BuildHtmlWidgetMarkdown(HtmlWidgetPayload, HtmlWidgetMarkdownOptions)

Wraps an HTML widget payload in the ```html-widget markdown code fence format required by Teams to render the widget in a message. The widget HTML is sent as authored. The widget owns the ui/initialize handshake and the ui/notifications/size-changed reporting. Without a size reporter, Teams renders the widget at about 150px tall.

BuildHtmlWidgetMessage(HtmlWidgetPayload, HtmlWidgetMarkdownOptions)

Builds a message activity containing an HTML widget, ready to be sent. The widget HTML is sent as authored, so the widget owns the ui/initialize handshake and the ui/notifications/size-changed reporting.

TryGetWidgetModelContext(MessageActivity)

Attempts to extract an MCP UI update-model-context request from a message activity's value. A widget can request that content be added to the model context by reusing the messageBack mechanism (like Action.Submit for adaptive cards). Such a request arrives as a normal message activity whose value carries the McpUiUpdateModelContextRequest payload. This is fire-and-forget: the bot does not respond. The helper is tolerant of two wire shapes: the raw request object, or an envelope of the form { "type": "widgetModelContext", "data": <request> }.

ValidateSecurityPolicy(String, HtmlWidgetSecurityPolicy)

Validates that external references in widget HTML are covered by the declared security policy. Returns a list of warnings for any references to origins not present in the appropriate policy field.

Applies to