Automating Content: From YouTube to Blog Posts with CrewAI

Anil Verma
AI

Automating Content: From YouTube to Blog Posts with CrewAI

In the modern digital landscape, content repurposing is king. But manually summarizing a 20-minute video into a readable blog post is tedious. Enter CrewAI—a framework for orchestrating role-playing, autonomous AI agents.

Today, we'll build a "Crew" that takes a YouTube URL and delivers a polished, SEO-friendly blog post using native CrewAI tools.


Why CrewAI?

Unlike simple sequential LLM calls, CrewAI allows you to define specialized agents that work together. By using native crewai_tools, we can integrate external data sources like YouTube effortlessly.

Key Benefits:

  • Autonomous Agents: Each agent has a specific role, goal, and backstory.
  • Native Tooling: Use YoutubeVideoSearchTool for seamless integration.
  • Process Orchestration: Manage complex workflows with sequential or hierarchical processes.

The Workflow

The system is designed with two core agents working in sequence:

graph LR
    A[YouTube URL] --> B((Researcher Agent))
    B -- "Extracts Insights" --> C[Video Analysis]
    C --> D((Writer Agent))
    D -- "Drafts Post" --> E[Final Blog Post]
    
    subgraph "CrewAI Orchestration"
    B
    D
    end

The Tech Stack

  • CrewAI: The main framework for agent orchestration.
  • crewai_tools: Native tools for YouTube interaction.
  • Python: Our language of choice.

implementation: The Code

Here is the clean, CrewAI-native implementation. No LangChain wrappers needed—just pure agentic power.

import os
from crewai import Agent, Task, Crew, Process
from crewai_tools import YoutubeVideoSearchTool
from langchain_openai import ChatOpenAI

# 1. Initialize LLM and Native Tools
# Even with native CrewAI tools, we need an LLM for 'brain' power
llm = ChatOpenAI(model="gpt-4o", temperature=0.7)

# This tool allows the agent to search and extract content from YouTube videos
yt_tool = YoutubeVideoSearchTool()

# 2. Define Agents
researcher = Agent(
  role='Senior Content Researcher',
  goal='Extract key insights and detailed information from the YouTube video: {video_url}',
  backstory="""You are an expert at distilling complex video content into 
  actionable points and technical summaries. Your expertise lies in identifying 
  the 'gold' within long-form video content.""",
  tools=[yt_tool],
  llm=llm,
  allow_delegation=True, # Enabled to allow delegation to the writer
  verbose=True
)

writer = Agent(
  role='Tech Content Strategist',
  goal='Write a compelling, SEO-optimized blog post based on researcher insights',
  backstory="""You are a master storyteller who can make technical topics 
  engaging for a broad audience. You know how to structure content for 
  readability and search engine optimization.""",
  llm=llm,
  allow_delegation=False,
  verbose=True
)

# 3. Define Tasks
research_task = Task(
  description="""Analyze the video at {video_url}. 
  Extract the core message, key technical points, and top 5 actionable takeaways.""",
  expected_output="A comprehensive summary including key insights and technical details.",
  agent=researcher
)

writing_task = Task(
  description="""Using the research summary, craft a 1000-word blog post. 
  Ensure it has a catchy title, introduction, subheadings, and a strong conclusion.
  Format the output in Markdown.""",
  expected_output="A full, high-quality blog post in markdown format.",
  agent=writer
)

# 4. Form the Crew
crew = Crew(
  agents=[researcher, writer],
  tasks=[research_task, writing_task],
  process=Process.sequential, # Sequential: Research must finish before Writing starts
  verbose=True
)

# 5. Execute
result = crew.kickoff(inputs={'video_url': 'https://www.youtube.com/watch?v=EXAMPLE'})
print(result)

Conclusion

By moving away from general-purpose chains and embracing specialized agents with native tools, we get a much more robust and manageable system. CrewAI's abstraction layer makes it easy to scale this into more complex workflows, such as adding an Editor agent or a Social Media strategist.

Happy coding! 🚀