Today, we are building an Agentic workflow that writes a 20k-word book from a 3-5 word book title.
Tech stack:
Firecrawl for web scraping.
CrewAI for orchestration.
Ollama to serve Qwen 3 locally.
LightningAI for development and hosting.
Here's our workflow:
Using Firecrawl, Outline Crew scrapes data related to the book title and decides the chapter count and titles.
Multiple writer Crews work in parallel to write one chapter each.
Combine all chapters to get the book.
The code is available in this Studio: Book writer flow. You can run it without any installations by reproducing our environment below:
Let’s implement this!
Scraping tool - SERP API
Books demand research. Thus, we'll use Firecrawl’s SERP API to scrape data.
Tool usage:
Outline Crew → to research the book title and prepare an outline.
Writer Crew → to research the chapter title and write it.
Set up Qwen 3 locally
We'll serve Qwen 3 locally through Ollama.
To do this:
First, we download it locally.
Next, we define it with the CrewAI's LLM class.
Outline Crew
This Crew has two Agents:
Research Agent → Uses the Firecrawl scraping tool to scrape data related to the book's title and prepare insights.
Outline Agent → Uses the insights to output total chapters and titles as Pydantic output.
Writer Crew
This Crew has two Agents:
Research Agent → Uses the Firecrawl Scraping tool to scrape data related to a chapter's title and prepare insights.
Write Agent → Uses the insights to write a chapter.
Create a Flow
We use CrewAI Flows to orchestrate the workflow.
First, the outline method invokes the Outline Crew, which:
researches the topic using the scraping tool.
returns the total number of chapters and the corresponding titles.
Save the book
Once all Writer Crews have finished execution, we save the book as Markdown:
Kickoff the Flow
Finally, we run the Flow.
First, the Outline Crew is invoked. It utilizes the Firecrawl scraping tool to prepare the outline.
Next, many Writer Crews are invoked in parallel to write one chapter each.
This workflow runs for ~2 minutes, and we get a neatly written book about the specified topic—"Astronomy in 2025."
The video at the top shows the book our Agentic workflow wrote.
Impressive, isn't it?
The code is available in this Studio: Book writer flow. You can run it without any installations by reproducing our environment below:
Thanks for reading!
Share this post