OpenAI Swarm Tutorial: Create Marketing Campaigns for Any Website
In this tutorial, we’ll build a multi-agent system using OpenAI Swarm for AI-powered marketing strategies using Firecrawl for web scraping.
Agents
- User Interface: Manages user interactions
- Website Scraper: Extracts clean LLM-ready content via Firecrawl API
- Analyst: Provides marketing insights
- Campaign Idea: Generates marketing campaign concepts
- Copywriter: Creates compelling marketing copy
Requirements
Setup
-
Install the required packages:
pip install -r requirements.txt
-
Set up your environment variables in a
.env
file:OPENAI_API_KEY=your_openai_api_key FIRECRAWL_API_KEY=your_firecrawl_api_key
Usage
Run the main script to start the interactive demo:
python main.py
How it works
Our multi-agent system uses AI to create marketing strategies. Here’s a breakdown:
-
User Interface Agent:
- Talks to the user
- Asks for the website URL
- Can ask follow-up questions if needed
- Passes the URL to the Website Scraper Agent
-
Website Scraper Agent:
- Uses Firecrawl to get content from the website
- Asks for the content in markdown format
- Sends the cleaned-up content to the Analyst Agent
-
Analyst Agent:
- Looks at the website content
- Uses GPT-4o-mini to find key marketing insights
- Figures out things like target audience and business goals
- Passes these insights to the Campaign Idea Agent
-
Campaign Idea Agent:
- Takes the analysis and creates a marketing campaign idea
- Uses GPT-4o-mini to come up with something creative
- Considers the target audience and goals from the analysis
- Sends the campaign idea to the Copywriter Agent
-
Copywriter Agent:
- Gets the campaign idea
- Uses GPT-4o-mini to write catchy marketing copy
- Creates copy that fits the campaign idea and target audience
The OpenAI Swarm library manages how these agents work together. It makes sure information flows smoothly between agents and each agent does its job when it’s supposed to.
The whole process starts when a user enters a URL. The system then goes through each step, from scraping the website to writing copy. At the end, the user gets a full marketing strategy with analysis, campaign ideas, and copy.
On this page
Ready to Build?
Start scraping web data for your AI apps today.
No credit card needed.
About the Author
Nicolas Camara is the Chief Technology Officer (CTO) at Firecrawl. He previously built and scaled Mendable, one of the pioneering "chat with your documents" apps, which had major Fortune 500 customers like Snapchat, Coinbase, and MongoDB. Prior to that, Nicolas built SideGuide, the first code-learning tool inside VS Code, and grew a community of 50,000 users. Nicolas studied Computer Science and has over 10 years of experience in building software.
More articles by Nicolas Camara
Using OpenAI's Realtime API and Firecrawl to Talk with Any Website
Build a real-time conversational agent that interacts with any website using OpenAI's Realtime API and Firecrawl.
Extract website data using LLMs
Learn how to use Firecrawl and Groq to extract structured data from a web page in a few lines of code.
Getting Started with Grok-2: Setup and Web Crawler Example
A detailed guide on setting up Grok-2 and building a web crawler using Firecrawl.
Launch Week I / Day 6: LLM Extract (v1)
Extract structured data from your web pages using the extract format in /scrape.
Launch Week I / Day 7: Crawl Webhooks (v1)
New /crawl webhook support. Send notifications to your apps during a crawl.
OpenAI Swarm Tutorial: Create Marketing Campaigns for Any Website
A guide to building a multi-agent system using OpenAI Swarm and Firecrawl for AI-driven marketing strategies
Build a 'Chat with website' using Groq Llama 3
Learn how to use Firecrawl, Groq Llama 3, and Langchain to build a 'Chat with your website' bot.
Scrape and Analyze Airbnb Data with Firecrawl and E2B
Learn how to scrape and analyze Airbnb data using Firecrawl and E2B in a few lines of code.