includes
Remote function signatures to include in SWAIG functions. Will allow you to include functions that are defined in a remote location that can be executed during the interaction with the AI. To learn more about how includes works see the request flow section.
Properties
SWAIG.includes
An array of objects that accept the following properties.
includes[].url
URL where the remote functions are defined. Authentication can also be set in the url in the format of username:password@url.
includes[].function
An array of the function names to be included.
includes[].meta_data
Metadata to be passed to the remote function. These are key-value pairs defined by the user.
SWML usage
Request flow
SWAIG includes creates a bridge between AI agents and external functions. When a SWML script initializes, it follows this two-phase process:
Initialization Phase: SWAIG discovers available functions from configured endpoints and requests their signatures to understand what each function can do.
Runtime Phase: The AI agent analyzes conversations, determines when functions match user intent, and executes them with full context.
Signature request
During SWML script initialization, SWAIG acts as a function discovery service. It examines your includes configuration,
identifies the remote functions you’ve declared, then systematically contacts each endpoint to gather function definitions.
How it works:
Looking at our SWML configuration example, SWAIG sends a targeted request to https://example.com/swaig specifically
asking for the get_weather function definition. Along with this request, it forwards any meta_data you’ve
configured—giving your server the context it needs to respond appropriately.
The discovery request:
What your server should return: Your endpoint must respond with complete function definitions that tell SWAIG everything it needs to know. Each function signature follows the SWAIG functions structure and describes the function’s purpose and required parameters:
Your server can optionally include web_hook_auth_user and web_hook_auth_password in each function definition
to set HTTP basic authentication credentials for the function’s web_hook_url.
Function execution request
When the AI agent determines that a function call matches user intent—such as when a user requests weather information SWAIG packages the required information and sends it to the configured endpoint. The full details of the request can be found in the web_hook_url documentation.
Example request format:
SWAIG provides arguments in multiple formats—parsed for direct access, raw for the original text, and substituted
with variable replacements applied. This flexibility supports edge cases and complex parsing scenarios.
Response formats:
When your function completes, it needs to send a response back to SWAIG. You have three main options depending on what you want to accomplish:
Simple Response
Response + Actions
Error Handling
Use this when: Your function just needs to return information to the AI agent.
The AI agent will receive this information and incorporate it naturally into the conversation with the user.
More information about the response format can be found in the web_hook_url documentation.
Flow diagram
The following diagram illustrates the complete SWAIG includes process from initialization to function execution:
Reference implementation
The following implementations demonstrate the essential pattern: define functions, map them to actual code, and handle both signature requests and function executions.
Python/Flask
JavaScript/Express
Testing the implementation
To test the implementation, start the server and simulate SWAIG requesting function signatures. This command requests signatures from the endpoint:
Expected response: A successful response returns function definitions in this format: