An autonomous multi-agent system engineered to plan, execute, and inspect digital marketing campaigns without constant human intervention.
This project implements a self-correcting cognitive architecture using LangGraph, where specialized agents collaborate to achieve high-level business goals. It moves beyond simple "chains" to a stateful, cyclic workflow capable of error recovery and iterative optimization.
The core logic is decoupled into three distinct agentic roles, ensuring separation of concerns and modular scalability:
- Responsibility: Deconstructs broad user goals (e.g., "Launch Q3 efficiency campaign") into tactical steps.
- Logic: Utilizes LLMs to generate valid JSON-based campaign structures, selecting appropriate platforms and budget allocations based on historical performance data.
- Responsibility: The side-effect handler. Interacts with external APIs (Twitter/X, LinkedIn) and databases.
- Logic: Executes the Planner's step. If an API call fails, it can self-correct or request an updated plan, preventing total system failure from transient errors.
- Responsibility: Closes the feedback loop.
- Logic: Analyzes output against the initial goal. It writes "Lessons Learned" into a Vector Memory store, allowing the system to improve its planning logic over time (e.g., learning that "Threads do better on Tuesdays").
- Orchestration: LangGraph - for building stateful, cyclic agent workflows.
- Memory: Vector Database integration for semantic retrieval of past campaign performance.
- API: FastAPI - providing a robust, async interface for the frontend or external triggers.
- Database: PostgreSQL & SQLModel - for persistent meaningful state (campaigns, ads, users).
- Runtime: Python 3.11+
-
Environment Setup
python3 -m venv venv source venv/bin/activate pip install -r requirements.txt # (Ensure you generate this from pyproject.toml)
-
Configuration Copy
.env.exampleto.envand configure your API keys (Anthropic, OpenAI, Twitter/X, etc.). -
Run the System
uvicorn src.marketing_agent.api:app --reload
-
Trigger a Campaign
curl -X POST http://localhost:8000/campaign/create \ -H "Content-Type: application/json" \ -d '{"goal": "Promote the new open-source vector DB features", "platforms": ["twitter", "linkedin"]}'
The specific agent logic can be found in src/marketing_agent/nodes.
planner.py: Strategy generation prompting.executor.py: Tool definitions and API wrappers.evaluator.py: Analysis logic and memory commits.
Build with ❤️ by Kaftrandev