Facebook Fanpage Inbox for Meta Business Suite

SkillDB 作者 picseeinc v1.0.0

Check Facebook page inbox messages via Meta Business Suite browser automation. Use when asked to check Facebook messages, reply to FB customers, or manage Facebook page inbox. Supports multiple pages with custom aliases.

源码 ↗

安装 / 下载方式

TotalClaw CLI推荐
totalclaw install skilldb:picseeinc~meta-fb-inbox
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/skilldb%3Apicseeinc~meta-fb-inbox/file -o meta-fb-inbox.md
Git 仓库获取源码
git clone https://github.com/openclaw/skills/commit/d13349085527f55ce8fcb454acb4b557677591f2
# Meta Facebook Inbox

⚠️ **CRITICAL**: Always use `profile:"openclaw"` (isolated browser) for all browser actions. Never use Chrome relay. Keep the same `targetId` across operations to avoid losing the tab.

⚠️ **CONTEXT Management**:
- Snapshot results are large. Do NOT repeat them in thinking.
- Extract needed info and process immediately.
- **Preferred approach**: Use `snapshot refs:"aria" compact:true` to find element refs, then `act` + `click`/`type` with ref.

## Configuration

Before first use, check if `config.json` exists:
```
read file_path:"skills/meta-fb-inbox/config.json"
```

⚠️ **PATH RULE**: Always use workspace-relative paths starting from `skills/meta-fb-inbox/`. Never use `../` or absolute paths.

If missing or empty, help the user run the setup wizard:
```bash
cd skills/meta-fb-inbox
node scripts/setup.js
```

### Config Format

`config.json` contains a `pages` array. Each page has an `alias` (display name) and `url` (Meta Business Suite inbox URL):
```json
{
  "pages": [
    {
      "alias": "fb fanpage",
      "url": "https://business.facebook.com/latest/inbox/all/?&asset_id=123456789012345"
    },
    {
      "alias": "fb fanpage 2",
      "url": "https://business.facebook.com/latest/inbox/all/?&asset_id=987654321098765"
    }
  ]
}
```

### Resolving a Page

When the user asks to check messages:
- If they specify an alias (e.g. "fb fanpage 2"), look it up in `config.json` → `pages`.
- If they don't specify, use the **first** page in the array.
- If only one page exists, use it directly.
- If multiple pages exist and no alias given, list available aliases and ask which one.

## Enter Facebook Inbox

This is the first step for all operations below.

1. **Check and start browser service:**
   ```
   browser action:"status"
   ```
   If `"running": false`, start the browser service:
   ```
   browser action:"start" profile:"openclaw"
   ```
   Wait 2-3 seconds for the service to initialize.

2. **Read config to get the target page URL:**
   ```
   read file_path:"skills/meta-fb-inbox/config.json"
   ```
   Resolve the page alias to a URL (see "Resolving a Page" above).

3. **Open browser:**
   ```
   browser action:"open" profile:"openclaw" targetUrl:"<pageUrl>"
   ```
   Capture `targetId` and `url` from response.

4. **Wait for page load:**
   ```
   browser action:"act" profile:"openclaw" targetId:"<targetId>" request:{"kind":"wait","timeMs":3000}
   ```

5. **Check login state:**
   ```
   browser action:"act" profile:"openclaw" targetId:"<targetId>" request:{"kind":"evaluate","fn":"function(){return window.location.href;}"}
   ```

   - If URL contains `business.facebook.com` and shows the inbox → logged in, proceed.
   - If redirected to a login page → notify the user they need to log in manually in the OpenClaw browser, then retry.

6. **Proceed with the user's request.**

7. **Clean Up Browser Tabs** (after all operations):

   a. Open a blank tab:
   ```
   browser action:"open" profile:"openclaw" targetUrl:"about:blank"
   ```

   b. Get all tabs:
   ```
   browser action:"tabs" profile:"openclaw"
   ```

   c. Close all tabs except the newest one (about:blank):
   ```
   browser action:"close" profile:"openclaw" targetId:"<your_targetId>"
   ```

## Quick Check (for cron / automated checks)

Complete flow: open page → screenshot → report.

