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
        • addContext
        • Context
        • createSimpleContext
        • GatherInfo & GatherQuestion
        • getCompletionAction
        • getContext
        • getGatherInfo
        • getQuestions
        • getStepOrder
        • getSteps
        • getValidContexts
        • reset
        • Step
        • toDict
        • validate
      • DataMap
      • FunctionResult
      • Helper Functions & Utilities
      • LiveWire
      • PomBuilder
      • Prefabs
      • SkillBase
      • SkillManager
      • SkillRegistry
      • Skills
      • SwaigFunction
      • SwmlBuilder
      • SWMLService
    • 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
  • Returns
  • Example
AgentsContextBuilder

validate

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

DataMap

Next
Built with

Validate the entire context configuration. Called automatically during SWML rendering, but can be called manually to catch errors early.

Checks performed:

  • At least one context exists.
  • A single context is named "default".
  • Every context has at least one step.
  • Each context’s initial_step (if set) references a real step in that context.
  • All context-level valid_contexts references point to contexts that exist in the builder.
  • All step-level valid_steps references point to real step names (or the literal "next") in the same context.
  • All step-level valid_contexts references point to contexts that exist in the builder.
  • All gather_info question keys are unique within a single step.
  • All gather_info completion_action targets point to "next_step" or a real step in the same context.
  • No user-defined SWAIG tool collides with the reserved native tool names (next_step, change_context, gather_submit).

Returns

void — Throws Error with a descriptive message if validation fails.

Example

1import { ContextBuilder } from '@signalwire/sdk';
2
3const builder = new ContextBuilder();
4const ctx = builder.addContext('default');
5ctx.addStep('greet').setText('Hello!');
6
7try {
8 builder.validate();
9} catch (e) {
10 console.log(`Invalid context config: ${e}`);
11}