declared_capabilities

View as MarkdownOpen in Claude

Return the capability names the client declared as truthy. Accepts either a full SWML request body or an already-extracted user variables dict, so it works from a dynamic-config callback and from a SWAIG handler without the caller tracking which one it holds.

Parameters

body_params
AnyRequired

A SWML request body, or a user variables dict.

Returns

frozenset[str] — Names whose declared value is truthy. Empty when nothing was declared, the payload was malformed, or the client isn’t a browser at all.

Example

from signalwire.core.capabilities import declared_capabilities
def configure(query_params, body_params, headers, ephemeral_agent):
caps = declared_capabilities(body_params)
if "display_content" in caps:
ephemeral_agent.prompt_add_section("Screen", body="The caller can see a screen.")
if "chat_handoff" in caps:
ephemeral_agent.prompt_add_section("Chat", body="Offer to continue by text if asked.")

Part of the client capabilities module.