Skip to main content

Marketing Team Agent

The marketing team agent is responsible for content generation, campaign strategy, and SEO optimization. It supports data-driven marketing decisions while maintaining a consistent brand voice.

Implementing the Marketing Agentโ€‹

// src/agents/marketing.ts
import { query } from "@anthropic-ai/claude-agent-sdk";
import { AgentResponse } from "../shared/types";
import { extractText, log } from "../shared/utils";

const MARKETING_SYSTEM_PROMPT = `You are a marketing strategist specializing in B2B SaaS.
You prefer data-driven decision-making and value brand consistency.
All content should consider both SEO and conversion rates.
Always present results in an actionable format.`;

export async function runMarketingAgent(task: string): Promise<AgentResponse> {
log("MARKETING", `Starting task: ${task.slice(0, 40)}...`);

const response = await query({
prompt: `${MARKETING_SYSTEM_PROMPT}\n\n---\n\n${task}`,
options: {
maxTurns: 12,
tools: ["Read", "Write", "Glob"]
}
});

const result = extractText(response);
log("MARKETING", "Task completed");

return {
department: "marketing",
result,
confidence: "high",
actionItems: extractActionItems(result)
};
}

function extractActionItems(text: string): string[] {
const lines = text.split("\n");
return lines
.filter(l => l.match(/^[-*]\s+|^\d+\.\s+/))
.map(l => l.replace(/^[-*\d.]\s+/, "").trim())
.filter(l => l.length > 10)
.slice(0, 5);
}

Key Marketing Workflowsโ€‹

1. Generating a Content Calendarโ€‹

> Marketing Team: Please create next month's content calendar.
Product: AI development tool / Target: Mid-size enterprise dev team leads
Channels: Blog, LinkedIn, Newsletter

Agent Response Example:

## March Content Calendar

### Blog (Twice a week)
- 3/3 (Mon): "How to Improve Development Speed by 40% with AI Coding Tools"
- 3/7 (Fri): Customer Success Story: Results after 6 months of adoption at Company A
- 3/10 (Mon): "5 AI Development Trends for 2026"
...

### LinkedIn (Daily)
- Tech tips sharing (60%)
- Customer testimonials (20%)
- Company culture (20%)

### Newsletter (Bi-weekly)
- 3/15: AI Development Tools Special Edition
- 3/29: Reader Q&A + Product Updates

2. SEO Content Optimizationโ€‹

async function seoOptimize(content: string, targetKeyword: string) {
return runMarketingAgent(
`Please optimize the following content for SEO focusing on the "${targetKeyword}" keyword.

Requirements:
- Keyword density of 1.5~2.5%
- Include keyword in titles/subtitles
- Write a meta description under 160 characters
- Identify internal/external linking opportunities
- Readability score of 70 or higher

Content:
${content}`
);
}

3. Competitor Analysis Reportโ€‹

async function competitorAnalysis(competitors: string[]) {
return runMarketingAgent(
`Analyze the following competitors and write a marketing strategy report:
${competitors.join(", ")}

Analysis Items:
1. Positioning and USP of each company
2. Content strategy patterns
3. Target customer segments
4. Opportunities for our differentiation
5. 3 immediately actionable tactics`
);
}

4. Campaign Performance Analysisโ€‹

async function analyzeCampaign(
campaignData: string,
campaignName: string
) {
return runMarketingAgent(
`Analyze the performance of the ${campaignName} campaign and suggest areas for improvement.

Performance Data:
${campaignData}

Analysis Requests:
- Evaluate achievement of core KPIs
- Compare ROI across channels
- 3 points that need improvement
- A/B testing ideas for the next campaign`
);
}

Specialized Prompts for the Marketing Agentโ€‹

Optimized instructions for different marketing task types:

Task TypeCore Instructions
Blog Writing"Use AIDA structure, empathize with reader problems in the first paragraph"
Social Media Copy"Adhere to platform-specific optimal lengths, clearly include a CTA"
Email"Subject under 35 characters, utilize personalization variables"
Press Release"Inverted pyramid structure, include at least 2 quotes"
Ad Copy"Focus on 1 core benefit, use action-oriented verbs"
Marketing Agent Usage Tips
  • Save your brand guidelines document in prompts/brand-guide.md and include it in the system prompt
  • Provide well-performing past content samples as few-shot examples
  • Always request an SEO score and readability check after generating content