We've reached the end of the series. You have an agent that generates on-brand copy. A visual pipeline that produces consistent images. An approval circuit via WhatsApp. All running on your infrastructure.
One final link remains: when you reply "OK," the content auto-publishes to Instagram and TikTok — without opening any app, without exporting files, without manual steps.
And not just publish: measure whether it worked, so the agent learns what content performs best.
The Goal: 5× Output Without Headcount Growth
A typical company posts 2-3 times per week. With this pipeline, you can post 1-2 times daily per platform. The bottleneck shifts from creation to editorial judgment — exactly where it should be.
| Activity | Before | With Pipeline |
|---|---|---|
| Generate copy | 30-45 min/post | 0 min |
| Create/design image | 45-90 min/post | 0 min |
| Review and approve | 15 min | 30 seconds (WhatsApp) |
| Publish on 2 platforms | 10 min | 0 min |
| Total per post | ~2 hours | ~30 seconds |
Step 1: Configure Instagram Graph API
To publish programmatically on Instagram, you need a Meta App with permissions. It's the most bureaucratic step — but it's one-time.
Prerequisites:
- Instagram Business or Creator account (not personal)
- Facebook Page linked to the Instagram account
- Meta App created at developers.facebook.com
Get the token:
# 1. Create a Meta App at developers.facebook.com
# 2. Add "Instagram Graph API" product
# 3. Connect your Instagram Business account
# 4. Generate a page access token
# Verify it works:
curl "https://graph.facebook.com/v21.0/me/accounts?access_token=YOUR_USER_TOKEN"
# → Find the page_access_token for your page
curl "https://graph.facebook.com/v21.0/{page_id}?fields=instagram_business_account&access_token={page_token}"
# → Get the instagram_business_account_id
n8n HTTP Request node to publish an image:
POST https://graph.facebook.com/v21.0/{ig_business_account_id}/media
Body (form-data):
image_url: {{ $json.image_url }}
caption: {{ $json.full_copy }}
access_token: {{ $json.page_token }}
This creates a "media container." Then publish:
POST https://graph.facebook.com/v21.0/{ig_business_account_id}/media_publish
Body (form-data):
creation_id: {{ $json.media_container_id }}
access_token: {{ $json.page_token }}
Response: { "id": "18005555555555555" } — your post is live.
Rate limits:
Instagram allows ~25 posts/day per account via API. For a pipeline posting 1-2 times daily, you won't come close to the limit.
Step 2: Configure TikTok Content Posting API
TikTok's API is newer and more restrictive. You need:
- TikTok Business account
- App at developers.tiktok.com
-
video.publishandvideo.uploadpermissions
Upload + publish flow:
// Step 1: Initialize upload
POST https://open.tiktokapis.com/v2/post/publish/video/init/
Headers: Authorization: Bearer {tiktok_token}
Body: {
"post_info": {
"title": "your caption here",
"privacy_level": "PUBLIC_TO_EVERYONE",
"disable_duet": false,
"disable_comment": false,
"disable_stitch": false
},
"source_info": {
"source": "PULL_FROM_URL",
"video_url": "{{ $json.video_url }}"
}
}
// Step 2: Check status
GET https://open.tiktokapis.com/v2/post/publish/status/fetch/
Headers: Authorization: Bearer {tiktok_token}
Body: { "publish_id": "{{ $json.publish_id }}" }
Limitation: TikTok API only accepts video
For TikTok, you'll need short video clips. Options:
- ComfyUI + AnimateDiff to animate your SD images into 15-30s clips
- RunwayML API ($15/month) for quick text-to-video
- FFmpeg to convert image carousels into music-backed slideshows
Most pragmatic starting option: FFmpeg slideshow.
# Convert 3-5 SD images into a video with transitions
ffmpeg -framerate 1/3 -i slide_%d.png -c:v libx264 \
-pix_fmt yuv420p -vf "fps=30,format=yuv420p" tiktok_output.mp4
Step 3: Multi-Platform Publishing Node in n8n
A single Switch node decides where to publish based on the brief:
const platform = $input.first().json.brief.platform;
const actions = [];
if (platform === "instagram" || platform === "both") {
actions.push("publish_instagram");
}
if (platform === "tiktok" || platform === "both") {
actions.push("publish_tiktok");
}
return actions.map(a => ({ action: a, data: $input.first().json }));
One sub-flow per platform:
Switch → Publish Instagram (HTTP Request → Parse Response → Save link)
→ Publish TikTok (HTTP Request → Parse Response → Save link)
→ WhatsApp Confirmation ("✅ Published on IG + TikTok")
Step 4: Performance Tracking
For the pipeline to improve, you need metrics. A simple Google Sheet:
| Date | Post ID | Platform | Topic | Format | Likes | Comments | Shares | Impressions |
|---|
Collection node (runs 24h after publishing):
// GET Instagram insights
GET https://graph.facebook.com/v21.0/{media_id}/insights
?metric=impressions,reach,likes,comments,shares
&access_token={token}
// Save to Google Sheet
Google Sheets node → Append Row with metrics
Feedback loop to the agent:
Every Monday, a node analyzes the week and updates the agent's context:
// Read last 2 weeks from Google Sheet
// Calculate: top-engagement topics, winning formats, best CTAs
// Update brand.last_posts with real data
// → Article 2's agent uses this data to improve
Step 5: Complete Pipeline — Final View
Brief (webhook)
↓
Orchestrator Agent (copy + brand context + history) ← [weekly feedback]
↓
Stable Diffusion (on-brand image)
↓
Quality Validation (auto-retry on failure)
↓
WhatsApp Preview (copy + image)
↓
You reply OK / NO + feedback
↓ ↓
OK NO → regenerate (back to Agent)
↓
Multi-Platform Switch
↓ ↓
Instagram TikTok
↓ ↓
WhatsApp Confirmation: "✅ Published"
↓
24h later → collect metrics → Google Sheet → weekly feedback
What You Achieved in This Series
| Article | Capability |
|---|---|
| #1 | Full stack: Ollama + n8n + ComfyUI self-hosted |
| #2 | Agent with brand memory, briefs, and context |
| #3 | On-brand images with SD + LoRAs + validation |
| #4 | Human approval via WhatsApp |
| #5 | Multi-platform publishing + metrics + feedback loop |
Final result: a system that takes you from 3 posts/week to daily content across 2 platforms — without growing the team — at ~$80/month infrastructure cost.
AI is not a toy. It's a mass production tool. You just need to know how to harness it.
Ready to build your self-hosted AI content production pipeline? At Guayoyo Tech, we help you design it, implement it, and train your team — on your infrastructure, with your data, under your control.
Top comments (0)