For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
        • addSection
        • addVerb
        • addVerbToSection
        • asRouter
        • extractSipUsername
        • getApp
        • getBasicAuthCredentials
        • getBuilder
        • getDocument
        • manualSetProxyUrl
        • onRequest
        • registerRoutingCallback
        • registerVerbHandler
        • renderDocument
        • renderSwml
        • resetDocument
        • run
        • serve
        • setOnRequestCallback
        • stop
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • ChatResource
      • Compat
      • Datasphere
      • Fabric
      • ImportedNumbersResource
      • Logs
      • LookupResource
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSubResource
      • Queues
      • Recordings
      • Registry
      • RestClient
      • RestError
      • Short Codes
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
AgentsSWMLService

registerVerbHandler

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

renderDocument

Next
Built with

Register a custom verb handler for specialized validation and configuration of a SWML verb. When a verb with a registered handler is added via addVerb(), the handler’s validateConfig() method is used instead of generic schema validation.

Custom verb handlers are useful when a verb has complex validation rules that go beyond JSON Schema checks — for example, mutually exclusive parameters or conditional requirements.

Parameters

handler
SWMLVerbHandlerRequired

An object implementing the SWMLVerbHandler interface. Must implement three methods:

  • getVerbName(): string — returns the verb name this handler manages
  • validateConfig(config): [boolean, string[]] — returns [isValid, errors]
  • buildConfig(opts): Record<string, unknown> — returns a configuration object

Returns

void

Example

1import { SWMLService } from '@signalwire/sdk';
2import type { SWMLVerbHandler } from '@signalwire/sdk';
3
4const customHandler: SWMLVerbHandler = {
5 getVerbName() {
6 return 'my_verb';
7 },
8 validateConfig(config: Record<string, unknown>) {
9 const errors: string[] = [];
10 if (!('target' in config)) {
11 errors.push("Missing required field 'target'");
12 }
13 return [errors.length === 0, errors];
14 },
15 buildConfig(opts: Record<string, unknown>) {
16 return { target: opts.target };
17 },
18};
19
20const service = new SWMLService({ name: 'custom-service' });
21service.registerVerbHandler(customHandler);
22
23// Now addVerb will use the custom handler for validation
24service.addVerb('my_verb', { target: 'https://example.com' });
25console.log(service.renderDocument());