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.`);
},
});
agent.addSkill('datetime');
agent.run();

Classes