← All posts

Blog

Building an AI-Powered Multi-Brand Social Media Distribution Workflow with n8n

December 3, 2026 · Samuel Aloysius

Automate multi-brand social media distribution with n8n, AI-generated captions, Google Drive, Supabase, Metricool and Telegram.

Building an AI-Powered Multi-Brand Social Media Distribution Workflow with n8n

Introduction

Managing social media content across multiple brands is more complicated than simply uploading videos and writing captions.

For agencies, social media managers and businesses operating multiple brands, the same operational tasks are repeated constantly:

  • Finding videos ready for publication.
  • Checking whether a video has already been published.
  • Writing platform-appropriate captions.
  • Uploading and hosting video files.
  • Distributing content to different social media accounts.
  • Tracking publication results.
  • Preventing duplicate posts.
  • Notifying the team when something succeeds or fails.

As the number of brands and publishing accounts increases, these tasks become increasingly difficult to manage manually.

I wanted to approach this problem differently.

Instead of building another automation that simply posts a video to social media, I designed a multi-brand content distribution workflow using n8n. The objective was to create a system where content could be placed in a designated Google Drive folder and subsequently processed, prepared and distributed through an automated pipeline.

The workflow combines Google Drive, Google Sheets, an AI caption-generation service, Supabase Storage, Metricool and Telegram.

This article explains the architecture, the individual components, the data flow and some of the engineering decisions involved in building the system.

Looking to build your own AI automation workflows?

The system discussed in this article is one example of how n8n can automate real business operations.

If you're an agency owner, freelancer or business looking to implement practical AI automations without building everything from scratch, explore the SeltechAI Agency Automation Pack.

It includes four ready-to-import n8n workflows:

  1. AI Lead Qualification & CRM Router
  2. AI Client Reporting Dashboard
  3. AI Outreach Personalization Engine
  4. AI Client Onboarding Automator

Each workflow comes with setup documentation and supporting templates.

Explore the pack: https://seltechai.com/shop/agency-automation-pack-4-ai-powered-n8n-workflows

Now, let's look at how the social media distribution system is built.


1. Understanding the Architecture

The system follows a relatively straightforward principle:

Google Drive serves as the content source, n8n orchestrates the workflow, AI generates the captions, Supabase temporarily hosts the media, Metricool handles social media distribution, and Google Sheets maintains the processing history.

Telegram provides notifications and operational visibility.

Technology stack

Technology Responsibility
n8n Workflow orchestration and execution
Google Drive Video storage and content source
Google Sheets Posting history and duplicate detection
OpenAI-compatible API AI caption generation
Supabase Storage Temporary video hosting
Metricool API Social media scheduling and distribution
Telegram Bot API Notifications and error alerts

Each service has a specific responsibility. Rather than forcing one platform to handle the entire process, the workflow connects specialized services into one coordinated system.

High-level architecture

The following diagram illustrates the distribution architecture.

flowchart TD
    A[Manual Trigger] --> C[Merge Triggers]
    B[Scheduled Trigger<br/>9 AM and 6 PM] --> C

    C --> D[Google Drive<br/>Find MP4 Videos]
    D --> E[Google Sheets<br/>Read Posting History]

    E --> F[Deduplication Logic]
    F --> G{New Video?}

    G -->|No| H[Telegram Notification<br/>No New Videos]

    G -->|Yes| I[Download Video]
    I --> J[Extract Video Metadata]

    J --> K[AI Caption Generation]
    K --> L[Prepare Caption and Metadata]

    L --> M[Upload Video to Supabase]
    M --> N[Normalize Media URL]

    N --> O[Metricool Distribution]
    O --> P[Aggregate Results]

    P --> Q[Google Sheets<br/>Update Posting Log]
    Q --> R[Telegram Success Notification]

    R --> S[Wait 15 Minutes]
    S --> T[Delete Temporary Video]

    U[Error Trigger] --> V[Telegram Error Alert]

The important distinction is that this is not simply a scheduled posting tool. It is a content-processing pipeline with a persistent record of previously processed files.


2. Triggering the Workflow

The workflow supports two execution methods.

Manual execution

The Manual Trigger allows an operator to initiate the process directly from the n8n dashboard.

This is useful when testing the workflow, processing newly uploaded content or running the distribution process outside the regular schedule.

Scheduled execution

The Schedule Trigger uses the following cron expression:

0 9,18 * * *

This schedules execution twice daily:

  • 9:00 AM
  • 6:00 PM

The actual execution timezone depends on the n8n instance configuration.

