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.

BuildHtmlWidgetMessage(HtmlWidgetPayload, HtmlWidgetMarkdownOptions)

Builds a message activity containing an HTML widget, ready to be sent.

InjectWidgetProtocol(String, InjectWidgetProtocolOptions)

Injects the MCP Apps protocol script into widget HTML. If the HTML already contains the protocol (detected by "ui/initialize"), it is returned unchanged.

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