Skip to navigation

Agents

TypeScript API reference for AgentBase, SWMLService, SWAIG functions, skills, contexts, LiveWire, and more
View as MarkdownOpen in Claude

The Agents namespace provides the core framework for building AI-powered voice agents with SignalWire. It includes the central AgentBase class, SWML document generation, tool/function definitions, skills, multi-agent hosting, CLI tools for local testing and deployment, and configuration management for security and environment settings.

The Server SDK generates SWML documents under the hood. Each agent produces a SWML document with the ai verb that the SignalWire platform executes.

Example

A complete agent that answers calls, uses an AI prompt, and exposes a custom tool:

import { AgentBase, FunctionResult } from '@signalwire/sdk';
const agent = new AgentBase({ name: 'support-agent', route: '/support' });
agent.setPromptText(
'You are a friendly support agent for Acme Corp. ' +
'Help customers check their order status. ' +
'Be concise and professional.'
);
agent.setParams({ temperature: 0.5, end_of_speech_timeout: 800 });
agent.defineTool({
name: 'check_order',
description: 'Check an order status by ID',
parameters: {
order_id: { type: 'string', description: 'The order ID to check' },
},
handler: (args, rawData) => {
const orderId = (args.order_id as string) || 'unknown';
return new FunctionResult(`Order ${orderId} shipped on March 28 and arrives tomorrow.`);
},
});
await agent.addSkillByName('datetime');
await agent.run();

Classes

AgentBase

The central class for building AI agents. Manages prompts, tools, skills, and serving.

SWMLService

SWML document generation and Hono service for non-AI call flows.

SWMLBuilder

Fluent builder for constructing SWML documents programmatically.

SwaigFunction

Wraps TypeScript functions as callable SWAIG tools with validation and metadata.

FunctionResult

Fluent interface for returning actions and responses from tool functions.

ContextBuilder

Multi-step agent workflows with context and step navigation.

DataMap

Server-side API tools that execute REST calls without agent webhooks.

SkillBase

Base class for building reusable skill plugins.

PomBuilder

Prompt Object Model builder for structured prompt composition.

AgentServer

Host multiple agents on a single Hono process with route-based dispatch.

BedrockAgent

Agent backed by the Amazon Bedrock voice-to-voice model.

AIChatClient

Hold a text conversation with an AI agent from your own server.

ParameterSchema

Fluent builder for typed SWAIG tool parameter schemas.

Prefabs

Pre-built agent templates for common conversational patterns.

Skills

Built-in skills catalog with 19 pluggable capabilities.

CLI

Test SWAIG functions and render SWML locally with swaig-test.

Configuration

Environment variables, config files, security settings, and authentication.

LiveWire

LiveKit-compatible API layer — use familiar livekit-agents classes on SignalWire infrastructure.

SkillManager

Manages the lifecycle of skills loaded on an agent.

SkillRegistry

Global singleton for registering and discovering skills by name.

Helpers & Utilities

Context creation, API tools, security utilities, type inference, and standalone functions.