Advanced Examples
Explore complex automation scenarios and integration patterns for sophisticated social media campaigns and workflows.
Example 1: Product Launch Campaign
Coordinate a multi-platform product launch with teaser stories, main announcement, and follow-up content at staggered times:
Product Launch Campaignjson
{
"caption": "🚀 Big announcement coming soon!",
"platforms": ["instagram", "facebook", "twitter"],
"platform_captions": {
"instagram": "Something amazing is coming... 🎉 #ProductLaunch",
"twitter": "Big news dropping tomorrow! Stay tuned 🚀",
"facebook": "We've been working on something special... Announcement tomorrow!"
},
"platform_types": {
"instagram": ["story", "feed"],
"facebook": ["story", "feed"]
},
"media_urls": ["https://s3.amazonaws.com/teaser-image.jpg"],
"scheduled_for": "2024-12-25T09:00:00Z",
"type_schedule": {
"story": "+0h",
"feed": "+3h",
"tweet": "+3h"
}
}Example 2: Cross-Platform Viral Strategy
Release content strategically across platforms to maximize engagement and cross-pollination:
Viral Content Strategytypescript
// Phase 1: Exclusive Instagram release
await publishPost({
caption: "EXCLUSIVE: First look at our new product! 🎉",
platforms: ["instagram"],
platform_types: { instagram: ["story", "reels"] },
media_urls: ["https://s3.amazonaws.com/product-video.mp4"],
publish_now: true
});
// Phase 2: Cross-post to other platforms after 2 hours
await publishPost({
caption: "Now available everywhere! Check out our new product 🚀",
platforms: ["facebook", "twitter", "youtube"],
platform_captions: {
twitter: "Our new product is here! Watch the full reveal 👇",
youtube: "Full Product Reveal - Everything You Need to Know"
},
media_urls: ["https://s3.amazonaws.com/product-video.mp4"],
scheduled_for: new Date(Date.now() + 2 * 60 * 60 * 1000).toISOString()
});Example 3: N8N Integration Workflow
Automate social media publishing based on external triggers using n8n or similar automation platforms:
N8N Workflow Examplejson
{
"nodes": [
{
"name": "RSS Feed Trigger",
"type": "n8n-nodes-base.rssFeedTrigger",
"parameters": {
"feedUrl": "https://blog.example.com/feed.xml"
}
},
{
"name": "HTTP Request to SocialHub",
"type": "n8n-nodes-base.httpRequest",
"parameters": {
"method": "POST",
"url": "https://your-domain.com/api/agents/v1/content/publish",
"authentication": "headerAuth",
"headerAuth": {
"name": "X-API-Key",
"value": "={{ $credentials.socialhubApiKey }}"
},
"body": {
"caption": "={{ $json.title }}\n\n{{ $json.contentSnippet }}\n\nRead more: {{ $json.link }}",
"platforms": ["twitter", "threads"],
"publish_now": true
}
}
}
]
}Example 4: A/B Testing Campaign
Test different captions and posting times to optimize engagement:
A/B Testing Strategytypescript
const variants = [
{
caption: "Discover our revolutionary new product! 🚀 [Variant A]",
scheduled_for: "2024-12-25T10:00:00Z"
},
{
caption: "Transform your workflow with our latest innovation! ✨ [Variant B]",
scheduled_for: "2024-12-25T14:00:00Z"
}
];
// Post each variant to different audience segments
for (const variant of variants) {
await axios.post(
'https://your-domain.com/api/agents/v1/content/publish',
{
...variant,
platforms: ["instagram"],
media_urls: ["https://s3.amazonaws.com/product-image.jpg"]
},
{
headers: {
'X-API-Key': process.env.SOCIALHUB_API_KEY,
'Content-Type': 'application/json'
}
}
);
}
// Later: Analyze engagement metrics to determine winner
// Then: Scale winning variant to other platformsExample 5: Bulk Content Scheduling
Schedule an entire week of content in a single script:
Bulk Scheduling Scriptpython
import os
import requests
from datetime import datetime, timedelta
API_KEY = os.environ.get('SOCIALHUB_API_KEY')
BASE_URL = 'https://your-domain.com/api/agents/v1'
# Weekly content calendar
content_calendar = [
{
'day': 0, # Monday
'time': '09:00',
'caption': 'Start your week right! 💪 #MotivationMonday',
'media': 'monday-motivation.jpg'
},
{
'day': 2, # Wednesday
'time': '12:00',
'caption': 'Midweek tip: Stay productive! 📝',
'media': 'wednesday-tips.jpg'
},
{
'day': 4, # Friday
'time': '17:00',
'caption': 'Weekend vibes! 🎉 #FridayFeeling',
'media': 'friday-vibes.jpg'
}
]
# Schedule all posts
base_date = datetime.now()
for post in content_calendar:
# Calculate scheduled datetime
post_date = base_date + timedelta(days=post['day'])
hour, minute = map(int, post['time'].split(':'))
scheduled_datetime = post_date.replace(
hour=hour,
minute=minute,
second=0,
microsecond=0
)
# Prepare media
media_response = requests.post(
f'{BASE_URL}/media/prepare',
json={'urls': [f'https://cdn.example.com/{post["media"]}']},
headers={'X-API-Key': API_KEY}
)
task_id = media_response.json()['task_id']
# Wait for media preparation (simplified)
# In production, implement proper polling with exponential backoff
import time
time.sleep(5)
status_response = requests.get(
f'{BASE_URL}/media/status/{task_id}',
headers={'X-API-Key': API_KEY}
)
prepared_url = status_response.json()['files'][0]['prepared_url']
# Schedule post
publish_response = requests.post(
f'{BASE_URL}/content/publish',
json={
'caption': post['caption'],
'platforms': ['instagram', 'facebook'],
'media_urls': [prepared_url],
'scheduled_for': scheduled_datetime.isoformat() + 'Z'
},
headers={
'X-API-Key': API_KEY,
'Content-Type': 'application/json'
}
)
print(f"Scheduled: {post['caption'][:30]}... for {scheduled_datetime}")Example 6: Content Repurposing Pipeline
Automatically convert blog posts into social media content:
Content Repurposingtypescript
interface BlogPost {
title: string;
excerpt: string;
url: string;
featuredImage: string;
}
async function repurposeBlogPost(post: BlogPost) {
// Create platform-specific content
const platforms = {
instagram: {
caption: `${post.title}\n\n${post.excerpt.substring(0, 100)}...\n\nLink in bio! 🔗`,
types: ['feed', 'story']
},
twitter: {
caption: `${post.title}\n\n${post.excerpt.substring(0, 150)}...\n\n${post.url}`,
types: ['tweet']
},
facebook: {
caption: `${post.title}\n\n${post.excerpt}\n\nRead more: ${post.url}`,
types: ['feed']
}
};
// Prepare featured image
const mediaResponse = await prepareMedia([post.featuredImage]);
const preparedUrl = mediaResponse.files[0].prepared_url;
// Publish to all platforms
await axios.post(
'https://your-domain.com/api/agents/v1/content/publish',
{
caption: post.title,
platforms: Object.keys(platforms),
platform_captions: {
instagram: platforms.instagram.caption,
twitter: platforms.twitter.caption,
facebook: platforms.facebook.caption
},
platform_types: {
instagram: platforms.instagram.types,
facebook: platforms.facebook.types
},
media_urls: [preparedUrl],
publish_now: true
},
{
headers: {
'X-API-Key': process.env.SOCIALHUB_API_KEY,
'Content-Type': 'application/json'
}
}
);
}Need More Help?
Check the API Reference for complete endpoint documentation, or visit Troubleshooting for common issues and solutions.