top of page

LBSocial

OpenClaw & n8n Social Media Automation with Human Approval

Every time you publish a new YouTube tutorial, do you find yourself caught up in the tedious loop of copying links, extracting titles, writing descriptions, and manually cross-posting onto social networks? Today, we are going to fix that completely. In this comprehensive tutorial, we are building a practical, enterprise-grade n8n social media automation workflow using OpenClaw as our natural-language agent interface, n8n as our orchestration engine, Gemini to handle creative drafting, and a Telegram Admin Bot to serve as our absolute checkpoint.


Automate Social Media Publishing with Human Approval | OpenClaw + n8n

OpenClaw + n8n social publishing flowchart: Telegram message to AI agent, approval, publish to social media.
Architecture Diagram

As illustrated in the diagram above, the entire workflow forms a seamless, closed-loop pipeline. When you send a request via Telegram, OpenClaw understands your intent, selects the appropriate skill, and executes a POST Webhook to n8n. From there, n8n automatically extracts the YouTube metadata, prompts Gemini to draft a professional promotional post, and pauses for your manual approval. Only after you review the draft and click "Approve" will the post be pushed out to your social media platform, with the final publication status routed right back to you.



1. The API Authorization Ecosystem: Why LinkedIn Personal Accounts?


Before diving into the workflow assembly, it is essential to understand the modern API landscape for social platforms. Different channels impose wildly opposite boundaries regarding automated scheduling and profile integration.


You can interact with the dynamic component below to explore the distinct entry barriers and credential rules across X (Twitter), Facebook, and LinkedIn:



Based on the authorization ecosystem demonstrated above, our tutorial strategic boundaries are defined as follows:


  • X (Twitter): Although technically possible, the official X API has transitioned into a paid usage model. To keep this implementation reproducible, X is excluded from our active environment.

  • Facebook: Meta makes Facebook Page publishing relatively straightforward once approved, but strictly restricts unattended automation on personal Profile timelines.

  • LinkedIn: Creating a LinkedIn Developer App is highly accessible. It enables streamlined personal account publishing using a standard member OAuth2 authorization flow without complex application reviews, making it the perfect focal point for this tutorial.


2. Core Architecture: Human-in-the-Loop Automation


In this architecture, our guiding operational principle is simple: AI handles the repetitive background iterations, but the human retains absolute control over the final execution. No promotional copy is ever deployed blindly without explicit manual sign-off.


3. Environment Preparation & Secure Ingress (Tailscale Serve)


To allow external webhooks (such as OAuth redirect callbacks from LinkedIn or inbound triggers from your VM) to securely reach your internal n8n instance, we use Tailscale Serve to provide an encrypted HTTPS tunnel.


Assuming your Google Cloud VM already hosts the OpenClaw dashboard on port 8443, we will append port 8444 to forward traffic safely to your local n8n service (running natively on port 5678). Execute the following commands in your host terminal:


# 1. Inspect existing Tailscale ingress configurations
tailscale serve status

# 2. Verify that local n8n is alive and listening
curl -I http://127.0.0.1:5678

# 3. Expose port 8444 over HTTPS and reverse proxy it to local n8n in the background
sudo tailscale serve --bg --https=8444 http://127.0.0.1:5678

# 4. Confirm the new secure route is registered alongside your dashboard
tailscale serve status

VS Code shows .env settings for n8n and a terminal running tailscale serve, with an openclaw-demo URL on a white screen
Tailscale serves a status reflecting both 8443 and 8444 mappings active

Once the mapping is verified, update your n8n workspace environment file (.env) to map the new secure external routes.


⚠️ CRUCIAL STEP: Do not blindly copy the URL in the code block below. You must replace YOUR-MACHINE-NAME.ts.net with your actual Tailscale domain URL, which you can find in the output of the tailscale serve status command you just ran.


N8N_EDITOR_BASE_URL=https://YOUR-MACHINE-NAME.ts.net:8444 
WEBHOOK_URL=https://YOUR-MACHINE-NAME.ts.net:8444

