Helper Functions
The SignalWire SDK exports several helper functions at the top level for common
tasks like creating simple contexts, building server-side API tools, and
managing the skill registry. All are imported directly from signalwire.
create_simple_context
create_simple_context(name="default") -> Context
Create a standalone Context object
without needing a full ContextBuilder.
Useful for quick single-context agents.
Parameters
name
Context name. For single-context agents this must be "default".
Returns
Context — A new Context
object ready for adding steps.
Example
create_simple_api_tool
create_simple_api_tool(name, url, response_template, parameters=None, method="GET", headers=None, body=None, error_keys=None) -> DataMap
Create a server-side API tool with minimal configuration. Returns a configured
DataMap that executes an HTTP
request on the SignalWire server without requiring a webhook endpoint.
Parameters
name
Function name for the SWAIG tool.
url
API endpoint URL. Supports ${variable} substitution for injecting parameter
values (e.g., "https://api.example.com/search?q=${args.query}").
response_template
Template string for formatting the API response. Uses ${response.field}
syntax to reference fields from the API response JSON.
parameters
Parameter definitions. Each key is a parameter name, and each value is a
dictionary with type, description, and optionally required.
method
HTTP method for the API call.
headers
Optional HTTP headers to include in the request.
body
Optional request body for POST/PUT requests.
error_keys
JSON keys whose presence in the response indicates an error.
Returns
DataMap — A configured DataMap
ready to be added to an agent.
Example
For more complex API integrations with multiple webhooks, fallback outputs, or
array processing, use the DataMap
builder directly.
create_expression_tool
create_expression_tool(name, patterns, parameters=None) -> DataMap
Create a pattern-matching tool that evaluates expressions locally on the SignalWire server without making any HTTP requests. Useful for command routing and conditional responses.
Parameters
name
Function name for the SWAIG tool.
patterns
Dictionary mapping test values to (pattern, [FunctionResult][ref-functionresult]) tuples. The test
value is a template string (e.g., "${args.command}"), and the pattern is a
regex string matched against it.
parameters
Parameter definitions, same format as create_simple_api_tool.
Returns
DataMap — A configured DataMap
with expression-based routing.
Example
Since dictionary keys must be unique, use separate DataMap.expression() calls
via the DataMap builder if you
need multiple patterns against the same test value.
list_skills_with_params
list_skills_with_params() -> dict[str, dict[str, Any]]
Return a comprehensive schema for all available skills, including metadata and parameter definitions. Useful for GUI configuration tools, API documentation, or programmatic skill discovery.
Returns
dict[str, dict[str, Any]] — Dictionary keyed by skill name. Each value
contains the skill’s metadata and a parameters dictionary describing each
configurable parameter with its type, description, required status,
hidden flag, and env_var name.
Example
register_skill
register_skill(skill_class) -> None
Register a custom skill class with the global skill registry. This allows third-party code to make skills available without placing them in a specific directory structure.
Parameters
skill_class
A class that inherits from
SkillBase. Must define
SKILL_NAME and SKILL_DESCRIPTION class attributes.
Example
add_skill_directory
add_skill_directory(path) -> None
Add a directory to the skill search path. Skills in this directory should follow
the same structure as built-in skills (each skill in its own subdirectory with
an __init__.py exporting a SkillBase subclass).
Parameters
path
Path to a directory containing skill subdirectories.