***

title: ai
slug: /reference/python/agents/swml-builder/ai
description: Add an AI verb to start an AI-powered conversation.
max-toc-depth: 3
---------------------

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

Add an `ai` verb to the main section. Starts an AI-powered conversation on the call.

<Note>
  `prompt_text` and `prompt_pom` are mutually exclusive. Provide one or the other to
  set the AI system prompt, but not both.
</Note>

## **Parameters**

<ParamField path="prompt_text" type="Optional[str]" toc={true}>
  Plain text system prompt for the AI. Mutually exclusive with `prompt_pom`.
</ParamField>

<ParamField path="prompt_pom" type="Optional[list[dict[str, Any]]]" toc={true}>
  Prompt Object Model (POM) structure for the AI prompt. A list of section dictionaries
  with keys like `"section"`, `"body"`, and `"bullets"`. Mutually exclusive with
  `prompt_text`.
</ParamField>

<ParamField path="post_prompt" type="Optional[str]" toc={true}>
  Instructions for summarizing the call after the AI conversation ends.
</ParamField>

<ParamField path="post_prompt_url" type="Optional[str]" toc={true}>
  URL where the post-prompt summary is sent via webhook.
</ParamField>

<ParamField path="swaig" type="Optional[dict[str, Any]]" toc={true}>
  SWAIG (SignalWire AI Gateway) configuration with tool function definitions and
  defaults. Structure: `{"defaults": {"web_hook_url": "..."}, "functions": [...]}`.
</ParamField>

<ParamField path="**kwargs" type="Any" toc={true}>
  Additional AI verb parameters passed directly into the verb config (e.g.,
  `hints`, `languages`, `params`, `global_data`).
</ParamField>

## **Returns**

`Self` -- The builder instance for method chaining.

## **Example**

```python {9}
from signalwire import SWMLService, SWMLBuilder

service = SWMLService(name="ai-agent")
builder = SWMLBuilder(service)

swml_json = (
    builder
    .answer()
    .ai(
        prompt_text="You are a helpful customer service assistant.",
        post_prompt="Summarize what was discussed.",
        post_prompt_url="https://example.com/post_prompt",
        swaig={
            "defaults": {"web_hook_url": "https://example.com/swaig"},
            "functions": [
                {
                    "function": "check_order",
                    "description": "Check order status",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "order_id": {"type": "string", "description": "The order ID"}
                        },
                        "required": ["order_id"]
                    }
                }
            ]
        },
        hints=["order", "tracking", "refund"],
        params={"end_of_speech_timeout": 500}
    )
    .render()
)
print(swml_json)
```