Apply changes by restarting your containers:


docker compose restart


4. LinkedIn Developer App Setup & n8n Credentials


Before we can build the workflow, we need to establish the connection between n8n and LinkedIn. Although we are publishing to a personal profile, LinkedIn requires a Developer App to generate the necessary API credentials.


Follow these exact steps to secure your authorization:


  • Step 1: Create a LinkedIn Company Page: To create a LinkedIn app, you must first have a LinkedIn Company Page. If you do not have one, it is completely free to create.

  • Step 2: Create the Developer App: Go to the LinkedIn Developer Portal and create a new app. Give it a name, upload a logo, and associate it with your Company Page.

  • Step 3: Request Product Access: Navigate to the Products tab and request access to two specific products: Share on LinkedIn and Sign In with LinkedIn using OpenID Connect. Both of these should be approved instantly.

  • Step 4: Configure the n8n Callback URL: Head back to your n8n dashboard, go to Credentials, and search for the LinkedIn OAuth2 API. n8n will provide you with an OAuth Redirect (Callback) URL. Copy this URL, return to the Auth tab in your LinkedIn Developer Portal, paste it into the authorized redirect URLs section, and click Save.

  • Step 5: Connect Your Account: On the same LinkedIn Auth page, copy your newly generated Client ID and Client Secret. Paste these back into your n8n credential settings.


Important: Make sure to turn off the "Organization Support" toggle in n8n, because we are publishing to an individual account, not managing an organization page. Finally, click "Connect my account" and log in with your personal LinkedIn credentials. Once connected, your authorization is ready to use.


5. Building the n8n social media automation Engine


Instead of building a brand-new pipeline from scratch, we will expand on the YouTube metadata workflow we created in our previous tutorial. This section will walk you through setting up the complete, enterprise-grade n8n social media automation engine step by step.


5.1 Duplicating and Cleaning the Base Workflow


First, make a copy of your existing YouTube metadata workflow and rename it explicitly to social-publishing-human-approval. For this specific automation, we will remove any extra downstream database or export nodes used previously. I also recommend temporarily disconnecting the Webhook trigger node while we build and test our new blocks.


Your base layout should now cleanly execute these four initial steps: Edit Fields -> get video id -> request meta -> clean data -> build_document_text.


Workflow diagram with Webhook, Edit Fields, get video id, request meta, clean data, and build_document_text nodes on a dotted canvas.
The cleaned base workflow nodes

5.2 Prompting Gemini for Structured Drafts


Our next step is to call a large language model to generate our promotional copy. Add a basic LLM text node named gemini draft, choosing the Message a Model operation. We deploy the cost-effective Gemini 2.5 Flash model.


To ensure n8n can programmatically parse the response, paste the following prompt inside the node parameters to enforce a strict JSON-only return layout without markdown wrappers:


Create a concise LinkedIn promotional post for the following YouTube tutorial.

Return only valid JSON using exactly this structure:

{
  "linkedin": {
    "post_text": "..."
  }
}

Requirements:
- Use a professional but natural tone.
- Clearly explain the tutorial topic.
- Include the exact YouTube video URL.
- Keep the post concise.
- Do not use Markdown code fences.
- Do not add any text before or after the JSON.
- Use the exact video URL provided below. Do not replace it with a playlist URL.

YouTube tutorial information:
{{ $json.document_text }}

Exact video URL:
{{ $json.url }}

Screenshot of Gemini draft in n8n showing YouTube metadata input, a prompt to create a LinkedIn post, and JSON output.
The Gemini draft node

5.3 Sanitizing and Parsing the LLM Output


Directly downstream of Gemini, introduce a JavaScript Code node named "parse LinkedIn draft JSON". This handler ensures any residual formatting or whitespaces are stripped away before parsing the JSON string into native object variables:


const rawText = $json.content?.parts?.[0]?.text;