1. Read config: `read file_path:"skills/meta-fb-inbox/config.json"` → resolve page URL
2. Start browser if needed: `browser action:"start" profile:"openclaw"`
3. Open page: `browser action:"open" profile:"openclaw" targetUrl:<pageUrl>` → get `targetId`
4. Wait: `browser action:"act" profile:"openclaw" targetId:<targetId> request:{"kind":"wait","timeMs":4000}`
5. Check URL to verify login (see step 5 above)
6. Take snapshot: `browser action:"snapshot" profile:"openclaw" targetId:<targetId> refs:"aria" compact:true`
7. Look for conversation items in the inbox list. Each conversation typically shows:
   - Customer name
   - Last message preview
   - Timestamp
   - Unread indicator (bold text or dot)
8. Report results in format: `<name> (<time>) <preview> [未讀/已讀]`
9. Clean up tabs.

If the snapshot is hard to parse (Meta's DOM is complex), fall back to:
```
browser action:"screenshot" profile:"openclaw" targetId:<targetId>
```
Then describe what you see in the screenshot.

## Check Inbox Messages

1. Follow "Enter Facebook Inbox" steps to get to the inbox page.
2. Take a snapshot or screenshot to see the conversation list.
3. Report conversations with name, time, preview, and read/unread status.

### Get URLs for Conversations (取得對話網址 - Simple!)

**Why get URLs?** Having the direct conversation URL lets you jump straight to a chat later without searching for it again. Saves time when replying.

**When to get URLs:** After listing chats, get URLs for unread conversations or any conversation you might need to access again.

**📝 Simple 3-Step Method:**

1. **Click into the conversation** using the customer name:
   ```
   browser action:"act" profile:"openclaw" targetId:"<targetId>" request:{"kind":"evaluate","fn":"function() { const containers = document.querySelectorAll('div[style*=\"position: absolute\"]'); for (let container of containers) { const nameEl = container.querySelector('div.x1vvvo52.x1fvot60.xxio538'); if (nameEl && nameEl.textContent.trim() === '<customer_name>') { nameEl.click(); return {clicked: true}; } } return {error: 'not found'}; }"}
   ```
   Replace `<customer_name>` with the actual customer name from your conversation list.

2. **Wait 2 seconds for page to load and URL to update:**
   ```
   browser action:"act" profile:"openclaw" targetId:"<targetId>" request:{"kind":"wait","timeMs":2000}
   ```

3. **Get the current URL - it's automatically updated!**
   ```
   browser action:"act" profile:"openclaw" targetId:"<targetId>" request:{"kind":"evaluate","fn":"function(){return window.location.href;}"}
   ```

4. **Store the URL** alongside the chat info.

**✅ Example URL Format:**

```
https://business.facebook.com/latest/inbox/all/?&asset_id=123456789012345&selected_item_id=1234567890&thread_type=FB_MESSAGE
```

Or with optional mailbox_id:
```
https://business.facebook.com/latest/inbox/all/?&asset_id=123456789012345&mailbox_id=123456789012345&selected_item_id=9876543210&thread_type=FB_MESSAGE
```

**🔍 Understanding the URL:**
- `asset_id` = Your Facebook page ID (stays the same)
- `selected_item_id` = Unique conversation ID (different for each customer)
- `thread_type=FB_MESSAGE` = Messenger conversation type
- `mailbox_id` = Optional, may appear for some conversations

**💾 How to Use Later:**

Next time you need to access this conversation, skip all the searching:
```
browser action:"navigate" profile:"openclaw" targetId:"<targetId>" targetUrl:"<saved_conversation_url>"
```
Wait 2 seconds, and you're in the conversation!

**💡 Tip:** Get URLs for unread messages during your check routine, store them in a file or memory, and reuse them for instant access.

**🔄 Getting Multiple URLs:**

If you need URLs for multiple conversations:
1. Get URL for first conversation (steps 1-3 above)
2. Navigate back to inbox list:
   ```
   browser action:"navigate" profile:"openclaw" targetId:"<targetId>" targetUrl:"<pageUrl>"
   ```
   Wait 2 seconds.
3. Repeat for next conversation.

**Alternative method (when already in conversation):**
If you're already viewing a conversation and just need its URL, skip step 1 and directly run step 3 - the URL is already there!

## View Specific Conversation

**⚡ Fast Path:** If you have the conversation URL from "Get URLs for Conversations":
```
browser action:"navigate" profile:"openclaw" targetId:"<targetId>" targetUrl:"<conversation_url>"
```
Wait 2 seconds, then skip to step 3.

**Standard Path:**

1. From the inbox list, find and click the conversation (use snapshot + click by ref).
2. Wait for messages to load (2-3 seconds).
3. Take a screenshot to see the message thread.
4. Report the messages with sender, time, and content.

### Ex