Both triggers connect to a Code node called Merge Triggers.

Its implementation is:

// Merge both trigger paths into one execution
return $input.all();

This gives both execution paths a shared downstream processing pipeline.

The advantage is maintainability: there is no need to duplicate the entire workflow simply because content can be processed through manual and scheduled execution.


3. Retrieving Videos from Google Drive

Google Drive acts as the content library.

The List Files in Drive Folder node searches a designated folder and retrieves MP4 files.

The underlying Google Drive query follows this structure:

mimeType='video/mp4'
and 'YOUR_FOLDER_ID' in parents

The workflow retrieves:

  • File ID
  • File name
  • Thumbnail availability

It also enables returning all matching files.

This is important because the workflow should not depend on manually selecting individual videos.

Once a video is placed in the designated folder, it becomes eligible for processing.

Why use Google Drive?

Google Drive provides a familiar interface for content management.

A social media manager can prepare content, name the video appropriately and upload it without having to interact with the automation infrastructure.

It also separates content management from workflow execution.

The people preparing videos do not need access to n8n.


4. Building a Posting Ledger with Google Sheets

One of the most important parts of the system is duplicate prevention.

Without a persistent record, a scheduled workflow could repeatedly retrieve and distribute the same video.

To prevent this, I used Google Sheets as a posting ledger.

The workflow reads the existing records before deciding which video should be processed.

Posting ledger structure

The sheet uses the following columns:

Column Purpose
file_id Original Google Drive file ID
file_name Original video filename
topic Extracted content topic
caption Generated caption
posted_at Processing timestamp
status Processing status
success_count Successful distribution count
fail_count Failed distribution count

The sheet provides a persistent history that survives individual n8n executions.

The deduplication algorithm

The Edit Fields Code node performs the actual comparison.

It retrieves the posting history and builds a JavaScript Set containing file IDs already recorded with a posted status.

const postLogRows = $input.all();

const driveFiles = $('List Files in Drive Folder').all();

const postedIds = new Set(
  postLogRows
    .map(r => r.json || {})
    .filter(j =>
      String(j.status || '').toLowerCase() === 'posted'
      && j.file_id
    )
    .map(j => String(j.file_id))
);

const unposted = driveFiles.filter(
  f => f.json && f.json.id &&
  !postedIds.has(String(f.json.id))
);

The workflow then checks whether any unposted videos remain.

If none exist, it returns:

{
  is_new: false,
  message: 'No new videos to post'
}

If new videos are available, it selects the first eligible file:

const pick = unposted[0];

return [{
  json: {
    is_new: true,
    id: pick.json.id,
    name: pick.json.name,
    file_id: pick.json.id,
    file_name: pick.json.name,
    queue_remaining: unposted.length - 1
  }
}];

This approach uses file IDs rather than relying exclusively on filenames.

That distinction matters because filenames are not guaranteed to be unique.

Why use a JavaScript Set?

A Set makes membership checks straightforward.

Instead of repeatedly searching through every historical row for every Drive file, the workflow builds a collection of previously processed IDs and uses it to filter the available files.

The resulting logic is deterministic and easier to maintain.

Routing the result

The Is New File? (Not Yet Posted) IF node checks:

{{ $json.is_new === true }}

It uses a Boolean condition.

There are two possible outcomes:

  • True: A new video exists, so the workflow continues to download it.
  • False: No new video exists, so Telegram sends a notification.

This separates content processing from empty-queue handling.


5. Downloading and Preserving the Video Binary

Once a new video has been identified, n8n downloads it directly from Google Drive using its file ID.

The download node uses:

  • Resource: File
  • Operation: Download
  • File selection: By ID
  • File ID: {{ $json.file_id }}

The downloaded video is represented as binary data.

This is an important implementation detail.

In n8n, video files are not simply ordinary JSON values. The binary data must be preserved as it moves between nodes.

A node can successfully receive metadata while accidentally losing access to the underlying video payload if the binary reference is not handled correctly.

Extracting video metadata

The next Code node is responsible for preparing the video information.

It extracts:

  • Google Drive file ID
  • Original filename
  • Topic
  • Processing timestamp

The topic is derived from the filename.

For example:

how-our-product-saves-you-time.mp4

Becomes:

how our product saves you time

The implementation also normalizes the binary metadata.

const item = $input.first();

const fileName = item.json.name || '';
const fileId = item.json.id;

const fileNameClean = fileName.replace(/\.[^/.]+$/, '');

const topic = fileNameClean.replace(/[-_]/g, ' ');

