# OpenClaw Standard Operating Playbook

This playbook is the safest way to operate `Facebook-auto` through OpenClaw.

The message source before OpenClaw is intentionally out of scope. Whether the user sends the instruction from WeChat, OpenClaw Web UI, OpenClaw CLI, or another bridge, OpenClaw should call this project's MCP tools and judge readiness from `facebook_auto_health`.

## Before you start

1. Start the project with your normal logged-in Chrome:

```bash
npm run dev:facebook
```

2. Sync the latest skill into the OpenClaw workspace:

```bash
npm run openclaw:sync-skill
```

3. Open an OpenClaw chat session with the project token preloaded:

```bash
bash scripts/openclaw-facebook-chat.sh
```

## Recommended command order

### 1. Environment check

```text
使用 facebook-auto-ops skill。先调用 health 和 pending。然后运行 check_facebook_login 与 diagnose_feed_post，把结果和下一步建议告诉我，不要直接发帖。
```

Use this when:

- you just started the project
- Facebook may not be logged in
- you are unsure whether the current tab is executable

### 1b. Inspect Current Facebook Page

```text
使用 facebook-auto-ops skill。先调用 health；如果 CDP 可用，运行 browser_snapshot。根据 snapshot 的 URL、标题、article 数、评论排序控件、展开评论控件，判断当前页面能否采集评论或发帖。

`health.browser.facebookPageState.pageType` 是判断页面用途的优先信号。`home_feed` 只适合登录检测和发新鲜事；关键词商机发现必须让 Facebook-auto 跳转到帖子、小组、Reels/视频、Marketplace 等搜索渠道，不要直接从首页信息流采集线索。

`queue_collect_comments` 只用于具体内容详情页：普通帖子、群组帖子、Reel/视频。不要把首页、搜索结果页、个人主页、小组主页或 Marketplace 链接传给它；这些页面应改用 `create_lead_search` 或对应渠道采集。
```

Use this when:

- OpenClaw is unsure what Facebook page is actually open
- comment collection returns too few or incorrect records
- you need evidence before retrying a browser task

### 2. Safe feed post

```text
使用 facebook-auto-ops skill。先运行 diagnose_feed_post。若主页发帖入口可用，再为我 queue_publish_feed_post，内容由我下一条消息提供，autoPublish=false。
```

Use this when:

- you want to post to your feed or page
- you want a diagnostic before queueing the task

### Regression bundle

```text
使用 facebook-auto-ops skill。先调用 health 和 summary。然后运行 facebook_auto_run_smoke_regression 和 facebook_auto_run_lead_fixture_regression；如果我提供了 groupUrl，就把它一起带上。最后总结登录态、主页入口、群组入口，以及帖子/小组/Reels/Marketplace 线索样本是否稳定。
```

Use this when:

- you want one standard smoke test after code changes
- you need a repeatable readiness check before real posting
- you changed lead collection, scoring, source evidence, or CRM merge logic

### 3. Safe group post

```text
使用 facebook-auto-ops skill。先运行 diagnose_group_post，targetUrl 由我提供。若群组发帖入口可用，再为我 queue_publish_group_post，autoPublish=false，并等我确认内容。
```

Use this when:

- you need to verify group posting permission or page readiness
- the group URL may be wrong

### 4. Messenger review

```text
使用 facebook-auto-ops skill。读取 pending，列出所有待审核 Messenger 消息，并给每条消息一个建议动作：批准回复、忽略、或继续人工修改。不要直接发送。
```

Use this when:

- you want OpenClaw to triage new Messenger messages
- you want human confirmation before sending

### 5. Lead search and CRM

```text
使用 facebook-auto-ops skill。创建一个 lead search，关键词由我提供，searchType=all，mode=playwright，deepComments=true。完成后分析 lead discovery 表，按评论人、评论内容、来源链接和意向分总结高分候选线索；没有我的确认不要直接加好友。
```

Use this when:

- you want OpenClaw to search and analyze opportunities first
- you want CRM writes gated by your approval

## Failure interpretation

When OpenClaw reports task failures, these are the common meanings:

- `主页发帖入口缺失`
  The current Facebook home page did not expose a usable composer.
- `群组发帖入口缺失`
  The group page either lacks permission or the composer UI was not found.
- `未登录 Facebook`
  The CDP-enabled Chrome is not logged in to Facebook.
- `后台不可达`
  The local `Facebook-auto` server is not reachable from OpenClaw or the browser executor.

## Rule of thumb

- Diagnose first when page readiness is uncertain.
- Queue internal tasks directly when the user clearly asked for them.
- Confirm before any external action that can send or publish content.
