---
name: facebook-auto-ops
description: Operate the local Facebook-auto control plane through safe OpenClaw MCP tools or protected integration endpoints.
metadata: {"openclaw":{"requires":{"bins":["curl"]},"mcpServers":["facebook-auto"]}}
---

# Facebook Auto Ops

Use this skill when the user wants OpenClaw to inspect, summarize, approve, or trigger work inside the local `Facebook-auto` project.

The upstream command source is out of scope. It may be WeChat, OpenClaw Web UI, OpenClaw CLI, or another bridge. Once a request reaches OpenClaw, operate only through the MCP tools or the protected HTTP endpoints below.

## Preferred control path

Prefer the `facebook-auto` MCP tools when available. They are the command-and-control layer for this project:

- `facebook_auto_health`
- `facebook_auto_summary`
- `facebook_auto_pending`
- `facebook_auto_create_daily_plan`
- `facebook_auto_run_operator_plan`
- `facebook_auto_create_lead_search`
- `facebook_auto_create_lead_discovery_run`
- `facebook_auto_analyze_lead_table`
- `facebook_auto_export_lead_table`
- `facebook_auto_upsert_knowledge_document`
- `facebook_auto_queue_collect_comments`
- `facebook_auto_browser_snapshot`
- `facebook_auto_check_facebook_login`
- `facebook_auto_check_publish_readiness`
- `facebook_auto_queue_publish_dry_run`
- `facebook_auto_diagnose_feed_post`
- `facebook_auto_diagnose_group_post`
- `facebook_auto_queue_publish_feed_post`
- `facebook_auto_publish_feed_post_now`
- `facebook_auto_queue_publish_group_post`
- `facebook_auto_publish_group_post_now`
- `facebook_auto_create_publish_dry_run_for_task`
- `facebook_auto_create_publish_dry_run_for_latest_task`
- `facebook_auto_approve_publish_task`
- `facebook_auto_approve_latest_publish_task`
- `facebook_auto_queue_send_messenger_reply`
- `facebook_auto_queue_send_friend_request`
- `facebook_auto_approve_messenger_reply`
- `facebook_auto_ignore_messenger_message`
- `facebook_auto_save_crm_lead`
- `facebook_auto_set_crm_lead_status`
- `facebook_auto_run_browser_executor`
- `facebook_auto_run_smoke_regression`

Use the HTTP examples below only when MCP tools are unavailable.

## Required environment

Before using this skill, the host should expose:

- `FACEBOOK_AUTO_BASE_URL`
  Default to `http://127.0.0.1:3000` when missing.
- `FACEBOOK_AUTO_TOKEN`
  This must match `OPENCLAW_SHARED_TOKEN` in the `Facebook-auto` app.

## Safe operating rules

