> This page is for Server SDKs.

> Fetch clean Markdown by appending `.md` to any page URL under https://signalwire.com/docs or requesting it with the HTTP header `Accept: text/markdown`. The root index at https://signalwire.com/docs/llms.txt lists the available documentation indexes.

# Helper Functions

> Convenience functions for creating common DataMap patterns.

[ref-datamap]: /docs/server-sdks/reference/python/agents/data-map

[ref-functionresult]: /docs/server-sdks/reference/python/agents/function-result

```python
from signalwire import create_simple_api_tool
```

Create a DataMap for a straightforward single-endpoint API call with minimal
configuration.

## **Parameters**

**`name`** `str` — required

Function name.

---

**`url`** `str` — required

API endpoint URL.

---

**`response_template`** `str` — required

Template string for formatting the response.

---

**`parameters`** `dict[str, dict]`

Parameter definitions. Keys are parameter names, values are dicts with
`"type"`, `"description"`, and optional `"required"` keys.

---

**`method`** `str` — default: GET

HTTP method.

---

**`headers`** `dict[str, str]`

HTTP headers.

---

**`body`** `dict[str, Any]`

Request body for POST/PUT.

---

**`error_keys`** `list[str]`

Keys indicating an error response.

---

## **Returns**

[`DataMap`][ref-datamap] -- A fully configured DataMap ready for further chaining or conversion.

---

```python
from signalwire import create_expression_tool
```

Create a DataMap for pattern-matching responses without API calls.

## **Parameters**

**`name`** `str` — required

Function name.

---

**`patterns`** `dict[str, tuple[str, FunctionResult]]` — required

Dictionary mapping test values to `(pattern, [FunctionResult][ref-functionresult])` tuples.

---

**`parameters`** `dict[str, dict]`

Parameter definitions (same format as `create_simple_api_tool`).

---

## **Returns**

`DataMap` -- A fully configured DataMap.

## **Example**

```python
from signalwire import AgentBase
from signalwire import create_simple_api_tool, create_expression_tool
from signalwire import FunctionResult

# Simple API tool -- one line instead of a full DataMap chain
weather = create_simple_api_tool(
    name="get_weather",
    url="https://api.weatherapi.com/v1/current.json?key=KEY&q=${enc:args.city}",
    response_template="Weather in ${args.city}: ${response.current.condition.text}",
    parameters={
        "city": {"type": "string", "description": "City name", "required": True}
    },
    error_keys=["error"]
)

# Expression tool -- pattern matching without API calls
greeting = create_expression_tool(
    name="greet",
    patterns={
        "${args.language}": (r"spanish|espanol", FunctionResult("Hola!")),
    },
    parameters={
        "language": {"type": "string", "description": "Language to greet in"}
    }
)

agent = AgentBase(name="helper-demo")
agent.set_prompt_text("You are a helpful assistant.")
agent.register_swaig_function(weather.to_swaig_function())
agent.register_swaig_function(greeting.to_swaig_function())

if __name__ == "__main__":
    agent.run()
```