DEV Community

jesus manrique
jesus manrique

Posted on • Originally published at guayoyo.tech

The Orchestrator Agent: Teaching Your AI to Understand Your Brand and Execute Briefs — Part 2 of 5

The Orchestrator Agent: Teaching Your AI to Understand Your Brand and Execute Briefs

In the previous article, we built a working endpoint: you send a topic, it returns a post. It works. But there's a problem — the same problem that makes 80% of AI-generated content feel… generic.

The single prompt problem.

When you type "write me a post about productivity," the AI knows nothing about your brand. It doesn't know if your audience is CEOs or interns. It doesn't know if your tone is irreverent or corporate. It doesn't know you'd never use the word "empower" or the 🚀 emoji.

The result: grammatically flawless, completely forgettable content.

The solution: an orchestrator agent with brand memory.


Why Loose Prompts Don't Scale

Imagine this real scenario. Three people on your team generate content with AI:

  • Ana types: "instagram post about our new reporting feature"
  • Carlos types: "something for stories about data, make it modern"
  • María types: "linkedin content, serious tone, about analytics"

Three people, three prompt styles, zero consistency. Your brand feed looks like it's run by three different companies. And every time you want to adjust the tone, you have to train three people.

An orchestrator agent solves this with two key concepts:

  1. Brand memory: A system prompt containing voice, audience, forbidden words, preferred structure
  2. Structured briefs: Instead of free-form prompts, you use JSON with specific fields

Anatomy of a Structured Brief

This is not a prompt:

Write me a post about productivity for Instagram
Enter fullscreen mode Exit fullscreen mode

This is a brief:

{
  "brand": "guayoyo_tech",
  "platform": "instagram_feed",
  "content_type": "educational",
  "topic": "reporting_automation",
  "hook_angle": "time_saved",
  "key_points": [
    "We reduce 12 weekly hours of manual reporting",
    "Real-time data without waiting for month-end",
    "A dashboard that updates itself"
  ],
  "cta_goal": "demo_booking",
  "visual_note": "dashboard with charts in #1A73E8 and #0b1120 colors"
}
Enter fullscreen mode Exit fullscreen mode

Every field has a purpose. The agent doesn't "interpret" — it executes. And because the brief is JSON, you can generate it from a CRM, an Airtable form, or even another AI node.


Brand Memory: The System Prompt That Defines Everything

In n8n, brand memory is stored as a Set node that injects the system prompt before every LLM call. Here's ours for Guayoyo Tech:

You are Guayoyo AI, the content assistant for Guayoyo Tech.

BRAND IDENTITY:
- Guayoyo Tech builds enterprise software and AI automations for companies in Latin America.
- We are not a Silicon Valley startup. We are serious engineers solving real problems.
- Our client is the CTO or CEO of a mid-to-large company.

VOICE AND TONE:
- Direct, no hype, no empty buzzwords.
- Professional but approachable tone. Like a knowledgeable colleague explaining without condescension.
- In English: conversational professional tone. In Spanish: use "tú" (informal, not "usted").

FORBIDDEN WORDS:
- Empower, disruptive, game-changer, synergy, revolutionary, next-gen, leveraging, holistic.
- Forbidden emojis: 🚀 (overused), 💡 (cliché), 🔥 (we're not an energy drink brand).

POST STRUCTURE:
1. Hook (1-2 lines, question or impactful fact)
2. Body (3-4 bullet points or short paragraphs)
3. Hashtags (5-7, mix of niche and trending)
4. CTA (specific, one clear action)

NEVER:
- End a post without a CTA.
- Use more than 2 emojis per post.
- Make exaggerated promises ("this will change your life").
- Mention competitors by name.
Enter fullscreen mode Exit fullscreen mode

This system prompt travels in every call to the LLM. The agent doesn't "remember" the brand — the brand is part of its base instruction.


Building the Agent in n8n: The 5-Node Flow

Let's transform the simple flow from Article 1 into a complete orchestrator agent.

Visual flow:

[Webhook] → [Set: Brand Memory] → [Code: Build Prompt] → [Ollama: Generate] → [Code: Parse Response] → [Respond]
Enter fullscreen mode Exit fullscreen mode

Node 1: Webhook

Same as before, receives the brief JSON:

curl -X POST http://localhost:5678/webhook/content-agent \
  -H "Content-Type: application/json" \
  -d '{
    "brief": {
      "platform": "instagram_feed",
      "content_type": "educational",
      "topic": "reporting_automation",
      "hook_angle": "time_saved",
      "key_points": [
        "We reduce 12 weekly hours of manual reporting",
        "Real-time data without waiting for month-end",
        "Self-updating dashboard"
      ],
      "cta_goal": "demo_booking",
      "visual_note": "dashboard with blue charts"
    }
  }'
Enter fullscreen mode Exit fullscreen mode

Node 2: Set — Brand Memory

In n8n, a Set node defines fixed values. Configure it like this:

Name Value
brandSystemPrompt (paste the full system prompt from above)
brandName Guayoyo Tech
brandColors #1A73E8, #0b1120, #22d3ee

These values are available to all downstream nodes as {{ $json.brandSystemPrompt }}.

Node 3: Code — Build Structured Prompt