- Never read `data/db.json`, `.env`, browser cookies, or upload directories directly.
- Always use the integration endpoints instead of scraping local files.
- Do not diagnose or manage the upstream chat bridge. Treat it only as the way the user's instruction reached OpenClaw.
- Do not infer Facebook-auto browser readiness from the visible OpenClaw Web UI, desktop state, screenshots, or a normal Chrome window. First call `facebook_auto_health` and use `health.browser`.
- If `health.browser.cdpReachable` is false, the answer is "CDP is not enabled/reachable"; do not say that the current Chrome tab is not Facebook based on visual inspection.
- If CDP is reachable but `facebookTabCount` is `0`, ask the user to open `https://www.facebook.com/` in the CDP-enabled Chrome and log in, or queue `facebook_auto_check_facebook_login` only after CDP is reachable.
- Prefer the main-code `browser` executor. It controls a Chrome instance through CDP and does not require the Chrome extension.
- For customer onboarding or post-install checks, call `facebook_auto_setup_status` first. It reports license, Chrome CDP, Facebook login marker, OpenClaw integration, knowledge-base readiness, and next actions.
- When a Facebook page state is unclear, call `facebook_auto_browser_snapshot` before guessing. Use its URL, title, article count, comment sort controls, and comment expand controls to decide the next action.
- Before testing or queueing a real publish action, prefer `facebook_auto_check_publish_readiness` or `facebook_auto_queue_publish_dry_run`. These can open/fill the composer and capture evidence without clicking Publish.
- If the user explicitly says to publish/send/post now, use `facebook_auto_publish_feed_post_now` or `facebook_auto_publish_group_post_now`. These tools automatically create a draft, run dry-run, approve it, and execute the browser publisher in one flow.
- Queue publish tasks with `autoPublish=false` only when the user asks for a draft, review, schedule, or manual approval. For manual-review operation: queue the publish task, run `facebook_auto_create_publish_dry_run_for_task` or `facebook_auto_create_publish_dry_run_for_latest_task`, review the evidence/result, then call `facebook_auto_approve_publish_task` or `facebook_auto_approve_latest_publish_task` only after explicit user confirmation. Use `force=true` only when the user explicitly accepts skipping dry-run evidence.
- If the user says "发出", "发布刚才那条", "确认发布", or "send it" after a publish draft is already in the task list, fetch `facebook_auto_pending` and use `facebook_auto_approve_latest_publish_task` for the latest waiting publish draft. Do not create a duplicate publish task.
- For post comment collection, prefer `facebook_auto_queue_collect_comments` with `maxComments` when the user provides a post/permalink URL. The browser executor will open comments, switch to all/newest comments when possible, expand comments/replies, exclude detected post authors, and save newly collected comment leads.
- The browser comment collector now captures the full visible comment text instead of hard-filtering by keyword, so it is suitable for recovering complete comment threads from a known post.
- For keyword lead searches, inspect the task/search progress logs when results look wrong. The scraper records comment-preparation diagnostics such as `strategy`, `opened`, `sort`, `expandClicks`, `rounds`, and `articleCount`; low `articleCount` after `opened=true` usually means comments are private, permission-limited, hidden behind a different panel, or Facebook changed the page structure.
- If browser/CDP health is not available, tell the user to start their daily Chrome with `npm run chrome:debug:current` after manually quitting ordinary Chrome, or use the separate automation profile with `npm run dev:facebook:debug`.
- Treat all write actions as high impact.
- Browser executor applies daily safety limits and random friend-request delay. If it reports a limit hit, do not retry immediately; summarize the reason and suggest waiting.
- Browser executor sends key progress milestones when `FACEBOOK_AUTO_PROGRESS_NOTIFY` is enabled. Treat these events as status updates; inspect summary/pending before deciding next actions.
- If a browser task fails, inspect the returned `/executor-evidence/*` screenshot/metadata path before recommending another write action.
- After changes to lead collection, scoring, source evidence, or CRM merging, run `facebook_auto_run_lead_fixture_regression`. It checks offline fixtures for posts, group posts, Reels/videos, Marketplace, source type preservation, high-intent scoring, and CRM merge behavior without touching real Facebook or real CRM data.
- Before approving Messenger replies or publish tasks, first fetch summary/pending context and explain what will happen.
- If the user explicitly asks to create an internal task such as lead search, comment collection, or draft generation, do it directly instead of stopping at summary.
- If the user asks for daily Facebook operations, create an operator plan with `facebook_auto_create_daily_plan`, then ask before running high-impact publish/message actions.
- If the user asks to search leads and also save/add friends, pass `autoSaveLeads`, `autoAddFriends`, `minAiScore`, and `friendRequestLimit` into `facebook_auto_create_lead_search`.
- For keyword opportunity discovery, choose `searchType` deliberately: `posts` for public post comments, `videos` for videos/Reels comments, `groups` for group discovery plus group-post comments, `marketplace` for listings/seller signals, and `all` when the user asks to search broadly across channels. `all` runs separate post, video/Reels, group, and Marketplace passes, then merges unique commenters and seller/listing leads with source evidence. Leave `searchVariants` enabled unless the user explicitly wants an exact query; it expands the keyword with commercial intent terms such as price, wholesale, where to buy, supplier, and interested. Leave `autoRetryOnLowQuality` enabled unless the user explicitly wants a single-pass search; when the first pass lacks commercial signals, Facebook-auto will retry with Marketplace/sales/buying-intent variants and merge unique commenters.
- When saving CRM leads, preserve source evidence fields when available: `sourceChannel`, `sourceType`, `sourceTitle`, `sourceUrl`, `sourceScore`, and `sourceEvidence`. The CRM save path now upserts by normalized Facebook identity and merges repeat sightings into the same lead record instead of creating duplicate rows.
- For normalized lead tables, use `facebook_auto_create_lead_discovery_run`, then run/search/collect as needed, call `facebook_auto_analyze_lead_table`, and return `facebook_auto_export_lead_table` when the user wants a table file. The normalized table now preserves source channel, source type, source title, source score, source reasons, and source evidence so channel-level evidence is visible during review.
- If the user provides product, pricing, FAQ, shipping, or company information for future replies, save it with `facebook_auto_upsert_knowledge_document`.
- For customer-service drafting, use `facebook_auto_create_customer_service_draft`; it retrieves matching knowledge chunks, returns matched document titles/confidence, and creates a pending review draft. If confidence is low or no documents match, ask for the missing product, quantity, budget, or shipping context instead of inventing an answer.
- Ask for explicit user confirmation before any action that can send a message, publish a post, join a group, or send a friend request.
- If the integration health endpoint reports outbound notifications disabled or unreachable, mention that clearly.
- Before queueing publish tasks, prefer running a safe diagnostic action first when the Facebook page readiness is uncertain.

## Read operations

Fetch integration health:

```bash
curl -s \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/health"
```

Fetch a sanitized dashboard summary:

```bash
curl -s \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/summary"
```

Fetch pending approval/action queues:

```bash
curl -s \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/pending"
```

