---
name: post-to-facebook
description: Post a product listing to Facebook Marketplace using the browser. Reads listing data from the product's LISTING.md, navigates to Facebook Marketplace, and fills in the listing form.
user_invocable: true
argument: (optional) product name (subfolder name under marketplace/)
---

# Post to Facebook Marketplace

{% if argument %}
You are posting the listing for **{{ argument }}** to Facebook Marketplace using the browser MCP tools.

Use **{{ argument }}** as the PRODUCT_NAME throughout the steps below.
{% else %}
## Step 0 – Select a Product

No product was specified. You need to find a product that hasn't been posted to Facebook yet.

1. Use `Glob` to find all `LISTING.md` files under the project directory.
2. For each `LISTING.md`, read it and check if it contains a **פוסט פייסבוק** row in the **פרטי מוצר** table.
3. Collect all products that do NOT have a פוסט פייסבוק entry (i.e., no Facebook post URL yet).
4. If all products already have a Facebook post, tell the user "All listings already have a Facebook post URL" and stop.
5. If there are multiple products without a Facebook post, pick the first one alphabetically and tell the user which product you selected.
6. Use the selected product's subfolder name as the **PRODUCT_NAME** throughout the steps below.

{% endif %}

**In all steps below, replace `PRODUCT_NAME` with the resolved product name (either from the argument or from Step 0).**

## Task Tracking

At the start of this skill, create a task list using `TaskCreate` to track progress. Create one task per step:

1. "Read listing data from LISTING.md"
2. "Navigate to Facebook Marketplace"
3. "Fill in listing form"
4. "Review before publishing"
5. "Publish listing"
6. "Update index.html dashboard"

As you begin each step, update its task to `in_progress`. When a step completes, update it to `completed`. If a step is blocked or fails, update it to `blocked` or note the issue.

## Step 1 – Read Listing Data

1. Read `PRODUCT_NAME/LISTING.md`
2. Extract all listing fields:
   - **Title**: from כותרת לפוסט section
   - **Description**: from תיאור לפוסט section
   - **Price**: מחיר מבוקש from מחירי שוק table
   - **Category**: קטגוריה from פרטי מוצר table
   - **Photos**: all image files (*.jpeg, *.jpg, *.png, *.webp) in the `PRODUCT_NAME/` directory
3. If the title, description, or price is empty, STOP and tell the user to run `/research-product PRODUCT_NAME` first.
4. Check if there is an `archive/` subdirectory in the product folder. If there is NO `archive/` directory, the photos haven't been processed yet — automatically run the `/process-photos PRODUCT_NAME` skill to process them before continuing. After processing completes, re-scan the directory for the updated photo list.

## Step 2 – Navigate to Facebook Marketplace

1. First, create a new browser tab using `browser_tab_create` to avoid conflicting with other browser sessions.
2. Use `browser_navigate` to go to: `https://www.facebook.com/marketplace/create/item`
3. Take a snapshot to see the current page state
4. If not logged in, take a screenshot and ask the user to log in manually, then wait and retry

## Step 3 – Fill in the Listing Form

Facebook Marketplace's "Create new listing" form has these fields. Fill them in order, taking a snapshot after each major action to verify state.

### Photos
1. Look for the photo upload area (usually "Add photos" or "הוסף תמונות")
2. Photo upload requires file paths — tell the user the absolute paths of the **processed** photos (from Step 2) they need to upload manually:
   - List each processed photo with its full path
3. Wait for the user to confirm photos are uploaded before continuing

### Title
1. Find the title/כותרת input field
2. Type the value from כותרת לפוסט

### Price
1. Find the price/מחיר input field
2. Type the מחיר מבוקש value — numbers only, no currency symbol

### Category
1. Find the category/קטגוריה field
2. Click it and search for or select the appropriate category based on קטגוריה
3. Use snapshot to find matching options and click the best match

### Condition
1. Find the condition/מצב field
2. Select "Used - Good" / "משומש – מצב טוב" (or equivalent)

### Description
1. Find the description/תיאור text area
2. Type the full description from תיאור לפוסט
3. Note: newlines should be typed as-is

### Location
1. If a location field is present and empty, type "תל אביב" or "Tel Aviv"
2. Select the first suggestion from the dropdown

## Step 4 – Review Before Publishing

1. Take a screenshot of the completed form
2. Show the screenshot to the user
3. Present a summary of what was filled in:
   - Title
   - Price
   - Category
   - Description (first 2 lines)
   - Number of photos
4. **Ask the user for explicit confirmation before clicking "Publish" / "פרסם"**
5. Do NOT click publish without user approval

## Step 5 – Publish (only after user confirms)

1. Once the user approves, click through all remaining steps ("Next" / "הבא" / "Publish" / "פרסם") **without asking for additional confirmations**. Just click Next, then Publish, navigating through any review/confirmation pages automatically.
2. Take a snapshot/screenshot to verify the listing was posted successfully.
3. Once published, copy the URL of the new listing from the browser.
4. Add a **פוסט פייסבוק** row to the **פרטי מוצר** table in `PRODUCT_NAME/LISTING.md` with the listing URL.

## Step 6 – Update index.html

1. Open `index.html` in the project root.
2. In the **dashboard summary table**, find the row for **PRODUCT_NAME** and:
   - Change the status from `ממתין` (with class `status-pending`) to `פורסם` (with class `status-listed`).
   - Add the Facebook listing URL in the לינק לפוסט column.
3. In the **product card** for PRODUCT_NAME, add a Facebook post link button (class `fb-post-link`) with the listing URL, if one doesn't already exist. Place it after the badge and before the price tag, matching the format of other cards that have it.

## Important Notes

- **Always snapshot before interacting** — Facebook's UI changes frequently; never assume element refs from a previous snapshot are still valid.
- **Never guess refs** — always take a fresh snapshot to get current element references.
- **If something fails**, take a screenshot, show it to the user, and ask how to proceed.
- **RTL text**: Hebrew text may render RTL. When typing Hebrew, type it as-is — the browser handles directionality.
- **Photos cannot be uploaded programmatically** via browser_click on file inputs in most cases. Provide the user with the file paths and ask them to drag-and-drop or use the file picker manually.