This is where the magic happens. This JavaScript code node builds the final prompt by combining brand memory with the brief:

// Get inputs from previous nodes
const brief = $input.first().json.brief;
const brandSystemPrompt = $('Set').first().json.brandSystemPrompt;
const brandColors = $('Set').first().json.brandColors;

// Build structured prompt
const userPrompt = `
CONTENT BRIEF:

Platform: ${brief.platform}
Content type: ${brief.content_type}
Topic: ${brief.topic}
Hook angle: ${brief.hook_angle}

Key points to cover:
${brief.key_points.map((p, i) => `${i + 1}. ${p}`).join('\n')}

CTA goal: ${brief.cta_goal}
Visual note (for designer/AI image gen): ${brief.visual_note}

Brand colors: ${brandColors}

INSTRUCTIONS:
Generate a complete post with this exact structure:
1. HOOK (1-2 lines)
2. BODY (3-4 paragraphs or bullets)
3. HASHTAGS (5-7)
4. CTA (1 line)

The hook should hook with: ${brief.hook_angle}.
The CTA should lead to: ${brief.cta_goal}.
No forbidden words. Max 2 emojis.
Respond in JSON format with fields: hook, body, hashtags, cta.
`;

return {
  systemPrompt: brandSystemPrompt,
  userPrompt: userPrompt,
  platform: brief.platform,
  visualNote: brief.visual_note
};
Enter fullscreen mode Exit fullscreen mode

Node 4: Ollama Chat Model

Configure it to use both system and user prompts:

  • Credential: Ollama Local
  • Model: mistral:7b
  • Messages:
    • System: {{ $json.systemPrompt }}
    • User: {{ $json.userPrompt }}
  • Temperature: 0.8 (slightly more creative)
  • Response Format: JSON (if your Ollama version supports it; if not, we parse it in the next node)

Node 5: Code — Parse Response

The LLM may return inconsistently formatted JSON. This node normalizes it:

const rawResponse = $input.first().json.message?.content || $input.first().json.response;

// Try to parse JSON; fall back to regex extraction
let parsed;
try {
  parsed = JSON.parse(rawResponse);
} catch (e) {
  // Fallback: extract fields with regex
  const hookMatch = rawResponse.match(/HOOK:?\s*(.+?)(?=\n\n|\n[A-Z])/s);
  const bodyMatch = rawResponse.match(/BODY:?\s*(.+?)(?=\n\n|\n[A-Z])/s);
  const hashtagsMatch = rawResponse.match(/HASHTAGS:?\s*(.+?)(?=\n\n|\n[A-Z])/s);
  const ctaMatch = rawResponse.match(/CTA:?\s*(.+?)(?=\n\n|$)/s);

  parsed = {
    hook: hookMatch?.[1]?.trim() || '',
    body: bodyMatch?.[1]?.trim() || '',
    hashtags: hashtagsMatch?.[1]?.trim() || '',
    cta: ctaMatch?.[1]?.trim() || ''
  };
}

// Build complete post
const fullPost = `${parsed.hook}

${parsed.body}

${parsed.hashtags}

${parsed.cta}`;

return {
  hook: parsed.hook,
  body: parsed.body,
  hashtags: parsed.hashtags,
  cta: parsed.cta,
  fullPost: fullPost,
  visualNote: $input.first().json.visualNote,
  platform: $input.first().json.platform,
  timestamp: new Date().toISOString()
};
Enter fullscreen mode Exit fullscreen mode

Testing the Agent

Send the brief and receive a complete, brand-consistent post:

{
  "hook": "12 hours a week on reports that update themselves? Something doesn't add up.",
  "body": "Every week, your team spends the equivalent of a day and a half consolidating data that already exists in your systems.\n\nWith an automated dashboard:\n• Data arrives in real time, not when someone runs the query\n• Monday's report is already ready Friday at 5pm\n• Your team stops copying-pasting and starts analyzing\n\nIt's not magic. It's good engineering.",
  "hashtags": "#Automation #BusinessIntelligence #DataAnalytics #Productivity #TechLeadership #GuayoyoTech",
  "cta": "Want to see what this would look like in your company? Book a free demo at guayoyo.tech/contacto"
}
Enter fullscreen mode Exit fullscreen mode

Compare this to what you'd get from a loose prompt. The difference is brand memory. The agent knows who you are, how you talk, and what you'd never say.


Why Mistral 7B and Not GPT-4?

Mistral 7B with 4-bit quantization runs in ~6GB of VRAM and generates ~40 tokens/second on an RTX 3090. For structured copy generation, its quality is comparable to GPT-3.5-Turbo. And it's free, private, and rate-limit-free.

Need higher quality? Step up to Mixtral 8x7B (~24GB VRAM) or even Llama 3 70B with quantization. The agent architecture doesn't change — you just swap the model in the Ollama node.


What's Next

You now have an agent that receives structured briefs and produces brand-consistent copy. But a post without an image is half a post. In the next article, we'll connect ComfyUI with Stable Diffusion to generate images that don't just look good — they look yours.


Already generating content with an LLM but getting inconsistent results? At Guayoyo Tech we design content agents with brand memory for companies that need copy that actually sounds like them. Let's talk →


Article 1: From Prompt to Post | Article 3: Images That Sell →

Top comments (0)