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
      • BedrockAgent
      • CLI Tools
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions
      • LiveWire
      • MCP Gateway
      • PomBuilder
      • Prefabs
      • Search
      • SkillBase
      • Skills
      • SWAIGFunction
        • execute
        • to_swaig
        • validate_args
      • SWMLBuilder
      • SWMLService
      • WebService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • Chat
      • Compat
      • Datasphere
      • Fabric
      • Imported Numbers
      • Logs
      • Lookup
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSub
      • Queues
      • Recordings
      • Registry
      • RestClient
      • Short Codes
      • SignalWireRestError
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
AgentsSWAIGFunction

to_swaig

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

validate_args

Next
Built with

Convert this function to a SWAIG-compatible dictionary for inclusion in a SWML document. Called internally during SWML rendering.

Parameters

base_url
strRequired

Base URL for the webhook endpoint.

token
str

Auth token to include in the webhook URL.

call_id
str

Call ID for session tracking.

include_auth
boolDefaults to true

Whether to include auth credentials in the webhook URL.

Returns

dict[str, Any] — Dictionary with "function", "description", "parameters", "web_hook_url", and optional "fillers" keys.

Example

1from signalwire import SWAIGFunction
2from signalwire import FunctionResult
3
4func = SWAIGFunction(
5 name="check_order",
6 handler=lambda args, raw_data: FunctionResult("ok"),
7 description="Check order status",
8 parameters={
9 "type": "object",
10 "properties": {
11 "order_id": {"type": "string", "description": "Order ID"}
12 },
13 "required": ["order_id"]
14 }
15)
16
17swaig_dict = func.to_swaig(
18 base_url="https://myapp.example.com",
19 token="abc123",
20 call_id="call-12345"
21)
22
23print(swaig_dict)
24# {
25# "function": "check_order",
26# "description": "Check order status",
27# "parameters": {...},
28# "web_hook_url": "https://myapp.example.com/swaig?token=abc123&call_id=call-12345"
29# }