AutomationFlowsAI & RAG › Create Structured XML System Messages for AI Agents with Claude 4 Sonnet

Create Structured XML System Messages for AI Agents with Claude 4 Sonnet

ByPaul @diagopl on n8n.io

XML (Extensible Markup Language) engineering is a foundational technique in modern software and system architecture. It enables the structured creation, storage, and exchange of messages—such as system instructions, configuration, or logs—by providing a human-readable,…

Chat trigger trigger★★★☆☆ complexityAI-powered9 nodesChat TriggerAnthropic ChatMemory Buffer WindowAgent
AI & RAG Trigger: Chat trigger Nodes: 9 Complexity: ★★★☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #6821 — we link there as the canonical source.

This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "5b147583-c453-434c-bbf9-52e116a5422f",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        0,
        0
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "62f745df-0a4f-462d-8b6a-045cf7c1ae72",
      "name": "Anthropic Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
      "position": [
        224,
        208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "claude-sonnet-4-20250514",
          "cachedResultName": "Claude 4 Sonnet"
        },
        "options": {}
      },
      "credentials": {
        "anthropicApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "9c93876d-d854-4f6a-a09b-15a9a55872b4",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        352,
        208
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "eec1e7c6-2b03-423f-bf53-c3e762931c3b",
      "name": "Create System messages",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        272,
        0
      ],
      "parameters": {
        "options": {
          "systemMessage": "<system_message>\n<agent_identity>\n<role>XML System Message Architect</role>\n<primary_function>Transform user-provided context and requirements into professional, well-structured XML system messages for AI agents</primary_function>\n<expertise>\n- XML formatting and structure optimization\n- AI prompt engineering best practices\n- System message component design\n- Role definition and task specification\n- Requirement analysis and organization\n</expertise>\n</agent_identity>\n\n<core_responsibilities>\n<analysis>\n- Parse user-provided context to identify key components\n- Extract role definitions, tasks, and requirements\n- Identify input/output specifications and constraints\n- Recognize quality standards and formatting needs\n</analysis>\n\n<structure_design>\n- Create logical XML hierarchy for system messages\n- Organize components into coherent, scannable sections\n- Establish clear relationships between different elements\n- Ensure proper nesting and element relationships\n</structure_design>\n\n<optimization>\n- Transform verbose instructions into concise, actionable directives\n- Eliminate redundancy while preserving essential information\n- Enhance clarity through strategic use of XML tags\n- Improve readability through proper formatting and spacing\n</optimization>\n</core_responsibilities>\n\n<xml_standards>\n<formatting_principles>\n- Use semantic XML tags that clearly describe content purpose\n- Maintain consistent indentation and hierarchy\n- Group related concepts under appropriate parent elements\n- Use descriptive tag names that enhance readability\n</formatting_principles>\n\n<structural_components>\n- Agent identity and role definition\n- Task specifications and objectives\n- Input/output requirements\n- Quality standards and constraints\n- Technical specifications\n- Output format expectations\n</structural_components>\n\n<best_practices>\n- Avoid deeply nested structures that reduce readability\n- Use attributes sparingly, prefer element content\n- Include clear section dividers for complex instructions\n- Maintain parallel structure across similar elements\n- Ensure tags are self-documenting and intuitive\n</best_practices>\n</xml_standards>\n\n<content_processing>\n<requirement_extraction>\n- Identify explicit instructions and implicit expectations\n- Distinguish between mandatory requirements and preferences\n- Recognize format specifications and output constraints\n- Extract quality standards and performance metrics\n</requirement_extraction>\n\n<information_organization>\n- Group related requirements under thematic categories\n- Prioritize information based on importance and usage frequency\n- Create logical flow from role definition to output expectations\n- Separate technical specifications from content guidelines\n</information_organization>\n\n<clarity_enhancement>\n- Replace ambiguous language with specific, actionable terms\n- Convert complex sentences into clear, direct instructions\n- Use bullet points and lists where appropriate within XML structure\n- Eliminate jargon and unnecessary complexity\n</clarity_enhancement>\n</content_processing>\n\n<output_specifications>\n<xml_structure>\n- Begin with clear system_message root element\n- Include properly nested sections for all major components\n- Use consistent naming conventions throughout\n- Maintain proper XML syntax and validation\n</xml_structure>\n\n<content_requirements>\n- Preserve all essential information from user context\n- Enhance clarity without changing fundamental meaning\n- Organize information in logical, hierarchical manner\n- Include specific examples or guidelines where beneficial\n</content_requirements>\n\n<quality_standards>\n- Ensure XML is well-formed and properly structured\n- Verify all requirements from original context are addressed\n- Maintain professional tone appropriate for system messages\n- Create output that is immediately usable for AI agents\n</quality_standards>\n</output_specifications>\n\n<interaction_guidelines>\n<user_input_handling>\n- Accept context in any format (plain text, bullet points, existing prompts)\n- Ask clarifying questions only when requirements are genuinely ambiguous\n- Identify missing critical components and request necessary information\n- Adapt to user's preferred complexity level and technical depth\n</user_input_handling>\n\n<output_delivery>\n- Provide complete, ready-to-use XML system message\n- Include brief explanation of structural choices when helpful\n- Offer suggestions for further optimization if requested\n- Ensure output requires no additional formatting or modification\n</output_delivery>\n\n<iterative_improvement>\n- Accept feedback on generated XML structure\n- Modify specific sections without rebuilding entire message\n- Explain reasoning behind structural decisions when asked\n- Provide alternative organizational approaches when beneficial\n</iterative_improvement>\n</interaction_guidelines>\n\n<task_execution>\nWhen provided with context for creating an XML system message:\n\n1. Analyze the user's requirements and extract key components\n2. Design appropriate XML structure based on content complexity\n3. Organize information into logical, hierarchical sections\n4. Transform verbose instructions into clear, actionable XML elements\n5. Ensure all original requirements are preserved and enhanced\n6. Deliver complete, well-formatted XML system message ready for implementation\n\nFocus on creating professional, scannable, and immediately usable XML system messages that enhance AI agent performance through clear structure and comprehensive requirements specification.\n</task_execution>\n</system_message>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "005b6343-64ea-4fcf-a6cc-655e0e5c7424",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        208,
        -80
      ],
      "parameters": {
        "color": 5,
        "width": 416,
        "height": 176,
        "content": "## Create system messages in XML based on the context provided"
      },
      "typeVersion": 1
    },
    {
      "id": "f10546b7-c0d3-4195-9358-e15ee3436f36",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        -64
      ],
      "parameters": {
        "content": "### See the output example in the Provided Agent system message itself"
      },
      "typeVersion": 1
    },
    {
      "id": "ecaa7dd5-88d2-45d1-a390-bd2dbd617e1b",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1008,
        -240
      ],
      "parameters": {
        "color": 5,
        "width": 960,
        "height": 1104,
        "content": "# Agent XML System Message Engineering: Enabling Robust Enterprise Integration and Automation\n\n## Why Creating System Messages in XML Is Important\n\n**XML (Extensible Markup Language) engineering** is a foundational technique in modern software and system architecture. It enables the structured creation, storage, and exchange of messages\u2014such as system instructions, configuration, or logs\u2014by providing a human-readable, platform-independent, and machine-processable format. Here\u2019s why this matters and how big tech companies leverage it:\n\n### Importance of XML in Engineering\n\n- **Standardization & Interoperability:** XML provides a consistent way to model and exchange data between different software components, no matter the underlying technology. This enables seamless integration of diverse systems, both internally within companies and externally across partners or clients.\n- **Traceability & Accountability:** By capturing not only the data but also its context (e.g., source, format, transformation steps), XML enables engineers to trace logic, troubleshoot issues, and ensure regulatory compliance. This is particularly crucial in sectors like finance, healthcare, and engineering where audit trails and documentation are mandatory.\n- **Configuration & Flexibility:** XML files are widely used for application settings. The clear hierarchical structure allows easy updates, quick testing of setups, and management of complex configurations\u2014without deep developer intervention.\n- **Reusability & Automation:** Automating the creation of system messages or logs in XML allows organizations to reuse and adapt those messages for various systems or processes, reducing manual effort, errors, and improving scalability.\n\n### How Big Tech Companies Use XML\n\n- **System Integration and Messaging:** Large enterprises including Amazon, Google, Microsoft, and SAP use XML for encoding, transporting, and processing data between distributed systems via web services (such as SOAP and REST APIs), often at web scale.\n- **Business Process Automation:** In supply chain management, e-commerce, and transactional processing, XML enables rapid, secure, and traceable information exchange\u2014helping automate operations that cross organizational and geographical borders.\n- **Content Management & Transformation:** Companies use XML to manage and deliver dynamic content\u2014such as translations, different document layouts, or multi-channel publishing\u2014by separating data from its presentation and enabling real-time transformations through XSLT or similar technologies.\n- **Data Storage, Validation, and Big Data:** XML\u2019s schema definitions (XSD) and well-defined structure are used by enterprises for validating and storing data models, supporting compatibility and quality across complex systems, including big data applications.\n\n### Why XML System Message Engineering Remains Relevant\n\n> \u201cXML is currently the most sophisticated format for distributed data \u2014 the World Wide Web can be seen as one huge XML database... Rapid adoption by industry [reinforces] that XML is no longer optional.\u201d\n\n- It brings **consistency**, **scalability**, and **reliability** to how software communicates, making development faster and systems more robust.\n- Enterprises continue to use XML alongside newer formats (like JSON) wherever rich validation, structured messaging, and backward compatibility with legacy systems are required.\n\n**In summary:** XML engineering empowers organizations, especially tech giants, to build, scale, and manage complex digital ecosystems by facilitating integration, automation, traceability, and standardization of data and messages across their platforms, operations, and partners.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a2b6c9cc-d65a-490b-9688-33c0dce8c0d8",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        672,
        128
      ],
      "parameters": {
        "color": 3,
        "width": 576,
        "height": 560,
        "content": "## \nNeed a tailor-made workflow? Tell me about your business and get a free proposal:\n\n**[Start here \u2192 Custom Automation Form](https://taskmorphr.com/contact)**\n\n---\n## \ud83d\udcc8 Cost-Savings Snapshot  \nCurious what automation could save you?  \nRun the 60-second calculator:\n\n**[ROI / Cost Comparison](https://taskmorphr.com/cost-comparison)**\n\n---\n### \u2709\ufe0f Reach me directly  \n`paul@taskmorphr.com`"
      },
      "typeVersion": 1
    },
    {
      "id": "fdcaa324-6fd3-4414-9738-8cdd18e5e6d3",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        992,
        528
      ],
      "parameters": {
        "color": 3,
        "width": 224,
        "height": 128,
        "content": "### \ud83d\udee0\ufe0f Build it yourself  \nBrowse every ready-made workflow:  \n[Full Template Pack \u2014 coming soon](https://n8n.io/creators/diagopl/)\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Create System messages",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Anthropic Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Create System messages",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Create System messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

XML (Extensible Markup Language) engineering is a foundational technique in modern software and system architecture. It enables the structured creation, storage, and exchange of messages—such as system instructions, configuration, or logs—by providing a human-readable,…

Source: https://n8n.io/workflows/6821/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Think Tool. Uses stickyNote, agent, googleCalendarTool, memoryBufferWindow. Chat trigger; 28 nodes.

Agent, Google Calendar Tool, Memory Buffer Window +8
AI & RAG

ModelRouter. Uses chatTrigger, agent, modelSelector, httpRequest. Chat trigger; 28 nodes.

Chat Trigger, Agent, Model Selector +8
AI & RAG

✨ Intro This workflow shows how to go beyond a “plain” AI chatbot by:

Telegram, OpenAI, OpenAI Chat +13
AI & RAG

Bring your solo podcast to life — on full autopilot. This workflow uses GPT-5 and Claude Sonnet to turn a single topic input into a complete podcast episode intro and ready-to-send audio file.

Chat Trigger, OpenAI Chat, Memory Buffer Window +4
AI & RAG

https://www.youtube.com/watch?v=OwIFK-r-NtQ

Agent, Memory Buffer Window, Anthropic Chat +5