# Airtable to a Facebook Page queue: n8n template

This n8n workflow sends each approved Airtable record to a PubNio schedule queue for one Facebook Page, so posts take the next free weekly slot instead of a hand-picked time. The slot's local date and time land in pubnio_outcome. A key saved on the record before sending keeps a rerun from taking a second slot.

Download: <https://pubnio.com/templates/n8n/airtable-to-facebook.json> (n8n workflow JSON, no credentials inside). Checked on n8n 2.50.7. Destination: Facebook (Live).

## What it does

- **Trigger.** A Schedule Trigger every 15 minutes searches the table with `{Status} = 'Approved'`.
- **Approval.** Set Status to Approved; the queue decides when it posts.
- **Request.** One create request per approved item. Each create carries the item's saved key as `Idempotency-Key`, and every request sends `PubNio-Version: 2026-12-02`.
- **Result.** The answer is written back to the item; the next runs read the post's status until every destination settles.

## Fields: Airtable fields

| Field | Type | Use |
| --- | --- | --- |
| `Status` | single select | Approved queues the record. |
| `Message` | long text | The Page post text. |
| `Link` | URL | Optional link preview; HTTPS. Leave Image URL empty when you fill it. |
| `Image URL` | URL | Optional public HTTPS image, posted by URL. Leave Link empty when you fill it. |

The workflow also fills `pubnio_key`, `pubnio_post_id`, `pubnio_status`, `pubnio_outcome`, `pubnio_error`, `pubnio_sent_at`; create them as text fields.

## Set up

1. **Create a PubNio API key.** In PubNio, create an API key with the publish scope; it includes read, which the status checks use.
2. **Import the workflow.** Download the JSON and import it into n8n with Import from File. It is checked on n8n 2.50.7.
3. **Add the PubNio credential.** Create a Header Auth credential named PubNio API key with name Authorization and value Bearer followed by the key. Select it on **Create post in PubNio**, **Read post status**.
4. **Fill PubNio settings.** Open the PubNio settings node and set `workspaceId`, `facebookAccountId`, `facebookQueueId`. `facebookAccountId`: The Page's account ID from PubNio's list of connected accounts. `facebookQueueId`: The ID of a schedule queue you create in PubNio.
5. **Connect Airtable.** Add the airtable fields above and the pubnio_ text fields, then select your Airtable credential and the same base and table on **Read rows**, **Save key before sending**, **Write result to row**.
6. **Run one approved test item.** Approve one test item, run the workflow once, and read pubnio_status and pubnio_outcome. Then activate it.

## Request

`queueId` replaces a time: PubNio assigns the slot and reports it back. A Facebook feed post carries a link preview or media, never both; PubNio answers `settings_conflict` to both, so the workflow rejects such a record before sending.

```json
{
  "text": "New on the blog: spring checklist.",
  "targets": [
    {
      "accountId": "22222222-2222-4222-8222-222222222222",
      "queueId": "9a9a9a9a-9a9a-49a9-89a9-9a9a9a9a9a9a",
      "settings": {
        "link": "https://blog.example.com/spring"
      }
    }
  ]
}
```

## Tested behavior

The download is imported unchanged into a clean n8n 2.50.7 container, and its node types, versions, parameters, and operations are checked against that release. Then a copy runs with n8n execute. Its PubNio requests and its Code, If, Switch, and Merge nodes run as published. Its trigger and source nodes are simulated by a fake source with the same row shapes, its media wait is cut to one second, and PubNio is a fake API that decodes every request with PubNio's own schemas and checks it with PubNio's own content rules. PubNio's test suite replays every create and validate request the run sent against the real API and requires the same answer. It proves:

- Only approved items are sent to PubNio.
- The key is a hash of the stable row ID, saved on the row with its send time before the request that sends it.
- A lost response (503 after PubNio admitted the post) is resent with the same key and PubNio returns the first post.
- A key with no post ID that was sent 23 hours and 1 minute ago, or has no send time, stops at needs_review instead of being resent.
- A 202 is recorded as queued or scheduled, never as published, until a delivery reports it.
- The post targets the configured Page with the configured `queueId`, and Link arrives as `settings.link`.
- pubnio_outcome records the slot PubNio assigned, e.g. `(queue slot 2026-12-08 09:30 UTC)`.
- A record with an Image URL and no Link posts the image by URL; a record with both is rejected by the workflow and nothing is sent, then accepted once Image URL is cleared.

## Recovery

- **When pubnio_error names `queue_not_found` or `queue_unavailable`:** Fix facebookQueueId or the queue in PubNio and clear pubnio_status. PubNio stored nothing for the rejected request, so the next run sends the row again.
- **When pubnio_error says `Fill Link or Image URL, not both`:** Clear one of the two fields, then clear pubnio_status; the next run sends the record.
- **When the slot is wrong:** Change it in PubNio; the next runs keep reading the post.

## Limits

- One Page and one queue per workflow.
- The queue's slots and time zone are managed in PubNio, not in Airtable.
- PubNio has no approval step of its own; approval happens in Airtable before n8n calls PubNio.
- The check uses a fake PubNio and fake provider answers, so this page shows no real delivery.

## Related

- [n8n integration: every PubNio template](https://pubnio.com/integrations/n8n)
- [Airtable to TikTok: n8n template for approved videos](https://pubnio.com/templates/n8n/airtable-to-tiktok)
- [Airtable to Pinterest: n8n template that pins approved records](https://pubnio.com/templates/n8n/airtable-to-pinterest)
- [PubNio quickstart](https://pubnio.com/docs/quickstart/)

