> 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. # PomBuilder > Build structured Prompt Object Model prompts with sections, subsections, and bullets. [agentbase]: /docs/server-sdks/reference/python/agents/agent-base [addsection]: /docs/server-sdks/reference/python/agents/pom-builder/add-section [addsubsection]: /docs/server-sdks/reference/python/agents/pom-builder/add-subsection [addtosection]: /docs/server-sdks/reference/python/agents/pom-builder/add-to-section [fromsections]: /docs/server-sdks/reference/python/agents/pom-builder/from-sections [getsection]: /docs/server-sdks/reference/python/agents/pom-builder/has-section [hassection]: /docs/server-sdks/reference/python/agents/pom-builder/has-section [render]: /docs/server-sdks/reference/python/agents/pom-builder/render [todict]: /docs/server-sdks/reference/python/agents/pom-builder/to-dict [tojson]: /docs/server-sdks/reference/python/agents/pom-builder/to-json PomBuilder provides a fluent interface for creating structured prompts using the Prompt Object Model (POM). POM organizes prompt content into titled sections, subsections, and bullet lists -- producing consistent, well-structured prompts that the AI can follow reliably. Use PomBuilder when you need fine-grained control over prompt structure beyond what `set_prompt_text()` and `prompt_add_section()` on [`AgentBase`][agentbase] provide. The builder can render to Markdown or XML format. > **Note** > > PomBuilder requires the `signalwire-pom` package. Install it with: > `pip install signalwire-pom` ## **Methods** #### [add\_section](/docs/server-sdks/reference/python/agents/pom-builder/add-section) Add a new top-level section to the POM. #### [add\_subsection](/docs/server-sdks/reference/python/agents/pom-builder/add-subsection) Add a subsection to an existing section. #### [add\_to\_section](/docs/server-sdks/reference/python/agents/pom-builder/add-to-section) Add content to an existing section. #### [from\_sections](/docs/server-sdks/reference/python/agents/pom-builder/from-sections) Create a PomBuilder from a list of section dictionaries. #### [get\_section](/docs/server-sdks/reference/python/agents/pom-builder/has-section) Get a section by title for direct manipulation. #### [has\_section](/docs/server-sdks/reference/python/agents/pom-builder/has-section) Check if a section with a given title exists. #### [render](/docs/server-sdks/reference/python/agents/pom-builder/render) Render the POM as Markdown or XML. #### [to\_dict](/docs/server-sdks/reference/python/agents/pom-builder/to-dict) Convert the POM to a list of section dictionaries. #### [to\_json](/docs/server-sdks/reference/python/agents/pom-builder/to-json) Convert the POM to a JSON string. ## **Examples** ### Building a structured prompt ```python {3} from signalwire.core.pom_builder import PomBuilder pom = PomBuilder() pom.add_section( "Role", body="You are a customer service representative for Acme Corp." ) pom.add_section( "Guidelines", bullets=[ "Always greet the customer by name when available", "Be concise and professional", "Never make promises about timelines you cannot keep" ] ) pom.add_section( "Product Knowledge", body="You have access to the product catalog.", subsections=[ { "title": "Pricing", "body": "Always quote current prices from the catalog." }, { "title": "Returns", "body": "30-day return policy for all items." } ] ) # Render as Markdown for use in a prompt prompt_text = pom.render_markdown() print(prompt_text) ``` ### Incremental construction ```python {3} from signalwire.core.pom_builder import PomBuilder pom = PomBuilder() # Start with a basic section pom.add_section("Capabilities", body="You can help with the following:") # Add bullets incrementally as skills are loaded pom.add_to_section("Capabilities", bullet="Weather lookups") pom.add_to_section("Capabilities", bullet="Calendar scheduling") pom.add_to_section("Capabilities", bullets=[ "Order tracking", "Account management" ]) # Add a subsection pom.add_subsection( "Capabilities", "Limitations", body="You cannot process payments directly." ) print(pom.render_markdown()) ``` ### Reconstructing from data ```python {8} from signalwire.core.pom_builder import PomBuilder # Rebuild a PomBuilder from serialized data sections = [ {"title": "Role", "body": "You are a helpful assistant."}, {"title": "Rules", "bullets": ["Be concise", "Be accurate"]} ] pom = PomBuilder.from_sections(sections) xml_prompt = pom.render_xml() print(xml_prompt) ``` > Build structured Prompt Object Model prompts with sections, subsections, and bullets. ## Docs - [add_section](https://signalwire.com/docs/server-sdks/reference/python/agents/pom-builder/add-section.md): Add a new top-level section to the POM. - [add_subsection](https://signalwire.com/docs/server-sdks/reference/python/agents/pom-builder/add-subsection.md): Add a subsection to an existing section. - [add_to_section](https://signalwire.com/docs/server-sdks/reference/python/agents/pom-builder/add-to-section.md): Add content to an existing section. - [from_sections](https://signalwire.com/docs/server-sdks/reference/python/agents/pom-builder/from-sections.md): Create a PomBuilder from a list of section dictionaries. - [has_section / get_section](https://signalwire.com/docs/server-sdks/reference/python/agents/pom-builder/has-section.md): Check if a section exists and retrieve it by title. - [render_markdown / render_xml](https://signalwire.com/docs/server-sdks/reference/python/agents/pom-builder/render.md): Render the POM as Markdown or XML. - [to_dict](https://signalwire.com/docs/server-sdks/reference/python/agents/pom-builder/to-dict.md): Convert the POM to a list of section dictionaries. - [to_json](https://signalwire.com/docs/server-sdks/reference/python/agents/pom-builder/to-json.md): Convert the POM to a JSON string.