How to Use AI in Brand Journalism with Gemini to Transform Digital Information into Strategic Editorial Content?

Introduction

In a hyperconnected world, every post, comment, or interaction contributes to building a brand’s reputation. Therefore, identifying what people are talking about and turning it into stories that inform, inspire, and connect is essential for any modern communication strategy.

This article was born from a concrete question: how can Generative AI be used to discover what is being said about a company and transform that information into relevant stories? Stories that reflect real experiences and concerns, turning them into inspiring narratives that strengthen brand identity.

In this tutorial, you will learn how to use Google Gemini to:

  • ๐Ÿ” Search for information using generative AI integrated with Google Search
  • โœ๏ธ Transform findings into structured journalistic narratives
  • ๐Ÿ“Š Generate visual reports with graphics and automated storytelling

ย What is Brand Journalism?

According to an article by The New York Times Licensing Group, readers experience significant content fatigue: there are more than 1.8 billion websites and over 70 million blogs published each month.

Brand Journalism is a communication strategy where brands adopt journalistic techniques to tell relevant and engaging stories. Instead of direct advertising messages, content is created with a narrative, informative, and value-added approach, similar to traditional media.

Key Features

  • Journalistic techniques: Application of rigorous journalistic methods to create credible and well-structured content.
  • Audience interests: Focus on the real interests of the audience, not just the messages the brand wants to convey.
  • Quality and useful information: Content that educates, informs, or solves concrete problems.
  • Use of different formats: Variety of formats (reports, interviews, analyses, infographics, videos) to maintain engagement.
  • Storytelling: Narratives that connect emotionally with values, experiences, and social impact.

Benefits

The benefits we can identify based on this are:

  • Brand Positioning: Establish yourself as a thought leader in your industry.
  • Audience Loyalty: Build authentic and lasting relationships with your audience.
  • Differentiation against the Competition: Stand out from competitors through higher-quality editorial content.
  • Greater Organic Reach: Valuable content is naturally shared, amplifying reach without direct advertising investment.

What is Generative AI?

Generative AI is a branch of artificial intelligence focused on creating new and original content: text, images, audio, video, or synthetic data. Its development has been possible thanks to deep learning, especially through advanced architectures such as transformers, which process information in parallel and capture complex relationships in large data volumes.

Additional Resources on GenAI

I have written a series of articles on the fundamentals of generative AI

  1. GenAI Foundations โ€“ Chapter 1: Prompt Basics: From Theory to Practice
  2. GenAI Foundations โ€“ Chapter 2: Prompt Engineering in Action โ€“ Unlocking Better AI Responses
  3. GenAI Foundations โ€“ Chapter 3: RAG Patterns and Best Practices
  4. GenAI Foundations โ€“ Chapter 4: Model Customization & Evaluation โ€“ Can We Trust the Outputs?
  5. GenAI Foundations โ€“ Chapter 5: Project Planning with the Generative AI Canvas

Gemini

Gemini is a family of multimodal AI models developed by Google DeepMind. It integrates into multiple Google products and can process text, images, and other data types simultaneously.

Grounding with Google Search

For this use case, we will use the Grounding with Google Search functionality, which connects the model directly to Google to perform searches and obtain up-to-date information.

Main Advantages:

  • ๐Ÿ“Increased Accuracy: Reduces model hallucinations by accessing verifiable information.
  • โšก๏ธReal-Time Information: Access to current data, reducing uncertainty about the model’s knowledge.
  • ๐Ÿ“šCitations and References: Retrieves source links and provides control over consulted data sources.

Use Case

Brand Journalism is a strategic tool for companies to communicate their values from an authentic perspective. However, we often need to find topics that might interest our target audience, so it is essential to search for:

  • Mentions of the company on different sites
  • Reputation and notable aspects
  • Trends and relevant conversations

This starting point helps those who write articles or create storytelling based not only on what the company wants to show but also on the external perspective others have of it.

Practical Example: ๐Ÿ“ฑiPhone 17

Using the latest iPhone launch as an example, we will:

  1. Search for recently published articles
  2. Classify and analyze these documents
  3. Generate a report with visualizations, conclusions, and structured narratives

Next, we will see how to implement this strategy through an automated workflow that integrates AI and data analysis.

Implementation Process

The following diagram illustrates how our automated analysis system works.

1๏ธโƒฃ Search with Google Search

We use Grounding with Google Search to find relevant articles and request output in JSON format using this structure:

{ 
   "title": "full article title",
   "source_name": "media name",
   "date": "publication date",
   "url": "article link",
   "site_name": "website name",
   "summary": "2-4 line summary",
   "sentiment": "positive/negative/neutral",
   "category": "rumor/analysis/comparison/market/technical",
   "sentiment_score": "1-10 score"
 }

2๏ธโƒฃ Storytelling Generation

We use another prompt to generate different types of narratives based on the articles found:

  • Analytical Insights: Compact analytical summary with concrete data.
  • Storytelling Narrative: Engaging mini-narrative based on dataset evidence.
  • Tone Variants (A/B/C): Three versions with different focuses: objective, emotional, and strategic.

3๏ธโƒฃ Report Creation

We generate a PDF report including:

  • Charts created with Seaborn and Matplotlib
  • Visual trend analyses
  • Narrative conclusions based on generated storytelling
  • Customizing the layout using ReportLab

Tutorial

How Does Gemini Work with Google Search?

When performing a query, Gemini not only relies on its internal knowledge but also actively searches updated information on Google Search. This grounding capability allows the model to access real-time data, verify facts, and provide responses based on concrete sources, reducing hallucination risk and ensuring relevance.

Pre-requisite: Access to Gemini API

Before starting, you need to get access to the Gemini API:

  1. Create an account in Google AI Studio
  2. Create or log in with your Google account
  3. Generate your API key from the control panel

Note: You can use Gemini’s free tier to test this project.

Once you have your API key, configure it in a .env file:

API_KEY = "tu_api_key_de_gemini"
MODEL_ID = "gemini-2.5-flash"

We use Gemini 2.5 Flash because it is the most cost-efficient model optimized for frequent, low-cost tasks.

Repository Structure

For this tutorial you must clone the following repository and you can get the complete code from this tutorial.

GitHub logo

RominaElenaMendezEscobar
/
brand-journalism-gemini

Tutorial about Brand Journalism Code Using Google Gemini

Buy Me A Coffee

How to Use AI in Brand Journalism with Gemini to Transform Digital Information into Strategic Editorial Content?

Introduction

In a hyperconnected world, every post, comment, or interaction contributes to building a brand’s reputation. Therefore, identifying what people are talking about and turning it into stories that inform, inspire, and connect is essential for any modern communication strategy.

This repository was born from a concrete question: how can Generative AI be used to discover what is being said about a company and transform that information into relevant stories? Stories that reflect real experiences and concerns, turning them into inspiring narratives that strengthen brand identity.

In this tutorial, you will learn how to use Google Gemini to:

  • ๐Ÿ” Search for information using generative AI integrated with Google Search
  • โœ๏ธ Transform findings into structured journalistic narratives
  • ๐Ÿ“Š Generate visual reports with graphics and automated storytelling

#ย What is Brand Journalism
According to anโ€ฆ

project/
   โ”œโ”€โ”€ img/                    # Generated graphics
   โ”œโ”€โ”€ prompt/
   โ”‚   โ”œโ”€โ”€ prompt_search.txt       # Search Prompt
   โ”‚   โ””โ”€โ”€ prompt_storytelling.txt # Prompt for narrative
   โ”œโ”€โ”€ report/                # PDFs generated
   โ”œโ”€โ”€ brand_journalist_analyzer.py
   โ”œโ”€โ”€ report_plots.py
   โ”œโ”€โ”€ report_analysis.py
   โ””โ”€โ”€ main.py
   โ””โ”€โ”€ .env

Main Files

1๏ธโƒฃ Prompts (/prompt)

  • ๐Ÿ—’prompt_search.txt: Here we define how to perform the search in Google Search and structure the results in JSON. This prompt instructs the model to return structured information with fields such as the article’s title, source, date, URL, summary, sentiment, and category.

  • ๐Ÿ—’prompt_storytelling.txt: In this file, we define how to generate conclusions and storytelling based on the articles found. It requests different types of outputs, including objective analysis, immersive narratives, and three tone variants (objective, emotional, and emotional).

2๏ธโƒฃ Brand Journalism Analyzer

  • ๐Ÿ—’brand_journalist_analyzer.py: This class is the core of the application and handles all interaction with the Gemini API. It implements three main functionalities: news retrieval using Google Search, structured storytelling generation, and analytical insights extraction.
    The most important method is search_news(), which executes real-time searches and returns structured data in JSON format. To use integrated Google Search, simply set config={"tools": [{"google_search": {}}]} in the API call.