if (item.binary) {
  for (const key of Object.keys(item.binary)) {
    item.binary[key].mimeType = 'video/mp4';
    item.binary[key].fileName = fileName;
    item.binary[key].fileExtension = 'mp4';
  }
}

return [{
  json: {
    file_id: fileId,
    file_name: fileName,
    topic: topic,
    posted_at: new Date().toISOString()
  },
  binary: item.binary
}];

Why mutate the binary object?

This was an important engineering consideration.

The workflow uses n8n's separate binary storage mode.

Creating a new object through a shallow spread operation can discard properties associated with the binary data reference.

Mutating the existing binary metadata preserves the original payload reference.

This is particularly important when dealing with larger video files.

It also ensures that downstream upload nodes receive the expected video MIME type:

video/mp4

6. Generating Social Media Captions with AI

Once the video metadata is available, the workflow sends its extracted topic to an AI caption-generation endpoint.

The configured endpoint is:

https://openrouter.ai/api/v1/chat/completions

The configured model is:

gpt-4o-mini

The AI receives the video topic and a system prompt containing the caption-writing requirements.

The prompt instructs the model to:

  1. Generate a short, attention-grabbing caption.
  2. Keep the main caption under 150 characters.
  3. Open with a strong hook.
  4. End with a call to action.
  5. Include 8–12 relevant hashtags.
  6. Mix broad and niche hashtags.
  7. Include the brand hashtag.
  8. Maintain a confident and direct tone.

The system prompt can be customized for a particular brand.

For example, a fitness brand, technology company and fashion business should not necessarily communicate using the same voice.

The ability to modify the prompt means the caption-generation stage can be adapted to different brand identities.

Why extract the topic from the filename?

This is a relatively simple but useful design decision.

Instead of requiring a separate content database or manually entering a topic every time a video is uploaded, the filename becomes the initial source of context.

The AI receives:

Write a TikTok/Instagram caption for a video about:
{{ $json.topic }}

This reduces the amount of manual input required.

It is worth noting that this implementation uses filename-derived context rather than actually analyzing the video's visual or audio content.

That distinction keeps the system relatively lightweight.


7. Preparing the Caption and Restoring the Video Context

The AI response and the original video metadata are produced by different parts of the workflow.

The Prepare Post with AI Caption node extracts the generated caption and reconstructs the publishing metadata.

It creates a structured object containing:

{
  "file_id": "GOOGLE_DRIVE_FILE_ID",
  "file_name": "video-name.mp4",
  "topic": "video topic",
  "caption": "AI generated caption",
  "posted_at": "TIMESTAMP",
  "userId": "METRICOOL_USER_ID",
  "blogId_brand1": "BRAND_1_ID",
  "blogId_brand2": "BRAND_2_ID"
}

The workflow then uses a Merge node to bring the prepared metadata and original binary video data together.

The merge uses:

Mode: Combine
Combine By: Position

This is important because the caption-generation HTTP request returns a JSON response, whereas the original video-processing branch contains the binary video.

The two streams need to be brought together before the upload process.


8. Using Supabase Storage as the Media Hosting Layer

One of the interesting architectural decisions is the use of Supabase Storage between Google Drive and Metricool.

Rather than assuming that the social media publishing service can directly consume the original Google Drive file, the workflow stages the video in Supabase Storage.

The upload node uses an HTTP POST request.

Its destination follows this structure:

https://YOUR_PROJECT.supabase.co/storage/v1/object/videos/VIDEO_FILENAME.mp4

The request sends the original video as binary data.

The content type is explicitly set to:

video/mp4

This matters because video APIs often validate the media format and MIME type.

Why use an intermediary?

The intermediary storage layer provides a stable media URL that the publishing platform can retrieve.

The overall process becomes:

Google Drive
     |
     v
Download Binary
     |
     v
Supabase Storage
     |
     v
Public Media URL
     |
     v
Metricool

This separates content storage from content distribution.

It also allows the workflow to manage temporary media independently of the original Google Drive library.

Normalizing the media URL

After uploading the video, the workflow calls Metricool's media URL normalization endpoint.

The endpoint is:

https://app.metricool.com/api/actions/normalize/image/url

The uploaded Supabase public URL is passed as a parameter.

The response is then processed to extract the normalized URL.

The workflow checks several possible response properties:

const mediaUrl =
  normalizeResponse.url ||
  normalizeResponse.mediaUrl ||
  normalizeResponse.data?.url ||
  fallbackUrl;

This URL is subsequently used by the publishing stage.


9. Multi-Brand Distribution Through Metricool

