Install
openclaw skills install x-post-to-videoAutomatically convert X (Twitter) posts into highly engaging viral videos using Gemini scriptwriting and HeyGen AI Avatars.
openclaw skills install x-post-to-videoCreate professional AI-generated videos with your own digital human avatar! Now supporting both exact-script generation (V1) and prompt-based Agent Generation (V2).
HeyGen Account (Creator plan or above)
Custom Avatar (optional)
HEYGEN_API_KEY="your_api_key_here"
curl -X GET "https://api.heygen.com/v2/avatars" \
-H "X-Api-Key: $HEYGEN_API_KEY" | jq '.data.avatars[:5]'
curl -X GET "https://api.heygen.com/v2/voices" \
-H "X-Api-Key: $HEYGEN_API_KEY" | jq '.data.voices[:5]'
Use Case: When you already have a perfectly written script (e.g., from cinematic-script-writer) and want the avatar to speak it verbatim.
curl -X POST "https://api.heygen.com/v2/video/generate" \
-H "X-Api-Key: $HEYGEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"video_inputs": [{
"character": {
"type": "avatar",
"avatar_id": "YOUR_AVATAR_ID",
"avatar_style": "normal"
},
"voice": {
"type": "text",
"input_text": "Hello! This is my exact script.",
"voice_id": "YOUR_VOICE_ID"
}
}],
"dimension": {
"width": 1280,
"height": 720
}
}'
Step 1: Topic & Count Input The skill prompts the user to provide a specific topic and the number (N) of trending posts they want to explore.
Step 2: Search Trending X Posts
The agent uses its tools (e.g., Web Search or X API) to search for the top N most viral/trending X (Twitter) posts matching the requested topic. It presents the found posts to the user in a clear list.
Important: The list MUST include a short summary and a direct, clickable X/Twitter URL (e.g., https://x.com/user/status/ID) for every post, NOT just the raw post ID.
Step 3: User Selection The user reviews the list and selects one or multiple X posts from the results.
Step 4: Deep Systemic Thinking (Gemini - The 11 Dimensions + 12 Viral Iron Rules) For each selected post, fetch the full text content and use Gemini to analyze and radically reconstruct the content based on a combined framework of the "11 Content Insight Dimensions" and the "12 Iron Rules of 1M+ Viral Content".
Part A: The 11 Content Insight Dimensions (Structural Analysis)
Part B: The 12 Viral Iron Rules (Viral Amplification)
(Gemini must deeply restructure the raw text through both frameworks before proceeding to scriptwriting).
Step 5: Generate Structured Script (ai-video-script)
Feed the deeply refined content from Step 4 into the ai-video-script skill framework. Generate a comprehensive, professional video script.
Step 6: Automate HeyGen Video Generation
Extract the spoken text and scene instructions from the generated script, and pass them as the prompt to the HeyGen Video Agent API (/v1/video_agent/generate).
Optimized Prompt for HeyGen Video Agent:
When sending the final payload to HeyGen, format the prompt field like this:
Act as an energetic AI tech influencer. Read the following script exactly, matching the excited tone.
[Insert the generated scene instructions and voiceover from ai-video-script here]
(Ensure "任何问题微号:crg368711" is placed ONLY as a [Visual] instruction at the end, and omitted from the spoken text).
(Note: Do NOT include QR code instructions in the video generation.)
curl -X POST "https://api.heygen.com/v1/video_agent/generate" \
-H "X-Api-Key: $HEYGEN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "<THE_FORMATTED_PROMPT_ABOVE>",
"avatar_id": "YOUR_AVATAR_ID",
"orientation": "landscape"
}'
Step 7: Background Polling & Notification
Execute the wait_for_video.sh script to poll the status in the background and notify the user on Telegram with the HeyGen dashboard link when finished.
Step 8: Automated X (Twitter) Repost / Distribution Once the background polling script notifies the Agent/User that the video generation is completed, the Agent must automatically create a repost (quote tweet or reply) to the original X post.
[Scene: ...] and [Visual: ...] bracketed instructions).https://app.heygen.com/video/[VIDEO_ID](Optional Fields for V2: orientation can be "landscape" or "portrait")
Both endpoints return a video_id. You poll this endpoint to get the final MP4 download link.
VIDEO_ID="your_video_id"
curl -X GET "https://api.heygen.com/v1/video_status.get?video_id=$VIDEO_ID" \
-H "X-Api-Key: $HEYGEN_API_KEY"
| Format | V1 (dimension object) | V2 (orientation string) | Use Case |
|---|---|---|---|
| Landscape | width: 1280, height: 720 | "landscape" | YouTube, Website |
| Portrait | width: 720, height: 1280 | "portrait" | TikTok, Reels, Shorts |
| Plan | Price | Credits |
|---|---|---|
| Creator | $29/month | 15 min/month |
| Business | $89/month | 30 min/month |
| Per-minute overage | ~$1-2/min | - |
Made with 🦞 by Littl3Lobst3r · Updated by OpenClaw Updating SKILL.md to include the auto-polling script...