How to Automate Content Ideation with Trend Analysis
Use AI to identify trending topics and generate content ideas automatically.
Jay Banlasan
The AI Systems Guy
The hardest part of running a content operation is not writing. It is knowing what to write about next. This ai content ideation trend analysis system pulls trending data from multiple sources, matches it against your audience and niche, and outputs a prioritized list of content ideas with angles already mapped. I run this weekly and feed the output directly into my content calendar.
The value compounds over time. You build a database of ideas, track which ones you acted on, and spot patterns in what your audience cares about before your competitors notice the same signals.
What You Need Before Starting
- Python 3.10 or higher
- Anthropic API key
- SerpAPI key (for Google Trends and SERP data)
- RSS library for industry feeds
pip install anthropic requests feedparser python-dotenv
Step 1: Define Your Niche and Audience Profile
This tells the system what is relevant versus noise:
# niche_config.py
NICHE_CONFIG = {
"topic": "AI tools for marketing teams",
"audience": "Marketing managers and content directors at mid-size B2B companies",
"competitors": [
"hubspot.com",
"contentmarketinginstitute.com",
"marketingprofs.com"
],
"core_themes": [
"AI automation",
"content strategy",
"marketing efficiency",
"SEO",
"lead generation"
],
"content_types": ["how-to guides", "case studies", "tool comparisons", "trend analysis"],
"excluded_topics": ["politics", "celebrity news", "sports"]
}
Step 2: Pull Trending Searches from Google
import os
import requests
from dotenv import load_dotenv
load_dotenv()
SERPAPI_KEY = os.getenv("SERPAPI_KEY")
def get_trending_searches(niche_term: str) -> list:
url = "https://serpapi.com/search"
params = {
"engine": "google_trends",
"q": niche_term,
"api_key": SERPAPI_KEY,
"data_type": "RELATED_QUERIES"
}
response = requests.get(url, params=params)
data = response.json()
trending = []
related = data.get("related_queries", {})
for item in related.get("rising", []):
trending.append({
"query": item["query"],
"value": item["value"],
"type": "rising"
})
for item in related.get("top", [])[:10]:
trending.append({
"query": item["query"],
"value": item["value"],
"type": "top"
})
return trending
Step 3: Pull Industry RSS Feeds
This gives you fresh topics from the sources your audience already reads:
import feedparser
RSS_FEEDS = [
"https://feeds.feedburner.com/MarketingProfs",
"https://contentmarketinginstitute.com/feed/",
"https://blog.hubspot.com/marketing/rss.xml"
]
def pull_rss_topics(feeds: list, max_per_feed: int = 10) -> list:
topics = []
for feed_url in feeds:
try:
feed = feedparser.parse(feed_url)
for entry in feed.entries[:max_per_feed]:
topics.append({
"title": entry.get("title", ""),
"summary": entry.get("summary", "")[:200],
"source": feed.feed.get("title", feed_url),
"published": entry.get("published", "")
})
except Exception as e:
print(f"Feed error {feed_url}: {e}")
return topics
Step 4: Generate Ideas with Claude
Now you combine the trend data and feed topics and ask Claude to generate content ideas your specific audience would value:
import anthropic
import json
from niche_config import NICHE_CONFIG
ai_client = anthropic.Anthropic(api_key=os.getenv("ANTHROPIC_API_KEY"))
def generate_content_ideas(trending: list, rss_topics: list) -> list:
trending_str = json.dumps(trending[:15], indent=2)
rss_str = json.dumps(rss_topics[:20], indent=2)
config = NICHE_CONFIG
prompt = f"""You are a content strategist. Generate 10 content ideas based on trending data.
NICHE: {config['topic']}
TARGET AUDIENCE: {config['audience']}
CORE THEMES: {', '.join(config['core_themes'])}
CONTENT TYPES: {', '.join(config['content_types'])}
TRENDING SEARCHES:
{trending_str}
RECENT INDUSTRY CONTENT:
{rss_str}
Generate 10 content ideas. For each idea, provide:
1. title: A strong, specific headline
2. angle: The unique perspective or approach (not the obvious take)
3. why_now: Why this topic is timely right now (1 sentence)
4. audience_pain: The specific problem this addresses
5. content_type: Which format fits best (how-to / case study / comparison / analysis)
6. priority: "high", "medium", or "low" based on trend strength and relevance
7. keyword_opportunity: A keyword phrase this could rank for
Return as a JSON array."""
message = ai_client.messages.create(
model="claude-opus-4-5",
max_tokens=3000,
messages=[{"role": "user", "content": prompt}]
)
raw = message.content[0].text.strip()
if raw.startswith("```"):
raw = raw.split("```")[1]
if raw.startswith("json"):
raw = raw[4:]
return json.loads(raw)
Step 5: Save to Your Content Calendar
import csv
from datetime import datetime
def save_to_calendar(ideas: list, output_path: str = "content_ideas.csv"):
today = datetime.now().strftime("%Y-%m-%d")
with open(output_path, "a", newline="", encoding="utf-8") as f:
writer = csv.DictWriter(f, fieldnames=[
"date_generated", "title", "angle", "why_now",
"audience_pain", "content_type", "priority", "keyword_opportunity", "status"
])
if f.tell() == 0:
writer.writeheader()
for idea in ideas:
writer.writerow({
"date_generated": today,
"status": "idea",
**{k: idea.get(k, "") for k in [
"title", "angle", "why_now", "audience_pain",
"content_type", "priority", "keyword_opportunity"
]}
})
print(f"Saved {len(ideas)} ideas to {output_path}")
if __name__ == "__main__":
from niche_config import NICHE_CONFIG
print("Pulling trending searches...")
trending = get_trending_searches(NICHE_CONFIG["topic"])
print("Pulling RSS feeds...")
rss_topics = pull_rss_topics(RSS_FEEDS)
print("Generating content ideas...")
ideas = generate_content_ideas(trending, rss_topics)
save_to_calendar(ideas)
# Print high-priority ideas
high_priority = [i for i in ideas if i.get("priority") == "high"]
print(f"\n{len(high_priority)} high-priority ideas this week:")
for idea in high_priority:
print(f" - {idea['title']}")
What to Build Next
- Set this up as a weekly cron job that emails the top 5 ideas to your team every Monday morning
- Add a competitor content tracker that monitors when competitors publish on your target keywords
- Build a content idea voting system where team members rank ideas so the best ones surface automatically
Related Reading
- How to Build an AI Blog Post Generator - Take your best ideas and turn them into full articles
- How to Create Automated Content Performance Reports - Track which idea categories perform best over time
- How to Create an AI-Powered FAQ Generator - Use trend data to generate FAQ content that matches search intent
Want this system built for your business?
Get a free assessment. We will map every system your business needs and show you the ROI.
Get Your Free Assessment