Complete Marketing Team Automation Pipeline Guide
Defines a CrewAI pipeline with four agents that research, strategise, describe visuals and write copy for Instagram posts.
What this file does
Defines a CrewAI pipeline with four agents that research, strategise, describe visuals and write copy for Instagram posts.
When to use it
- Automating weekly Instagram content from research to captions
- Replacing a manual marketing team workflow with AI agents
- Generating structured marketing assets for a social media account
- Learning how to orchestrate multiple CrewAI agents in sequence
Assumes this stack
Complete Marketing Team Automation Pipeline Guide
📋 Overview
This project is an AI-powered Instagram marketing automation pipeline built with CrewAI framework that simulates a complete marketing team with 4 specialized AI agents:
- Market Researcher - Analyzes trends, competitors, and hashtags
- Content Strategist - Creates content calendars and strategies
- Visual Creator - Generates detailed image descriptions
- Copywriter - Crafts engaging captions and copy
🏗️ Project Structure
Automating-a-Marketing-Team-with-agents/
├── src/
│ └── instagram/
│ ├── __init__.py
│ ├── crew.py # Main crew orchestration
│ ├── main.py # Entry point
│ ├── config/
│ │ ├── agents.yaml # AI agents configuration
│ │ └── tasks.yaml # Tasks configuration
│ └── tools/
│ ├── __init__.py
│ └── search.py # Search tools for research
├── .env # Environment variables
├── pyproject.toml # Poetry dependencies
├── poetry.lock # Locked dependencies
└── README.md
🚀 Step-by-Step Manual Setup and Execution
Step 1: Prerequisites
Required Software:
- Python 3.10-3.13
- Poetry (for dependency management)
- OpenAI API key
Step 2: Environment Setup
2.1 Install Poetry
pip install poetry
2.2 Navigate to Project Directory
cd C:\Users\abhis\Automating-a-Marketing-Team-with-agents
2.3 Lock and Install Dependencies
python -m poetry lock
python -m poetry install
Step 3: Configuration
3.1 Environment Variables Setup
Create/Edit .env file in project root:
OPENAI_API_KEY=your_actual_openai_api_key_here
# Optional: Add Serper API key for enhanced search
SERPER_API_KEY=your_serper_api_key_here
3.2 Agents Configuration (src/instagram/config/agents.yaml)
- Market Researcher: Analyzes Instagram trends and competitors
- Content Strategist: Develops content calendars
- Visual Creator: Creates image descriptions
- Copywriter: Writes engaging captions with SEO optimization
3.3 Tasks Configuration (src/instagram/config/tasks.yaml)
- market_research: Research trends and hashtags
- content_strategy: Create weekly content calendar
- visual_content_creation: Generate image descriptions
- copywriting: Write post captions and copy
Step 4: Pipeline Execution
4.1 Manual Execution Command
python -m poetry run instagram
4.2 Interactive Inputs Required
When you run the pipeline, you'll be prompted for:
-
Instagram Account Description:
- Example: "A fitness coaching page focused on home workouts and healthy lifestyle tips"
-
Topic of the Week:
- Example: "New Year fitness resolutions and motivation"
Step 5: Pipeline Flow
Phase 1: Market Research
- Agent: Market Researcher
- Action: Analyzes current trends, hashtags, competitor activities
- Output: Research report with trending hashtags and insights
Phase 2: Content Strategy
- Agent: Content Strategist
- Action: Creates 3-5 day content calendar based on research
- Output: Structured markdown calendar with themes and keywords
Phase 3: Visual Content Creation
- Agent: Visual Creator
- Action: Generates detailed image descriptions for each post
- Output: Detailed visual prompts for AI image generation
Phase 4: Copywriting
- Agent: Copywriter
- Action: Writes engaging captions with hashtags and CTAs
- Output: Ready-to-post Instagram captions
Step 6: Expected Outputs
The pipeline generates several files:
- Market Research Report (
market_research.md) - Content Calendar (integrated in final output)
- Visual Content Descriptions (
visual-content.md) - Instagram Copy (captions with hashtags)
🔧 Manual Customization Options
Modify Agents (agents.yaml)
market_researcher:
role: "Your custom role"
goal: "Your specific goal"
backstory: "Agent personality and expertise"
Adjust Tasks (tasks.yaml)
market_research:
description: "Custom task description with {variables}"
expected_output: "Specific output format requirements"
Add Custom Tools (tools/search.py)
- Extend search capabilities
- Add new data sources
- Integrate APIs
🎯 Manual Execution Examples
Example 1: Fitness Coach Account
python -m poetry run instagram
# Inputs:
# Page description: "Personal trainer specializing in strength training for beginners"
# Topic: "January fitness motivation and goal setting"
Example 2: Food Blog
python -m poetry run instagram
# Inputs:
# Page description: "Healthy recipe blog with quick meal ideas for busy professionals"
# Topic: "Meal prep Sunday inspiration"
📊 Pipeline Performance Metrics
- Processing Time: 5-10 minutes depending on complexity
- API Calls: ~10-15 OpenAI API calls per run
- Output Quality: Professional-grade marketing content
- Customization Level: Highly configurable through YAML files
🛠️ Troubleshooting
Common Issues:
-
Poetry not recognized:
python -m poetry [command] -
API Key errors:
- Verify
.envfile location and format - Check API key validity
- Verify
-
Dependency conflicts:
python -m poetry lock --no-update python -m poetry install
🔄 Alternative Execution Methods
Method 1: Direct Python Execution
python src/instagram/main.py
Method 2: Poetry Shell
poetry shell
python -m instagram
Method 3: Custom Script
Create run_pipeline.py:
from src.instagram.crew import InstagramCrew
import datetime
inputs = {
'current_date': datetime.datetime.now().strftime("%Y-%m-%d"),
'instagram_description': 'Your page description',
'topic_of_the_week': 'Your weekly topic',
}
InstagramCrew().crew().kickoff(inputs=inputs)
🏃♂️ Quick Start Commands
For Windows PowerShell:
# 1. Install Poetry
pip install poetry
# 2. Navigate to project
cd C:\Users\abhis\Automating-a-Marketing-Team-with-agents
# 3. Install dependencies
python -m poetry lock
python -m poetry install
# 4. Run pipeline
python -m poetry run instagram
📁 File Locations and Purposes
Configuration Files:
.env- Environment variables (API keys)pyproject.toml- Project dependencies and metadatasrc/instagram/config/agents.yaml- AI agent definitionssrc/instagram/config/tasks.yaml- Task descriptions and workflows
Core Code Files:
src/instagram/main.py- Entry point and user interactionsrc/instagram/crew.py- CrewAI orchestration logicsrc/instagram/tools/search.py- Search and research tools
Output Files (Generated):
market_research.md- Research findings and trendsvisual-content.md- Image descriptions for posts- Various markdown files with content strategies and copy
🔐 Security Notes
- Never commit your
.envfile with real API keys - Use environment variables for sensitive data
- Consider using
.env.examplefor template sharing
🚀 Advanced Usage
Batch Processing:
Create multiple input configurations and run them sequentially:
# batch_run.py
from src.instagram.crew import InstagramCrew
import datetime
campaigns = [
{
'current_date': datetime.datetime.now().strftime("%Y-%m-%d"),
'instagram_description': 'Fitness coaching page',
'topic_of_the_week': 'New Year resolutions',
},
{
'current_date': datetime.datetime.now().strftime("%Y-%m-%d"),
'instagram_description': 'Travel photography blog',
'topic_of_the_week': 'Winter destinations',
}
]
for campaign in campaigns:
print(f"Running campaign: {campaign['topic_of_the_week']}")
InstagramCrew().crew().kickoff(inputs=campaign)
📈 Monitoring and Analytics
Track Pipeline Performance:
- Monitor API usage and costs
- Log execution times and success rates
- Analyze output quality and engagement metrics
Integration Possibilities:
- Connect to Instagram Business API
- Integrate with scheduling tools (Buffer, Hootsuite)
- Add analytics dashboards
- Implement A/B testing for content variations
This comprehensive pipeline automates the entire content creation process from research to final copy, simulating a full marketing team's workflow in minutes rather than hours!
🎯 Next Steps After Pipeline Execution
- Review Generated Content: Check all output files for quality and relevance
- Customize as Needed: Edit any generated content to match your specific brand voice
- Schedule Posts: Use the content calendar to plan your posting schedule
- Generate Images: Use the visual descriptions with AI image generators (DALL-E, Midjourney, etc.)
- Track Performance: Monitor engagement metrics and adjust future inputs based on results
What's inside
14 sections, 4 agent definitions, 4 task definitions, 6 code examples, 3 execution methods
Change this for your project
- Replace
C:\Users\abhis\Automating-a-Marketing-Team-with-agentswith your own project path - Replace
your_actual_openai_api_key_herewith your own API key - Replace
your_serper_api_key_herewith your own Serper key if used - Replace
abhi-iitk26/Instagram_multiagentic_ai_projectwith your own repository URL
Where it goes
A standard operating procedure. Keep where the team or agent running the process will find it.
Worth borrowing
- Using a sequential pipeline of specialised agents where each agent's output feeds the next
- Separating agent roles, tasks and tools into YAML config files so they can be edited without touching code
- Providing both interactive CLI input and a batch script for running multiple campaigns
Related Documents
Comprehensive AI Assistant Tools Reference
Lists 80+ tools with MCP server associations, bulk support, parallel capability, resource impact, and execution type for AI agent workflows.
iOS Deployment Guide
Walks through setting up an iOS development environment, building a Tauri app for iOS, and publishing to the App Store or alternative channels.
How to Add Resources to Your FastMCP Server
Teaches how to add static and dynamic MCP resources to a FastMCP server, with six ready-to-copy examples for a GitHub crawler.
PCI Compliance Guide
Explains PCI DSS compliance via tokenization, lists forbidden and allowed data, and provides code examples for BigCommerce and Stripe.