2X Post to LinkedIn
Post a draft to LinkedIn via browser. Read local file, post, record via client.
Inputs
- •session_number: which session folder to read from
Step 1: Read Draft
bash
cat ~/.openclaw/workspace/2x-sessions/{session_number}/drafts/linkedin.md
If file doesn't exist, stop: "No LinkedIn draft found."
Step 2: Post via Browser
- •
browser open "https://www.linkedin.com/feed/" - •Wait 3 seconds
- •
browser snapshot --interactive - •Find "Start a post" button or text area → click
- •Wait 2 seconds for modal
- •
browser snapshot --interactive
LinkedIn uses a contenteditable div, NOT a regular input.
- •Find text area in modal (contenteditable div, role "textbox")
- •
browser type <ref> "{content}" - •Wait 1 second
If browser type fails (content doesn't appear), fallback:
code
browser evaluate "document.querySelector('div[contenteditable=true].ql-editor, div[role=textbox][contenteditable=true]').innerText = `{content}`; document.querySelector('div[contenteditable=true].ql-editor, div[role=textbox][contenteditable=true]').dispatchEvent(new Event('input', {bubbles: true}))"
- •
browser snapshot --interactive→ verify content visible - •Find "Post" button (blue, bottom of modal)
- •
browser click <ref> - •Wait 3 seconds
- •
browser snapshot→ verify modal closed
Extract Posted URL
LinkedIn doesn't redirect to the post. To find it:
- •
browser open "https://www.linkedin.com/feed/" - •Wait 3 seconds, snapshot
- •Find most recent post at top of feed
- •URL format:
https://www.linkedin.com/feed/update/urn:li:activity:{id}/ - •Extract activity ID as platform_post_id
If extraction fails, report success without URL — not critical.
Step 3: Record
bash
SESSION_UUID=$(cat ~/.openclaw/workspace/2x-sessions/{session_number}/.supabase_session_id)
node ~/.openclaw/workspace/skills/2x/db/client.js publish-draft \
--session "$SESSION_UUID" \
--platform linkedin \
--platform-post-id "{extracted_id_or_null}" \
--posted-url "{extracted_url_or_null}"
Local log:
bash
echo '{"platform":"linkedin","post_id":"{id}","url":"{url}","posted_at":"'$(date -u +%Y-%m-%dT%H:%M:%SZ)'","session":{session_number}}' \
>> ~/.openclaw/workspace/2x-posted.jsonl
Step 4: Return
code
✅ Posted to LinkedIn: {url}
Or: ❌ LinkedIn posting failed: {reason}
Known Gotchas
- •"Add to your post" overlay: Ignore — just find the Post button.
- •Modal states: Snapshot after each action.
- •Visibility selector: Leave as default ("Anyone"), proceed.
- •Rich text paste: LinkedIn may auto-format URLs. Fine — don't fight it.
- •NEVER retry automatically.