This workflow contains community nodes that are only compatible with the self-hosted version of n8n.
HeyGen AI Video Generation with Social Media Publishing
Description
This workflow automates the entire process of creating AI-generated videos from trending news content and publishing them to social media platforms (Instagram and TikTok). It runs daily at 6 AM, finds viral-worthy news, generates scripts, creates AI avatar videos using HeyGen, and automatically publishes to multiple social platforms.
How it works
Content Discovery & Script Generation
- Schedule Trigger: Runs daily at 6 AM
- Perplexity Search: Finds trending news articles that would make good viral content
- Write Video Script: Uses GPT-4.1 to create a 30-second video script with hook, main content, and CTA
- Extract URL: Parses the article URL and script data for further processing
Video Creation Pipeline
- Get Screenshot: Uses ScreenshotOne API to create an animated scrolling video of the news article
- Upload to Cloudinary: Temporarily stores the background video
- Write Video Caption: Generates an engaging social media caption (150-200 characters)
- Prepare Avatar Data: Combines all data needed for HeyGen video generation
- Create Avatar Video: Sends request to HeyGen API to generate AI avatar video with:
- Talking photo avatar
- Text-to-speech voice
- Background video from the news article
- 720x1280 dimensions (vertical format)
Data Management
- Prepare Sheets Data: Formats video metadata
- Store to Google Sheets: Saves video_id, caption, timestamp, and status for tracking
Webhook Processing (Asynchronous)
- HeyGen Webhook: Receives callback when video generation is complete
- Process HeyGen Callback: Extracts video URLs and status from webhook
- Get Caption from Sheets: Retrieves the associated caption using video_id
- Combine Data: Merges video data with caption
Social Media Publishing
- Upload to Blotato: Uploads the completed video to Blotato media service
- Extract Blotato URL: Gets the media URL for social posting
- Assign Social Media IDs: Sets the account IDs for each platform
- INSTAGRAM: Posts video to Instagram with caption
- TIKTOK: Posts video to TikTok with caption and appropriate settings
Setup
Prerequisites
-
API Keys Required:
- Perplexity API (for news search)
- OpenAI API (for script and caption generation)
- ScreenshotOne API (for article screenshots)
- HeyGen API (for AI video generation)
- Cloudinary account (for temporary video storage)
- Blotato API (for social media posting)
- Google Sheets API (for data tracking)
-
HeyGen Setup:
- Create a talking photo avatar and get the
talking_photo_id
- Select a voice and get the
voice_id
- Set up a webhook endpoint in n8n for callbacks
-
Google Sheets Setup:
- Create a new Google Sheet
- Add headers:
video_id
, caption
, timestamp
, status
- Get the sheet ID from the URL
-
Social Media Setup:
- Connect Instagram and TikTok accounts to Blotato
- Get the account IDs for each platform
Configuration Steps
-
Replace all placeholder values:
YOUR_TALKING_PHOTO_ID
- HeyGen avatar ID
YOUR_VOICE_ID
- HeyGen voice ID
YOUR_WEBHOOK_URL
- Your n8n webhook URL
YOUR_GOOGLE_SHEET_ID
- Google Sheets document ID
YOUR_INSTAGRAM_ACCOUNT_ID
- Blotato Instagram account ID
YOUR_TIKTOK_ACCOUNT_ID
- Blotato TikTok account ID
YOUR_CLOUD_NAME
- Cloudinary cloud name
YOUR_UPLOAD_PRESET
- Cloudinary upload preset
-
Add credentials in n8n:
- Perplexity API credentials
- OpenAI API credentials
- HeyGen API credentials (create custom API credentials with X-Api-Key)
- Blotato API credentials
- Google Sheets OAuth2
- ScreenshotOne API credentials
-
Configure the webhook:
- Copy the webhook URL from the "HeyGen Webhook" node
- Use this URL in the "Create Avatar Video" node's callback_url
Notes
- The workflow uses a two-part asynchronous process: initial video creation and webhook-based completion
- Videos are optimized for vertical format (720x1280) for mobile social media
- The Google Sheet acts as a database to link video IDs with captions
- All sensitive content (URLs, API keys) should be replaced with your own values
- Consider content moderation and copyright when selecting news sources
- Monitor API usage and costs, especially for HeyGen video generation
Customization Options
- Content Sources: Modify the Perplexity search query to target specific news sources or topics
- Video Style: Adjust avatar position, scale, and background video settings
- Voice Settings: Change voice_id, speed, and pitch for different narration styles
- Publishing Schedule: Modify the Schedule Trigger for different times or frequencies
- Social Platforms: Add more platforms by duplicating the Blotato posting nodes