## Write operations

All writes go through `POST /api/integrations/openclaw/action`.

Create a lead search:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"create_lead_search","keyword":"Silicone Piping Nozzle","searchType":"posts","mode":"playwright","maxResults":20,"maxPostsToVisit":5,"deepComments":true}'
```

Create a broad multi-channel lead search:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"create_lead_search","keyword":"Disposable Ice Pop Bags","searchType":"all","mode":"playwright","maxResults":50,"maxPostsToVisit":10,"deepComments":true,"searchVariants":true,"autoRetryOnLowQuality":true}'
```

Create a lead search that saves qualified leads and queues friend requests:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"create_lead_search","keyword":"Disposable Ice Pop Bags","searchType":"posts","mode":"playwright","maxResults":30,"maxPostsToVisit":8,"deepComments":true,"autoSaveLeads":true,"autoAddFriends":true,"minAiScore":75,"friendRequestLimit":8}'
```

Queue a feed post task after explicit user confirmation:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"queue_publish_feed_post","content":"post copy here","autoPublish":false,"scheduledAt":""}'
```

Automatically publish a feed post now:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"publish_feed_post_now","content":"post copy here"}'
```

Create a dry-run from a queued publish task:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"create_publish_dry_run_for_task","taskId":"task-xxx"}'
```

Create a dry-run from the latest queued publish task:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"create_publish_dry_run_for_latest_task"}'
```

Approve a publish task after dry-run and user confirmation:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"approve_publish_task","taskId":"task-xxx","dryRunTaskId":"task-dryrun-xxx"}'
```

Approve the latest queued publish task after user confirmation:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"approve_latest_publish_task"}'
```

Run a smoke regression bundle:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"run_smoke_regression","groupUrl":"https://www.facebook.com/groups/your-group","includePublisher":false}'
```

Queue a safe feed-post diagnostic:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"diagnose_feed_post"}'
```

Queue a group post task after explicit user confirmation:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"queue_publish_group_post","targetUrl":"https://www.facebook.com/groups/your-group","content":"group post copy here","autoPublish":false}'
```

Automatically publish a group post now:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"publish_group_post_now","targetUrl":"https://www.facebook.com/groups/your-group","content":"group post copy here"}'
```

Queue a safe group-post diagnostic:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"diagnose_group_post","targetUrl":"https://www.facebook.com/groups/your-group"}'
```

Queue a comment collection task:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"queue_collect_comments","targetUrl":"https://www.facebook.com/...","keyword":"automation"}'
```

Queue a login check task:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"check_facebook_login"}'
```

Approve a Messenger reply after user confirmation:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"approve_messenger_reply","messageId":"mm-xxx","aiReply":"你好，我们可以先确认你的需求和预算。"}'
```

Queue a Messenger reply task after explicit user confirmation:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"queue_send_messenger_reply","threadUrl":"https://www.messenger.com/t/test","threadId":"thread-xxx","senderName":"Alice","content":"reply text"}'
```

Queue a friend request after explicit user confirmation:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"queue_send_friend_request","profileUrl":"https://www.facebook.com/profile.php?id=123","name":"Alice"}'
```

Ignore a Messenger message:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"ignore_messenger_message","messageId":"mm-xxx"}'
```

Save a lead to CRM:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"save_crm_lead","lead":{"name":"Alice","profileUrl":"https://www.facebook.com/alice","snippet":"Looking for a quote","aiScore":82,"aiReason":"Clear buying intent","customerNeeds":"Needs pricing","sourceKeyword":"silicone nozzle","sourceSearchId":"lead-xxx"}}'
```

Update a CRM lead status:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"set_crm_lead_status","leadId":"crm-xxx","status":"contacted","notes":"Sent first outreach"}'
```

Delete a lead search after explicit user request:

```bash
curl -s \
  -X POST \
  -H "Authorization: Bearer $FACEBOOK_AUTO_TOKEN" \
  -H "Content-Type: application/json" \
  "${FACEBOOK_AUTO_BASE_URL:-http://127.0.0.1:3000}/api/integrations/openclaw/action" \
  -d '{"action":"delete_lead_search","leadSearchId":"lead-xxx"}'
```

## Collaboration pattern

When OpenClaw receives a Facebook-auto event from an OpenClaw hook or webhook:

1. Call the summary or pending endpoint first.
2. Summarize the situation in plain Chinese.
3. Recommend the next safe action.
4. Wait for user confirmation before any write that can contact people or publish content.

## Coverage

This skill is intended to cover the current Facebook-auto control surface:

- dashboard summary and health
- Messenger review and reply queueing
- lead search, CRM save, CRM status updates
- lead-search followups: auto-save qualified leads and queue friend requests
- main-code browser/CDP executor for publish drafts, publish dry-run, explicit publish approval, comments, lead search, diagnostics, and friend requests
- normalized lead tables and AI lead analysis
- knowledge documents for customer-service replies
