For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReference
GuidesReference
    • Core
      • Overview
    • Agents
      • Overview
      • AgentBase
      • AgentServer
      • BedrockAgent
      • CLI Tools
      • Configuration
      • ContextBuilder
      • DataMap
      • FunctionResult
      • Helper Functions
      • LiveWire
      • MCP Gateway
      • PomBuilder
      • Prefabs
      • Search
      • SkillBase
      • Skills
      • SWAIGFunction
      • SWMLBuilder
        • add_section
        • ai
        • answer
        • build
        • hangup
        • play
        • render
        • reset
        • say
      • SWMLService
      • WebService
    • RELAY
      • Overview
      • Actions
      • Call
      • Constants
      • Events
      • Message
      • RelayClient
      • RelayError
    • REST Client
      • Overview
      • Addresses
      • Calling
      • Chat
      • Compat
      • Datasphere
      • Fabric
      • Imported Numbers
      • Logs
      • Lookup
      • MFA
      • Number Groups
      • Phone Numbers
      • Project
      • PubSub
      • Queues
      • Recordings
      • Registry
      • RestClient
      • Short Codes
      • SignalWireRestError
      • SIP Profile
      • Verified Callers
      • Video
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Parameters
  • Returns
  • Example
AgentsSWMLBuilder

ai

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

answer

Next
Built with

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

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

Parameters

prompt_text
Optional[str]

Plain text system prompt for the AI. Mutually exclusive with prompt_pom.

prompt_pom
Optional[list[dict[str, Any]]]

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.

post_prompt
Optional[str]

Instructions for summarizing the call after the AI conversation ends.

post_prompt_url
Optional[str]

URL where the post-prompt summary is sent via webhook.

swaig
Optional[dict[str, Any]]

SWAIG (SignalWire AI Gateway) configuration with tool function definitions and defaults. Structure: {"defaults": {"web_hook_url": "..."}, "functions": [...]}.

**kwargs
Any

Additional AI verb parameters passed directly into the verb config (e.g., hints, languages, params, global_data).

Returns

Self — The builder instance for method chaining.

Example

1from signalwire import SWMLService, SWMLBuilder
2
3service = SWMLService(name="ai-agent")
4builder = SWMLBuilder(service)
5
6swml_json = (
7 builder
8 .answer()
9 .ai(
10 prompt_text="You are a helpful customer service assistant.",
11 post_prompt="Summarize what was discussed.",
12 post_prompt_url="https://example.com/post_prompt",
13 swaig={
14 "defaults": {"web_hook_url": "https://example.com/swaig"},
15 "functions": [
16 {
17 "function": "check_order",
18 "description": "Check order status",
19 "parameters": {
20 "type": "object",
21 "properties": {
22 "order_id": {"type": "string", "description": "The order ID"}
23 },
24 "required": ["order_id"]
25 }
26 }
27 ]
28 },
29 hints=["order", "tracking", "refund"],
30 params={"end_of_speech_timeout": 500}
31 )
32 .render()
33)
34print(swml_json)