if (!rawText) {
  throw new Error('Gemini response text is missing');
}

const cleanedText = rawText
  .replace(/^```json\s*/i, '')
  .replace(/^```\s*/i, '')
  .replace(/\s*```$/i, '')
  .trim();

let parsed;

try {
  parsed = JSON.parse(cleanedText);
} catch (error) {
  throw new Error(`Unable to parse Gemini JSON response: ${error.message}`);
}

if (!parsed.linkedin?.post_text) {
  throw new Error('Missing linkedin.post_text in Gemini response');
}

return [
  {
    json: parsed,
  },
];

5.4 Configuring the Telegram Approval Node


To maintain human control over our publishing pipeline, we introduce a Telegram node. This serves as our human-in-the-loop checkpoint.


Add a Telegram node, set the Resource to Message, and change the Operation to Send and Wait for Response. Because this is your first time using Telegram inside n8n, you must configure your credentials:


  1. Bot Token: Open Telegram, go to BotFather, select your admin bot, and copy the long HTTP API token. Paste this directly into the n8n credential field.

  2. Chat ID: Enter your personal unique numeric Telegram Chat ID in the parameter section to ensure the bot knows exactly which private conversation to message.


Next, set the rest of the node parameters exactly as follows:

  • Response Type: Approval

  • Type of Approval: Approve Only

  • Approve Button Label: ✅ Approve

  • Message Text:


Please review the generated social media post.

Post draft:
{{ $json.linkedin.post_text }}

This post will be published to:
- LinkedIn personal account

Approve publishing?

n8n workflow editor and Telegram approval chat reviewing a LinkedIn post draft about YouTube data collection and automation
The Telegram approval node

5.5 Conditional Routing & The LinkedIn Publishing Node


To route the workflow based on your manual response, insert an IF node directly after the Telegram Approval node. This node evaluates whether the approval criteria have been met before triggering external APIs.  


Configure the IF node condition parameters with the following logic:


  1. Add a new conditional routing rule.  

  2. Set the primary variable to evaluate the boolean output from the previous step: {{ $json.data.approved }}.  

  3. Choose the comparison operator as is true.  


Next, drag a connection from the true branch of the IF node to a native LinkedIn node. In the LinkedIn node configuration panel, select Create a post under the operations field, then set the "Post As" parameter to Person. Once your authenticated credential is active, your personal account name will automatically populate the workspace.  


⚠️ The Context-Swap Trap: When you interact with the Telegram approval card, n8n updates the live incoming dataset to contain only the execution confirmation metadata (e.g., {"approved": true}). If you simply pass the shorthand variable {{ $json.linkedin.post_text }} into the LinkedIn text container, it will return an empty string and fail.  


To bypass this state reset, you must implement n8n's historical cross-node lookback syntax to explicitly pull the structured copy from your parsing block:  


{{ $('parse LinkedIn draft JSON').first().json.linkedin.post_text }}

LinkedIn Create a post automation screen showing post settings, JSON output, and a green Node executed successfully alert.
The LinkedIn node


5.6 Reconnecting and Publishing the Webhook


With the downstream publication logic verified, you can now finalize the automation canvas for live production deployment:


  1. Delete any temporary mock or static test inputs used during the development phase.  

  2. Reconnect your primary Webhook trigger node back to the beginning of the orchestration chain (linking directly to the Edit Fields node).  

  3. Place a Respond to Webhook node immediately following the successful LinkedIn post execution block. Set the Respond With property to All Incoming Items to return the live platform transaction URN codes back to the initial caller.  


Finally, open your primary Webhook node configuration, change the URL path from the random system-generated UUID to exactly "social-publishing-human-approval", and click the Publish button in the top-right corner of the n8n editor to activate the production routing.  


Automation workflow diagram with webhook, video metadata fetch, Gemini draft, LinkedIn post creation, and webhook response.
The whole workflow

6. OpenClaw Skill Integration


Once your backend n8n automation engine is published and listening for traffic on port 8444, you can integrate it seamlessly into your Telegram AI agent's skill repository. Access your OpenClaw management console, activate the Skill Creator utility, and submit the following comprehensive configuration prompt.  


⚠️ CRUCIAL COMPLIANCE NOTE: Do not copy the text below blindly. Before submitting, ensure you replace YOUR-MACHINE-NAME.ts.net in the endpoint and cURL payload with your actual secure Tailscale domain, as shown by your terminal's tailscale serve status command.


Use Skill Creator to update or register the skill named:
social-publishing-human-approval

Purpose:
Use this skill whenever the user asks OpenClaw to promote, distribute, or publish a YouTube video link on social media networks.

Current tutorial scope:
- Publish exclusively to the authorized LinkedIn personal account profile.
- Require a Telegram human checkpoint before executing any external publication.

Production webhook endpoint:
https://YOUR-MACHINE-NAME.ts.net:8444/webhook/social-publishing-human-approval

Execution behavior:
1. Extract the raw YouTube video URL parameter from the user's message context.
2. Dispatch a synchronous POST request to the production webhook endpoint.
3. Hold the execution thread open while the n8n workflow generates the draft copy and pauses for the Telegram manual review.
4. Wait for the user to complete the manual verification step.
5. Maintain the active connection thread until n8n transmits the final downstream HTTP response array.
6. Capture and parse the returned JSON status payload.
7. Report the definitive publication success or failure outcome clearly back to the user interface.

Use this precise cURL command architecture:

curl -sS --max-time 900 \
  -X POST \
  'https://YOUR-MACHINE-NAME.ts.net:8444/webhook/social-publishing-human-approval' \
  -H 'Content-Type: application/json' \
  -d '{
    "video_url": "YOUR_URL"
  }'

Critical execution rules:
- Dynamically substitute YOUR_URL with the clean YouTube URL isolated from the incoming request.
- Execute the cURL network process synchronously. Do not append background processing flags such as nohup or &.
- Enforce a strict network connection timeout boundary of 900 seconds (15 minutes) to guarantee adequate human review latency buffer.
- Capture stdout streams directly and evaluate the final JSON array structure.
- Never trigger automated publishing logic without verified human confirmation.

Success parsing:
Upon receiving a valid LinkedIn share URN payload response from the webhook, confirm the deployment status by outputting:
"Approved and published successfully:
- LinkedIn personal account"
Include the matching transaction URN if visible in the telemetry.


7. End-to-End Testing


With both systems fully synchronized, you can execute a comprehensive integration test to verify the operational integrity of your new pipeline:  


  1. Open your Telegram AI Bot user interface and submit a natural-language request that includes a target link: "Promote this YouTube video: https://www.youtube.com/watch?v=hN-9e5iLLHA."  

  2. OpenClaw will automatically isolate the URL parameters, match the intent to your custom social-publishing-human-approval skill, and forward the payload array over your secure Tailscale tunnel to n8n.  

  3. Within moments, your administrative bot will deliver an interactive review card displaying the structured copy generated by Gemini 2.5 Flash.  

  4. Review the copy and hashtags. Click the ✅ Approve button and follow the secure callback link to resume the execution loop.  

  5. Navigation to your personal LinkedIn profile feed will confirm that the promotional update is live, complete with your optimized text layout and native video player preview component.  


Telegram chat with bot openclaw-demo-main reviewing a post draft, Approve button, and LinkedIn publish confirmation.
The final test in Telegram


Summary


This architecture highlights the optimal operational blueprint for modern enterprise workflows: OpenClaw provides an intuitive natural-language operator interface, n8n coordinates backend logical integrations, Gemini scales creative content production, and Telegram keeps you securely in control as the human gatekeeper. By adopting this "Human-in-the-Loop" pattern, you eliminate repetitive data-entry tasks while ensuring that nothing ever posts blindly to your production environments.

Comments


bottom of page