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
        • cleanup
        • defineTool
        • getAgent
        • getConfig
        • getDataMapTools
        • getGlobalData
        • getHints
        • getInstanceKey
        • getParameterSchema
        • getPromptSections
        • getSkillData
        • getSkillNamespace
        • getTools
        • hasAllEnvVars
        • hasAllPackages
        • isInitialized
        • markInitialized
        • setAgent
        • setup
        • updateSkillData
        • validateEnvVars
        • validatePackages
      • 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
  • Parameters
  • Returns
  • Example
AgentsSkillBase

defineTool

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

getAgent

Next
Built with

Imperatively register a SWAIG tool with this skill. The tool definition is merged with the skill’s swaigFields (explicit fields on toolDef take precedence) and then appended to the internal dynamic tool list. The default getTools() implementation returns these dynamic tools at SWML render time.

Use defineTool() from setup() when the tool shape depends on config evaluated at setup time (e.g., an API key that changes the available actions). Skills with a static tool list should override getTools() directly instead.

Parameters

toolDef
SkillToolDefinitionRequired

The tool definition. Must include at minimum name, description, parameters, and handler.

toolDef.name
stringRequired

Tool name exposed to the AI.

toolDef.description
stringRequired

One-sentence summary the AI sees when choosing whether to call the tool.

toolDef.parameters
Record<string, unknown>Required

JSON-Schema-style parameter description.

toolDef.handler
(args, raw) => Promise<FunctionResult>Required

Async function invoked when the AI calls the tool.

toolDef.secure
boolean

When true, the tool requires signed tokens for invocation.

Returns

void

Example

1import { SkillBase, FunctionResult } from '@signalwire/sdk';
2
3export class TimeSkill extends SkillBase {
4 static SKILL_NAME = 'time';
5 static SKILL_DESCRIPTION = 'Tells the current time.';
6
7 async setup(): Promise<boolean> {
8 const timezone = this.getConfig<string>('timezone', 'UTC');
9 this.defineTool({
10 name: 'get_time',
11 description: `Get the current time in ${timezone}.`,
12 parameters: { type: 'object', properties: {} },
13 handler: async () => {
14 const now = new Date().toLocaleString('en-US', { timeZone: timezone });
15 return new FunctionResult().setResponse(`It's ${now}`);
16 },
17 });
18 return true;
19 }
20}