SWMLService

View as MarkdownOpen in Claude

SWMLService is a lightweight HTTP service for serving non-AI SWML documents. Unlike AgentBase (which always produces an AI block), SWMLService generates pure SWML call-flow documents: IVR menus, voicemail, call recording, etc.

It uses a SwmlBuilder internally for verb construction and Hono for HTTP serving.

SWMLService generates and serves SWML documents over HTTP. See the SWML reference for the full document specification.

Constructor

opts
SWMLServiceOptions

Optional configuration object.

opts.name
stringDefaults to swml-service

Service display name used in logging and startup messages.

opts.route
stringDefaults to /

HTTP route path where the service is accessible.

opts.basicAuth
[string, string]

Basic auth credentials as [username, password]. Unlike AgentBase, SWMLService does not fall back to environment variables — credentials must be provided explicitly.

Properties

name
string

Service display name.

route
string

HTTP route path where this service is accessible.

Methods

Example

1import { SWMLService } from '@signalwire/sdk';
2
3const service = new SWMLService({ name: 'my-ivr', route: '/' });
4service.addVerb('answer', {});
5service.addVerb('play', { url: 'https://example.com/greeting.mp3' });
6service.addVerb('hangup', {});
7
8await service.run();