Social Media Post Generator
Transform blog posts and announcements into platform-optimized social content.
This workflow adapts content for Twitter, LinkedIn, Facebook, and Instagram with platform-specific best practices.
Implementation
1import { relay } from "@relayplane/workflows";23const result = await relay4 .workflow("social-post-generator")56 // Step 1: Extract key messages7 .step("extract-key-messages")8 .with("anthropic:claude-3.5-sonnet")9 .prompt(`Extract the most compelling points from this content:1011{{sourceContent}}1213Identify:14- Main headline/hook (most attention-grabbing angle)15- 3 supporting points16- Call-to-action17- Relevant hashtags (trending + niche)18- Target audience pain point addressed1920This will be adapted for social media.`)2122 // Step 2: Generate Twitter/X thread23 .step("twitter-thread")24 .with("openai:gpt-4o")25 .depends("extract-key-messages")26 .prompt(`Create a Twitter/X thread (5 tweets max):2728Key Messages: {{extract-key-messages.output}}2930Tweet 1: Hook (stop the scroll)31Tweets 2-4: Value/insights32Tweet 5: CTA + link3334Each tweet:35- Under 280 characters36- One clear idea per tweet37- Use line breaks for readability38- End with question or CTA39- Include 2-3 relevant hashtags4041Engaging, conversational tone.`)4243 // Step 3: Generate LinkedIn post44 .step("linkedin-post")45 .with("anthropic:claude-3.5-sonnet")46 .depends("extract-key-messages")47 .prompt(`Create a LinkedIn post:4849Key Messages: {{extract-key-messages.output}}5051Structure:52- Hook (first 2 lines visible in feed)53- Personal angle or story (200 words)54- Insights/lessons55- CTA5657Style:58- Professional but approachable59- Use "I/we" for authenticity60- Break into short paragraphs61- Strategic emoji use (3-4 max)62- End with thought-provoking question63641000-1300 characters.`)6566 // Step 4: Generate Instagram caption67 .step("instagram-caption")68 .with("openai:gpt-4o")69 .depends("extract-key-messages")70 .prompt(`Create Instagram caption:7172Key Messages: {{extract-key-messages.output}}7374Requirements:75- Casual, authentic voice76- Front-load value in first line77- Use emoji strategically78- Include storytelling element79- 10-15 hashtags (mix of popular and niche)80- CTA in last line81- "Link in bio" if applicable8283Target length: 150-200 words`)8485 // Step 5: Suggest visual concepts86 .step("visual-concepts")87 .with("anthropic:claude-3.5-sonnet")88 .depends("extract-key-messages")89 .prompt(`Suggest visual concepts for each platform:9091Content: {{extract-key-messages.output}}9293For each platform (Twitter, LinkedIn, Instagram):94- Image style (photo, graphic, screenshot, etc.)95- Key text overlay (if any)96- Color scheme97- Composition notes98- DALL-E prompt for generation99100Make visuals platform-appropriate.`)101102 .run({103 sourceContent: blogPost,104 });105106console.log("Twitter Thread:", result.steps["twitter-thread"].output);107console.log("LinkedIn:", result.steps["linkedin-post"].output);108console.log("Instagram:", result.steps["instagram-caption"].output);109console.log("Visuals:", result.steps["visual-concepts"].output);Automated Publishing
1import { relay } from "@relayplane/workflows";2import { TwitterApi } from 'twitter-api-v2';3import { LinkedInApi } from 'linkedin-api-client';45async function publishToSocial(blogUrl: string, content: string) {6 // Generate posts7 const result = await relay8 .workflow("social-post-generator")9 .run({ sourceContent: content });1011 // Parse outputs12 const twitterThread = result.steps["twitter-thread"].output.split("\n\n");13 const linkedInPost = result.steps["linkedin-post"].output;1415 // Publish to Twitter16 const twitter = new TwitterApi(process.env.TWITTER_TOKEN);17 let lastTweetId;18 for (const tweet of twitterThread) {19 const posted = await twitter.v2.tweet({20 text: tweet,21 reply: lastTweetId ? { in_reply_to_tweet_id: lastTweetId } : undefined,22 });23 lastTweetId = posted.data.id;24 }2526 // Publish to LinkedIn27 const linkedin = new LinkedInApi(process.env.LINKEDIN_TOKEN);28 await linkedin.posts.create({29 author: `urn:li:person:${PERSON_ID}`,30 commentary: linkedInPost,31 visibility: 'PUBLIC',32 distribution: {33 linkedInDistributionTarget: {},34 },35 });3637 console.log("Published to all platforms!");38}Content Calendar Integration
1// Generate week's worth of posts2const contentCalendar = [3 { topic: "New feature announcement", date: "2024-11-18" },4 { topic: "Customer success story", date: "2024-11-20" },5 { topic: "Industry trends analysis", date: "2024-11-22" },6];78for (const item of contentCalendar) {9 const posts = await relay10 .workflow("social-post-generator")11 .run({ sourceContent: item.topic });1213 // Schedule for future publishing14 await schedulePost({15 platform: "all",16 content: posts,17 publishAt: item.date,18 });19}Sample Output
**Twitter Thread:** 1/ Just shipped a feature that saves our users 10+ hours/week The problem? Manual data entry across 5 different tools. Here's how we automated it (and why you can too) 2/ Traditional integration tools require code for every edge case. We flipped it: AI agents handle the "fuzzy logic" parts, deterministic code handles the critical paths. Result: 90% less code to maintain. 3/ The secret? Multi-model workflows... [continues]
Best Practices
- Always review AI-generated posts before publishing
- A/B test different hooks and CTAs
- Adjust tone based on platform (LinkedIn more formal than Twitter)
- Use platform analytics to refine prompts over time