Metricool provides the social media publishing integration.

The architecture is designed to support multiple brand configurations through separate brand-specific publishing requests.

Each brand can use its own Metricool blog ID while sharing the same underlying content and AI-generated caption.

Brand-specific configuration

The workflow export contains two publishing implementations.

Brand 1

The first implementation uses a JSON request to Metricool's scheduler endpoint.

It includes:

  • Caption text
  • Hosted video URL
  • Instagram Reel configuration
  • TikTok configuration
  • Publication date
  • Brand-specific blog ID

The request includes Instagram and TikTok as its providers.

It also sets automatic publishing to true.

Brand 2

The second implementation uses multipart form data.

It includes:

  • Video binary data
  • Caption
  • Metricool user ID
  • Brand-specific blog ID
  • Instagram network
  • TikTok network
  • Immediate publishing configuration

The two approaches demonstrate different ways of supplying media to a publishing API: using a hosted media URL or sending the binary file directly.

Extending the architecture

The benefit of separating brand-specific publishing configuration is that additional brands can be accommodated without redesigning the entire content discovery and AI generation process.

The shared stages remain:

flowchart TD
    A[One Video] --> B[One AI Caption]
    B --> C[Shared Media Processing]

    C --> D[Brand 1 Publishing]
    C --> E[Brand 2 Publishing]
    C --> F[Brand 3 Publishing]
    C --> G[Brand N Publishing]

Each additional publishing destination needs its own account configuration and appropriate API request.

The uploaded workflow export contains the second brand node, although its connection to the execution path needs to be verified before treating that branch as active.


10. Aggregating Publishing Results

Once publishing requests return their responses, the workflow uses a Code node called Aggregate Post Results.

Its responsibility is to collect the available publishing results and calculate:

  • Total brand submissions
  • Successful submissions
  • Failed submissions
  • Individual provider statuses
  • Returned Metricool post IDs

The workflow checks whether a response contains a post ID and whether any provider reports a failed, rejected or error status.

The resulting structure looks like this:

{
  "total_brands": 2,
  "success_count": 2,
  "fail_count": 0,
  "results": [
    {
      "success": true,
      "postId": "METRICOOL_POST_ID",
      "providers": [
        {
          "network": "instagram",
          "status": "SCHEDULED"
        },
        {
          "network": "tiktok",
          "status": "SCHEDULED"
        }
      ]
    }
  ]
}

The values above are illustrative, not an actual execution response.

This stage provides a centralized view of the distribution results instead of requiring operators to inspect individual publishing nodes.

One important distinction is that successful scheduling or API acceptance does not necessarily mean that a video has already been published or successfully delivered to every social network.

A production implementation should distinguish between submission, scheduling and confirmed publication.


11. Maintaining the Posting History

After aggregation, the workflow updates Google Sheets.

It records:

  • File ID
  • Filename
  • Topic
  • Generated caption
  • Processing timestamp
  • Status
  • Successful distribution count
  • Failed distribution count

The Google Sheets node uses an append-or-update operation.

This creates a persistent record that can be consulted during subsequent executions.

The ledger is what allows the workflow to determine whether a video should be processed again.

Without this component, the scheduled workflow would have no reliable history of previously handled files.


12. Telegram Notifications and Error Handling

An automation should not operate as a black box.

The workflow includes Telegram notifications for two operational scenarios.

No new videos

When the IF node determines that no unposted videos are available, the workflow sends a Telegram notification.

The message informs the operator that the Drive folder was checked and no eligible videos were found.

This is useful because a scheduled execution can finish without processing any content, and the operator can still understand what happened.

Successful distribution

After the posting ledger is updated, Telegram sends a success notification containing:

  • Video filename
  • Number of brand submissions
  • Successful submission count
  • Failed submission count
  • Processing timestamp

This provides a quick overview without requiring access to the n8n dashboard.

Error notifications

The workflow also contains an Error Trigger connected to a Telegram error notification node.

When an execution error is captured, the notification includes the error message and timestamp.

The intended operational structure is:

flowchart TD
    A[Workflow Execution] --> B{Execution Outcome}

    B -->|No new video| C[Telegram: No New Files]

    B -->|Publishing completed| D[Telegram: Success Summary]

    B -->|Execution error| E[Error Trigger]

    E --> F[Telegram: Error Alert]

    D --> G[Wait for Media Fetch]
    G --> H[Delete Temporary Media]

This gives the operator visibility into the workflow's execution rather than requiring constant manual monitoring.


13. Temporary Media Cleanup

