add_verb_to_section

View as MarkdownOpen in Claude

Add a verb to a specific named section of the SWML document. If the section does not exist, it is created automatically before the verb is appended. Raises SchemaValidationError if validation is enabled and the verb config is invalid.

Parameters

section_name
strRequired

Name of the section to add the verb to (e.g., "main", "transfer_flow").

verb_name
strRequired

The SWML verb name.

config
dict[str, Any] | intRequired

Configuration dictionary for the verb, or a direct int for the sleep verb.

Returns

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

Example

1from signalwire import SWMLService
2
3service = SWMLService(name="transfer-flow")
4
5# Build the main section
6service.add_verb("answer", {})
7service.add_verb("ai", {"prompt": {"text": "You are a helpful assistant"}})
8
9# Build a separate transfer section
10service.add_verb_to_section("transfer", "connect", {
11 "to": "+15551234567",
12 "from": "+15559876543"
13})
14
15print(service.render_document())