def search_news(self, max_retries=1, create_dataframe=True):
    """Search for news on a topic using Google Search."""
    prompt = self.search_prompt()

    response = self.client.models.generate_content(
        model=self.model_id,
        contents=prompt,
        config={"tools": [{"google_search": {}}]}
    )

    # Process and clean JSON response
    txt = response.candidates[0].content.parts[0].text
    clean_text = self._clean_json_response(txt)

    return json.loads(clean_text)

3๏ธโƒฃ Visualization Generator

  • report_plots.py: This class creates all the report visualizations using Seaborn and Matplotlib. It generates three essential chart types: a bar chart showing which media outlets publish the most on the topic, a timeline visualizing the evolution of publications over time, and a heatmap that cross-references sentiment with content categories.
    All visual aspects are customizable: color palette, titles, axis labels, and save paths. The methods first prepare the data with Pandas aggregations and then generate the visualizations, automatically saving them as PNG files.

4๏ธโƒฃ PDF Report Generator

  • report_analysis.py: This class assembles the final report in professional PDF format using ReportLab. It combines multiple elements: a customizable logo, corporate-style headers, informative tables about the analyzed dataset, pre-generated visualizations, formatted narratives with full Markdown support (including headings, lists, code, and emphasis), and conclusions and storytelling sections with different tone variations.

๐ŸŽฏProcess Orchestration

The main.py file constitutes the application’s main entry point, orchestrating the entire Brand Journalism pipeline. This script coordinates the interaction between all the developed classes, managing the flow from real-time information retrieval to the generation of the final document, ensuring that each component executes in the correct order and with the necessary dependencies.

๐Ÿmain.py

from brand_journalist_analyzer import BrandJournalistAnalyzer
from report_analysis import ReportAnalysis
from report_plots import DataVisualizer
from dotenv import load_dotenv
import os
import pandas as pd
from datetime import datetime

if __name__ == "__main__":
    # Cargar variables de entorno
    load_dotenv()
    API_KEY = os.getenv("API_KEY")
    MODEL_ID = os.getenv("MODEL_ID")

    # Generar ruta con timestamp
    timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
    output_path = f"report/news_report_{timestamp}.pdf"

    # Inicializar analizador
    analyzer = BrandJournalistAnalyzer(api_key=API_KEY)

    # Buscar o cargar noticias (usa cachรฉ si existe)
    response = analyzer._load_or_search(force_refresh=False)
    search_data = pd.DataFrame(response)

    # Generar storytelling y conclusiones
    storytelling = analyzer.get_storytelling(response)
    conclusion = analyzer.get_conclusion(response)

    # Crear visualizaciones
    visualizer = DataVisualizer(dataset=search_data)
    visualizer.plot_news_by_source()
    visualizer.plot_news_over_time()
    visualizer.plot_sentiment_category_heatmap()

    # Generar reporte PDF
    report = ReportAnalysis(
        dataset=search_data,
        filename=output_path,
        conclusion=conclusion,
        storytelling=storytelling,
    )
    report.create_report()

๐Ÿ—’ Report Generation

The system automatically generates a professional PDF report using Seaborn/Matplotlib for visuals and ReportLab for document layout. It includes:

  • Media coverage charts
  • Temporal trends
  • Heatmap crossing content categories with sentiment
  • Structured storytelling and analytical conclusions

Final Report Structure

In this use case, we generated a four-page PDF report that provides a comprehensive overview of the analysis, starting with complete details of the websites and media outlets where relevant news stories on the researched topic were found.

The document includes graphical visualizations specifically designed to analyze temporal publishing trends, allowing for the identification of patterns of interest over time, as well as categorical classifications based on the criteria identified by the AI โ€‹โ€‹model following the instructions defined in the search prompt.

The final section of the report presents analytical conclusions based on quantitative data and storytelling narratives structured in different tones, providing multiple perspectives on the same information.

๐Ÿ’ก Conclusions

AI can be a powerful tool for optimizing research and analysis processes, but I still believe that authentic company communication requires the perspective, sensitivity, and values โ€‹โ€‹that only people can provide.

This tutorial offers an automated starting point that:

  • Collects and structures scattered information
  • Identifies patterns and trends in large data volumes
  • Generates evidence-based insights

However, Brand Journalism work should remain in the hands of professionals who can:

  • Interpret data within the organizational context
  • Align narratives with real corporate values
  • Add nuances, experiences, and internal perspectives
  • Ensure the message genuinely reflects brand identity
  • Humanize content with empathy and authentic connection

AI provides the knowledge foundation, but people create the true connection with the audience. Therefore, effective storytelling emerges from combining automated analysis with human narrative craftsmanship.

๐Ÿ“š References:

Do you have any other thoughts or suggestions? Leave them in the comments.

Similar Posts