Automating Social Media Content Writing and Publishing with Dify Workflows
💡 Developer Takeaways
Learn how to build a Dify workflow containing a scraper node, an LLM rewrite node, formatting utility, and social media webhooks.
1. Why Dify Workflows?
In enterprise automation, conversational agents (simple chatbots) are inherently unreliable. Due to the probabilistic nature of LLMs, you cannot guarantee the path of execution. To build stable automation pipelines, you must wrap models inside deterministic graph execution engines. This is the core value of Dify Workflows.
We will construct a typical social media automation workflow: scraping a target post, extracting its formatting hooks, drafting rewrites, and routing the finalized text via Webhooks to posting services.
2. Designing the Automation Graph
Within Dify, we create a new "Workflow" application and connect the following nodes sequentially:
A. Start Node
Define two variables: target_url (the URL to scrape) and style_bias (e.g., "humorous" or "analytical").
B. HTTP Request Node (The Scraper)
AI cannot read external websites without tools. We configure an HTTP GET node querying a web-reader endpoint (like Jina Reader):
- Method: GET
- URL:
https://r.jina.ai/{{sys.query.target_url}}
This returns clean Markdown-formatted web page content, saved under the variable raw_html_markdown.
C. LLM Node 1 (Style Analyzer)
Using Claude-3.5-Sonnet, we analyze the structure of the retrieved text. The prompt is structured to avoid generic AI clichés:
You are a senior editor. Analyze the following viral article:
{{raw_html_markdown}}
Extract:
1. The top 3 emotional hooks used.
2. The narrative structure.
3. Frequency of emojis and keyword styling.
Output a clean JSON payload without conversational fluff.
D. LLM Node 2 (Content Rewriter)
Using DeepSeek-R1 (leveraging reasoning capabilities for more natural phrasing), we generate three drafts:
You are a copywriter for an apparel brand. Based on the outline: {{llm_node_1_result}} and style bias: {{sys.query.style_bias}}, draft a new marketing post.
Requirements:
- Open with a hook addressing standard user frustrations (e.g., morning commute delays). Avoid opening statements like "embark on a journey."
- Split paragraphs using native emojis and attach 5 relevant hashtags at the bottom.
E. Webhook Node
An HTTP POST request routing the final output {{llm_node_2_result}} to an automation platform like Make.com to trigger Xiaohongshu/Twitter publishing.
3. Production Failure Handling: Resolving Scraper Blocks
When scraping content in production, standard HTTP nodes often trigger 403 Forbidden errors. To resolve this, we route requests through a local Puppeteer-Renderer container acting as a rendering pool, running Javascript and resolving pages before routing the data back to Dify.
// Typical execution logic
// Book a diagnostic session to access our complete Git repositories
console.log("Loading module: $Dify/Coze...");
console.log("Configuring agent pipeline: $Automating Social Media Content Writing and Publishing with Dify Workflows...");
console.log("Dependencies active. Pipeline initializing...");
// TODO: Custom code hooks for wolaizuo solutions. * This tutorial is developed by wolaizuo technical team. If you prefer a professional team to build this workflow for you, or require system integrations (ERP/CRM), feel free to schedule a free 15-minute diagnostic call with us.