The workflow does not intend to keep every processed video in Supabase Storage indefinitely.

After the success notification, it waits for 15 minutes before deleting the uploaded media object.

The sequence is:

  1. Upload the video to Supabase.
  2. Make the media accessible to Metricool.
  3. Submit the publishing request.
  4. Record the results.
  5. Notify the operator.
  6. Wait 15 minutes.
  7. Delete the temporary video from Supabase.

The reason for the delay is to give Metricool time to retrieve the hosted media.

This helps avoid retaining unnecessary copies of video files in temporary storage.

The original video remains in Google Drive.

This distinction is important: the cleanup operation targets the temporary Supabase copy, not the source video.


14. Important Engineering Considerations

Building the workflow exposed several considerations that are worth understanding when developing production automation systems.

A. Persistent state matters

An automation that processes content without remembering previous executions can easily repeat work.

Using a persistent posting ledger makes the workflow state-aware.

B. File IDs are more reliable than filenames

Filenames are useful for human identification, but they should not be the only identifier used for duplicate detection.

Google Drive file IDs provide a better basis for identifying individual source files.

C. Binary data needs special handling

Video processing is different from ordinary JSON processing.

The binary payload must survive the movement between download, metadata extraction, merge and upload operations.

D. External services have different responsibilities

The workflow does not attempt to make Google Drive, AI caption generation, storage and social media publishing perform the same function.

Each service has a defined role.

This separation makes the overall architecture easier to understand and extend.

E. API success is not always publication success

A successful HTTP response from a scheduling service is not necessarily proof that a social media platform has published the video.

Production systems should distinguish between accepted requests, scheduled posts, failed provider submissions and confirmed publication.

F. Idempotency needs deliberate design

The posting ledger reduces duplicate processing, but a robust production implementation should also consider what happens when an execution fails halfway through.

For example, a video could be accepted by Metricool but the subsequent Google Sheets update could fail.

A retry could then submit the same content again.

A stronger implementation would use explicit processing states, stable idempotency keys where supported, and reconciliation against the publishing service.


15. Opportunities for Further Development

The architecture can be extended beyond the current implementation.

Some potential improvements include:

1. Dynamic brand management

Instead of manually duplicating publishing nodes, brand configurations could be stored in a database and loaded dynamically.

2. Platform-specific captions

The current caption-generation stage creates shared caption content. Future versions could generate different captions for TikTok and Instagram based on their respective audiences and content requirements.

3. AI-powered video understanding

The current implementation extracts context from the filename. A future version could analyze video frames, audio and transcripts to generate more contextually accurate captions.

4. Publication verification

A separate verification stage could periodically check Metricool or supported platform APIs to determine whether scheduled content was actually published.

5. Retry and recovery mechanisms

Failed submissions could be retried with controlled backoff, while preserving the original processing state.

6. Multi-tenant architecture

The workflow could be extended to support different organizations, each with its own Drive folder, brand configuration, publishing credentials and posting ledger.

7. Analytics and reporting

Publishing results could be connected to an analytics dashboard that tracks publishing volume, platform performance, failed submissions and brand-level activity.


Conclusion

This project demonstrates how several specialized services can be connected to create a coordinated content distribution system.

What begins as a video uploaded to Google Drive can pass through a sequence of automated operations:

  • Content discovery
  • Duplicate detection
  • Video downloading
  • Metadata extraction
  • AI caption generation
  • Media hosting
  • Social media distribution
  • Result aggregation
  • Posting history updates
  • Telegram notifications
  • Temporary media cleanup

The interesting part is not any individual integration. It is how the components work together to reduce repetitive operational work.

n8n provides the orchestration layer, while the other services handle their respective responsibilities.

The same architectural principles can be applied to other automation scenarios, including agency content operations, creator workflows, multi-brand marketing systems and scheduled media distribution.

Ultimately, the goal is to move beyond automating individual tasks and start building systems that manage complete operational processes.

One content library. One coordinated pipeline. Multiple brand destinations.

Want ready-made AI automation workflows?

Building automation systems requires connecting APIs, managing data, handling execution failures and making sure every component works together.

If you'd rather start with workflows that are already built, the SeltechAI Agency Automation Pack gives you four practical n8n automations designed for agency operations:

  • AI Lead Qualification & CRM Router
  • AI Client Reporting Dashboard
  • AI Outreach Personalization Engine
  • AI Client Onboarding Automator

Each comes with its workflow file and setup resources.

Explore the SeltechAI Agency Automation Pack

Build less from scratch. Spend more time putting automation to work.

More from the blog