> For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

# add_verb

> Add a SWML verb to the main section of the document.

[ref-swmlservice]: /docs/server-sdks/reference/python/agents/swml-service

Add a verb to the `main` section of the current SWML document. The verb is validated
against the SWML schema (or a registered custom handler) before being appended. Raises
`SchemaValidationError` if validation is enabled and the verb config is invalid.

[SWMLService][ref-swmlservice] also auto-generates convenience methods for every verb defined in the SWML
schema (e.g., `service.play(url=...)`, `service.connect(to=...)`). These call `add_verb`
internally. Use `add_verb` directly when you need to pass a pre-built config dictionary
or work with custom verbs.

## **Parameters**

**`verb_name`** `str` — required

The SWML verb name (e.g., `"answer"`, `"play"`, `"ai"`, `"hangup"`, `"connect"`).

---

**`config`** `dict[str, Any] | int` — required

Configuration dictionary for the verb. Most verbs accept a dict of parameters.
The `sleep` verb is a special case that accepts a direct `int` value representing
milliseconds.

---

## **Returns**

`bool` — `True` if the verb was added successfully, `False` if the config type was
invalid (non-dict for non-sleep verbs).

## **Example**

```python {4-7}
from signalwire import SWMLService

service = SWMLService(name="ivr")
service.add_verb("answer", {})
service.add_verb("play", {"url": "https://example.com/greeting.mp3"})
service.add_verb("sleep", 2000)
service.add_verb("hangup", {"reason": "completed"})

print(service.render_document())
```