SWAIG allows AI Agents to delegate tasks to your backend via HTTP POST. Think of it like CGI (Common Gateway Interface) - where a web server hands off execution to an external program using raw query strings or form-encoded data - but for AI Agents. With SWAIG, instead of messy query strings requiring tedious parsing and validation, you receive clean, structured JSON with context, arguments, and intent.
SWAIG requests include rich context:
"search_movie"),argument.parsed field,argument_desc) to describe expected inputsWhen a SWAIG function is invoked by the AI Agent, your server receives a JSON payload containing:
function name to be executed.argument.parsed.From this request, extract the function name and argument.parsed.
The following sample SWML creates the SWAIG function search_movie:
When your SWAIG function executes, SignalWire sends a request like the following to your server.
On your server, perform the actions needed to generate the desired response using the extracted function name and arguments.
In this case, our application retrieves information about a selected movie from an external API.
response messageThe response can directly shape the AI Agent’s next moves using natural language and SWML instructions.
In reply, your server should return a JSON object with the following:
response (string): A message in Markdown format used by the LLM in its reply.action (array): Optional list of SWML-compatible objects that can execute commands, play media, set metadata, or return inline SWML.For example:
Note that this response includes both response and action sections. This means that our server has both updated the LLM’s context with the requested information from an external API, and handed off new call flow instructions in the form of valid SWML.