addFunctionInclude

View as MarkdownOpen in Claude

Add a remote SWAIG function include so the agent can call tools hosted on an external server. The remote endpoint is contacted at session start and the listed functions become available to the AI just like locally defined tools.

This maps to the SWML ai.swaig.includes array. See the SWML SWAIG includes reference for details.

Parameters

url
stringRequired

URL of the remote SWAIG server that hosts the functions.

functions
string[]Required

Array of function names to include from the remote server.

metaData
Record<string, unknown>

Optional metadata object passed along with the function include. Can be used to provide authentication tokens or context to the remote server.

Returns

AgentBase — Returns this for method chaining.

Example

1import { AgentBase } from '@signalwire/sdk';
2
3const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
4agent.setPromptText('You are a helpful assistant.');
5agent.addFunctionInclude(
6 'https://tools.example.com/swaig',
7 ['lookup_order', 'cancel_order'],
8 { auth_token: 'secret-token' },
9);
10await agent.serve();