Skip to content

Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.

feat(content): pick Webflow or the webhook when sending pages to the CMS (Send to CMS #1331, phase 2 part 4: send target) (#1506)

Cihan5f39b59a0cf7
diff --git a/web/messages/en.json b/web/messages/en.json
index 865497abf..b78cfccf0 100644
--- a/web/messages/en.json
+++ b/web/messages/en.json
@@ -3391,7 +3391,13 @@
"failed": "The last send to your CMS failed, {when}",
"published": "Published {when}",
"openLive": "Published {when}: open the live page in a new tab",
- "answered": "The webhook answered {status}."
+ "answered": "The webhook answered {status}.",
+ "webflow": {
+ "queued": "Sending to Webflow since {when}",
+ "sent": "In Webflow as a draft item since {when}",
+ "failed": "The last send to Webflow failed, {when}",
+ "published": "Published {when}"
+ }
},
"bulk": {
"selected": "{count, plural, one {# page selected} other {# pages selected}}",
@@ -3402,6 +3408,7 @@
"selectRow": "Select {title}",
"title": "{count, plural, one {Send # page to your CMS} other {Send # pages to your CMS}}",
"description": "Each page goes to the brand's webhook as it is ready to publish, with the slug and meta of its last send, else the page's. Open a page in the editor to change them.",
+ "descriptionWebflow": "Each page goes to {collection} in Webflow as a draft item, as it is ready to publish, with the slug and meta of its last send, else the page's. Open a page in the editor to change them.",
"readFailed": "Couldn't read the pages. Try again.",
"retry": "Try again",
"notFound": "A page was archived or deleted since you picked it. Close this, pick the pages again and send.",
@@ -3431,6 +3438,7 @@
"waitedOut": "The pages before {count, plural, one {it} other {them}} were still going after 30 minutes, so {count, plural, one {# page wasn't} other {# pages weren't}} sent. Send {count, plural, one {it} other {them}} again once they have gone.",
"closedUnsent": "{count, plural, one {# page wasn't sent} other {# pages weren't sent}}: the dialog closed while the pages before {count, plural, one {it} other {them}} were still going. Send {count, plural, one {it} other {them}} again from the Library.",
"skipped": "{count, plural, one {# page wasn't sent} other {# pages weren't sent}}: the workspace has sent 200 pages in the last 24 hours. Try again later.",
+ "inProgress": "A page is already on its way to Webflow. Wait for it, then send again.",
"close": "Close",
"cancel": "Cancel",
"send": "{count, plural, one {Send # page} other {Send # pages}}",
@@ -4298,9 +4306,26 @@
},
"send": {
"button": "Send to CMS",
- "hint": "Send the page to your CMS through the brand's webhook",
+ "hint": "Send the page to your CMS: Webflow, or your workflow through the brand's webhook",
"title": "Send to CMS",
"description": "The page goes to the brand's webhook, for your workflow tool (Zapier, Make, n8n) to publish it in your CMS.",
+ "descriptionWebflow": "The page goes to {collection} in Webflow as a draft item, with its slug and meta. You publish it in Webflow.",
+ "descriptionReading": "The page goes to your CMS with its slug and meta, kept on the page.",
+ "target": {
+ "label": "Send to",
+ "webflow": {
+ "title": "Webflow",
+ "hint": "A draft item in {collection}",
+ "collection": "your collection",
+ "notReady": "Not ready: connect it again or pick its collection in Settings › Integrations"
+ },
+ "webhook": {
+ "title": "Your workflow",
+ "hint": "The brand's webhook (Zapier, Make, n8n)"
+ },
+ "unchecked": "Couldn't check Webflow just now, so this send goes to your workflow.",
+ "retry": "Try again"
+ },
"placeholders": "{count, plural, one {# placeholder is} other {# placeholders are}} still open. Fill {count, plural, one {it} other {them}} first: none goes to your CMS.",
"fillNow": "Fill now",
"empty": "The page has nothing under its title yet. Write it first, then send it.",
@@ -4328,6 +4353,12 @@
"failed": "The last send failed, {when}.",
"published": "Published {when}."
},
+ "lastWebflow": {
+ "queued": "Last sent to Webflow {when}, still on its way.",
+ "sent": "In Webflow as a draft item since {when}.",
+ "failed": "The last send to Webflow failed, {when}.",
+ "published": "Published {when}."
+ },
"errors": {
"no_webhook": "This brand has no webhook yet. Set one up in Webhook Settings on Content Opportunities.",
"webhook_not_subscribed": "The brand's webhook doesn't receive \"Content page sent\". Turn it on in Webhook Settings on Content Opportunities.",
@@ -4339,12 +4370,22 @@
"failed": "Couldn't send the page. Try again.",
"too_large": "Too much to send in one go. Send fewer pages, or shorter ones.",
"webhookStatus": "The webhook answered {status} and didn't take the page. Check your workflow, then send again.",
- "webhookFailed": "The webhook didn't take the page: {reason}"
+ "webhookFailed": "The webhook didn't take the page: {reason}",
+ "webflowFailed": "Webflow didn't take the page: {reason}",
+ "webflow_not_configured": "Webflow isn't set up on this server. Send to your workflow instead.",
+ "no_webflow": "Connect Webflow in Settings › Integrations first.",
+ "webflow_refused": "Webflow refused the brand's site token. Connect it again in Settings › Integrations.",
+ "webflow_not_ready": "Pick the Webflow collection pages go to in Settings › Integrations.",
+ "in_progress": "This page is already on its way to Webflow. Wait for it, then send again.",
+ "no_webhookWebflow": "This brand's Webflow isn't ready, and it has no webhook. Connect Webflow again or pick its collection in Settings › Integrations."
},
"cancel": "Cancel",
"send": "Send",
"sending": "Sending",
- "sent": "Sent to your CMS"
+ "sent": "Sent to your CMS",
+ "sentWebflow": "Sent to Webflow as a draft item",
+ "sentWebflowUpdated": "Updated in Webflow",
+ "webflowChanged": "{tables, plural, =0 {} one {# table went as a list. } other {# tables went as lists. }}{images, plural, =0 {} one {# image wasn't sent: add it in Webflow.} other {# images weren't sent: add them in Webflow.}}"
},
"rulesChip": "Rules {met}/{total}",
"rulesChipHint": "Rules this page meets now. Open the Rules tab.",
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
index a1a603e73..0f333315b 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/editor/[draftId]/page.test.tsx
@@ -173,6 +173,10 @@ vi.mock('@/lib/download', () => ({ saveBlob }));
const readDraftCms = vi.hoisted(() => vi.fn());
const sendPagesToCms = vi.hoisted(() => vi.fn());
vi.mock('@/lib/content/cms-send-client', () => ({ readDraftCms, sendPagesToCms }));
+// The brand's Webflow connection (#1331, phase 2): none here.
+vi.mock('@/lib/webflow-client', () => ({
+ readWebflow: async () => ({ ok: true, configured: false, connection: null }),
+}));
(
globalThis as typeof globalThis & {
@@ -4864,16 +4868,20 @@ describe('the side panel', () => {
'pipeline-forecasting',
);
await act(async () => inDialog('Send').click());
- expect(sendPagesToCms).toHaveBeenCalledWith('b1', [
- expect.objectContaining({
- draftId: 'd1',
- title: 'Pipeline forecasting',
- slug: 'pipeline-forecasting',
- html: '<p>Teams trust it.</p>',
- // Authors come with Quality (CE-038): while it is off, none goes.
- author: null,
- }),
- ]);
+ expect(sendPagesToCms).toHaveBeenCalledWith(
+ 'b1',
+ [
+ expect.objectContaining({
+ draftId: 'd1',
+ title: 'Pipeline forecasting',
+ slug: 'pipeline-forecasting',
+ html: '<p>Teams trust it.</p>',
+ // Authors come with Quality (CE-038): while it is off, none goes.
+ author: null,
+ }),
+ ],
+ 'webhook',
+ );
expect(dialog()).toBeNull();
});
@@ -4886,9 +4894,11 @@ describe('the side panel', () => {
await act(async () => button('Send to CMS')!.click());
await act(async () => inDialog('Continue to send').click());
await act(async () => inDialog('Send').click());
- expect(sendPagesToCms).toHaveBeenCalledWith('b1', [
- expect.objectContaining({ draftId: 'd1', author: 'Acme Ekibi' }),
- ]);
+ expect(sendPagesToCms).toHaveBeenCalledWith(
+ 'b1',
+ [expect.objectContaining({ draftId: 'd1', author: 'Acme Ekibi' })],
+ 'webhook',
+ );
} finally {
brandState.brands = [{ id: 'b1' }, { id: 'b2' }];
}
@@ -4909,9 +4919,11 @@ describe('the side panel', () => {
await act(async () => inDialog('Continue to send').click());
await act(async () => inDialog('Send').click());
// The CMS keeps its own author.
- expect(sendPagesToCms).toHaveBeenCalledWith('b1', [
- expect.objectContaining({ draftId: 'd1', author: null, html: '<p>Teams trust it.</p>' }),
- ]);
+ expect(sendPagesToCms).toHaveBeenCalledWith(
+ 'b1',
+ [expect.objectContaining({ draftId: 'd1', author: null, html: '<p>Teams trust it.</p>' })],
+ 'webhook',
+ );
});
it('opens Before you publish first while Quality is on', async () => {
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.test.tsx
index cc485e7a8..5d83569fe 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.test.tsx
@@ -18,6 +18,28 @@ vi.mock('@/lib/content/cms-send-client', () => ({
readDeliveries,
sendPagesToCms,
}));
+// The brand's Webflow connection (#1331, phase 2): none unless a test gives one.
+const webflow = vi.hoisted(() => ({ ready: false, refused: false, failed: false }));
+vi.mock('@/lib/webflow-client', () => ({
+ readWebflow: async () => ({
+ ok: !webflow.failed,
+ code: 'failed',
+ configured: true,
+ connection:
+ webflow.ready || webflow.refused
+ ? {
+ status: webflow.refused ? 'auth_failed' : 'connected',
+ siteId: 's1',
+ siteName: 'Acme',
+ collectionId: 'c1',
+ collectionName: 'Blog Posts',
+ fieldMap: { body: 'post-body' },
+ connectedAt: '2026-10-25T10:00:00Z',
+ updatedAt: '2026-10-25T10:00:00Z',
+ }
+ : null,
+ }),
+}));
// One request a page, so a test can refuse the second.
const oneByOne = vi.hoisted(() => ({ on: false }));
vi.mock('@/lib/content/cms-send', async (importOriginal) => {
@@ -88,6 +110,15 @@ const lines = () => [...dialog().querySelectorAll('li')].map((li) => li.textCont
beforeEach(() => {
oneByOne.on = false;
+ Object.assign(webflow, { ready: false, refused: false, failed: false });
+ // The send target remembered per brand, in this browser.
+ const kept = new Map<string, string>();
+ vi.stubGlobal('localStorage', {
+ getItem: (key: string) => kept.get(key) ?? null,
+ setItem: (key: string, value: string) => void kept.set(key, value),
+ removeItem: (key: string) => void kept.delete(key),
+ clear: () => kept.clear(),
+ });
onClose.mockReset();
readCmsSources.mockReset().mockResolvedValue(
new Map([
@@ -109,6 +140,7 @@ afterEach(() => {
act(() => root.unmount());
container.remove();
vi.useRealTimers();
+ vi.unstubAllGlobals();
});
describe('BulkSendDialog', () => {
@@ -142,8 +174,13 @@ describe('BulkSendDialog', () => {
expect(dialog().textContent).toContain("A page that can't go is left out");
await act(async () => button('Send 2 pages').click());
- const [, pages] = sendPagesToCms.mock.calls[0] as [string, { draftId: string; slug: string }[]];
+ const [, pages, target] = sendPagesToCms.mock.calls[0] as [
+ string,
+ { draftId: string; slug: string }[],
+ string,
+ ];
expect(sendPagesToCms).toHaveBeenCalledTimes(1);
+ expect(target).toBe('webhook');
expect(pages.map((page) => [page.draftId, page.slug])).toEqual([
['d1', 'pour-over'],
// What it kept from its last send.
@@ -169,6 +206,68 @@ describe('BulkSendDialog', () => {
expect(onClose).toHaveBeenCalled();
});
+ it('sends the pages to the brand’s Webflow collection when Settings has it ready', async () => {
+ vi.useFakeTimers({ toFake: ['setTimeout', 'clearTimeout', 'Date'] });
+ webflow.ready = true;
+ sendPagesToCms.mockResolvedValue({
+ ok: true,
+ skipped: 0,
+ deliveries: [
+ { id: 'x1', draftId: 'd1', status: 'queued' },
+ { id: 'x3', draftId: 'd3', status: 'queued' },
+ ],
+ });
+ readDeliveries.mockResolvedValue([
+ { id: 'x1', draftId: 'd1', status: 'sent', http_status: null, error: null },
+ { id: 'x3', draftId: 'd3', status: 'sent', http_status: null, error: null },
+ ]);
+ await render();
+ expect(dialog().textContent).toContain(
+ 'Each page goes to Blog Posts in Webflow as a draft item',
+ );
+ const webflowChoice = [...dialog().querySelectorAll('[role="radio"]')].find((r) =>
+ r.textContent?.startsWith('Webflow'),
+ );
+ expect(webflowChoice?.getAttribute('aria-checked')).toBe('true');
+ await act(async () => button('Send 2 pages').click());
+ expect(sendPagesToCms.mock.calls[0]?.[2]).toBe('webflow');
+ expect(localStorage.getItem('aeo:cms-target:brand-1')).toBe('webflow');
+ // Once sent, the choice is gone.
+ await act(async () => void (await vi.advanceTimersByTimeAsync(2_000)));
+ expect(dialog().querySelector('[role="radio"]')).toBeNull();
+ });
+
+ it('sends to the webhook when Webflow can’t be read, saying so to a person who sent to Webflow', async () => {
+ webflow.failed = true;
+ localStorage.setItem('aeo:cms-target:brand-1', 'webflow');
+ sendPagesToCms.mockResolvedValue({
+ ok: true,
+ skipped: 0,
+ deliveries: [
+ { id: 'x1', draftId: 'd1', status: 'sent' },
+ { id: 'x3', draftId: 'd3', status: 'sent' },
+ ],
+ });
+ await render();
+ expect(dialog().querySelector('[role="radio"]')).toBeNull();
+ expect(dialog().querySelector('[role="status"]')!.textContent).toContain(
+ "Couldn't check Webflow just now, so this send goes to your workflow.",
+ );
+ expect(button('Send 2 pages').disabled).toBe(false);
+ await act(async () => button('Send 2 pages').click());
+ expect(sendPagesToCms.mock.calls[0]?.[2]).toBe('webhook');
+ });
+
+ it('says Webflow isn’t ready when the brand has no webhook either', async () => {
+ webflow.refused = true;
+ sendPagesToCms.mockResolvedValue({ ok: false, code: 'no_webhook', field: null });
+ await render();
+ await act(async () => button('Send 2 pages').click());
+ expect(dialog().querySelector('[role="alert"]')!.textContent).toBe(
+ "This brand's Webflow isn't ready, and it has no webhook. Connect Webflow again or pick its collection in Settings › Integrations.",
+ );
+ });
+
it('says why nothing went, and keeps the pages to send again', async () => {
sendPagesToCms.mockResolvedValue({ ok: false, code: 'webhook_not_subscribed', field: null });
await render();
@@ -179,6 +278,22 @@ describe('BulkSendDialog', () => {
expect(button('Send 2 pages').disabled).toBe(false);
});
+ it('says a page is already on its way to Webflow, and clears it when the webhook is picked', async () => {
+ webflow.ready = true;
+ sendPagesToCms.mockResolvedValue({ ok: false, code: 'in_progress', field: null });
+ await render();
+ await act(async () => button('Send 2 pages').click());
+ expect(sendPagesToCms.mock.calls[0]?.[2]).toBe('webflow');
+ expect(dialog().querySelector('[role="alert"]')!.textContent).toBe(
+ 'A page is already on its way to Webflow. Wait for it, then send again.',
+ );
+ const workflow = [...dialog().querySelectorAll<HTMLElement>('[role="radio"]')].find((r) =>
+ r.textContent?.startsWith('Your workflow'),
+ );
+ await act(async () => workflow!.click());
+ expect(dialog().querySelector('[role="alert"]')).toBeNull();
+ });
+
it('keeps what went when a later request is refused for the day', async () => {
oneByOne.on = true;
sendPagesToCms
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx
index 3db445900..bbb203f77 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_bulk-send-dialog.tsx
@@ -23,6 +23,7 @@ import {
type CmsSendError,
} from '@/lib/content/cms-send-client';
import type { ContentDraftListItem } from '@/lib/content/drafts';
+import { CmsTargetPicker, CmsTargetUnchecked, useCmsTarget } from '@/components/content/cms-target';
import { readCmsSources } from './_cms-sources';
/** How often the sends going on in the background are read. */
@@ -109,6 +110,18 @@ export function BulkSendDialog({
// Why a request was refused; with the page its `pages.N` named, when it named one.
const [failure, setFailure] = useState<Refusal | null>(null);
const [attempt, setAttempt] = useState(0);
+ const {
+ webflow,
+ target,
+ pick,
+ sent: keepTarget,
+ unchecked: targetUnchecked,
+ reading: targetReading,
+ retry: retryTarget,
+ } = useCmsTarget(brandId);
+ const collection = webflow?.ready
+ ? webflow.collection || tEditor('send.target.webflow.collection')
+ : '';
useEffect(() => {
let cancelled = false;
@@ -185,6 +198,7 @@ export function BulkSendDialog({
}, []);
const send = async () => {
+ if (!target) return;
setPhase({ kind: 'sending' });
setFailure(null);
const made = new Map<string, CmsDelivery>();
@@ -207,7 +221,7 @@ export function BulkSendDialog({
notSent += group.length;
continue;
}
- const result = await sendPagesToCms(brandId, group);
+ const result = await sendPagesToCms(brandId, group, target);
if (!result.ok) {
// The page a refusal names ("pages.2.html"), as the group's own.
const index = Number(/^pages\.(\d+)\./.exec(result.field ?? '')?.[1] ?? NaN);
@@ -266,6 +280,7 @@ export function BulkSendDialog({
setPhase({ kind: 'ready' });
return;
}
+ keepTarget(target);
const left = [...made.values()].some((d) => d.status === 'queued');
setPhase(
left && !waitedOut
@@ -284,6 +299,12 @@ export function BulkSendDialog({
? t('invalidPage', { title, field: named })
: tEditor('send.errors.invalidField', { field: named });
}
+ // No page named: any of them may be the one on its way.
+ if (code === 'in_progress') return t('inProgress');
+ // Webflow not ready sent the pages to the webhook: what to fix is Webflow.
+ if (code === 'no_webhook' && webflow && !webflow.ready) {
+ return tEditor('send.errors.no_webhookWebflow');
+ }
return tEditor(`send.errors.${code}`);
};
@@ -303,9 +324,35 @@ export function BulkSendDialog({
<DialogTitle>
{t('title', { count: phase.kind === 'reading' ? drafts.length : items.length })}
</DialogTitle>
- <DialogDescription>{t('description')}</DialogDescription>
+ <DialogDescription>
+ {!target
+ ? tEditor('send.descriptionReading')
+ : target === 'webflow'
+ ? t('descriptionWebflow', { collection })
+ : t('description')}
+ </DialogDescription>
</DialogHeader>
+ {/* Where the pages go, before they go: Webflow once Settings has it ready. */}
+ {webflow && target && !after && (
+ <CmsTargetPicker
+ value={target}
+ webflow={webflow}
+ disabled={phase.kind === 'sending'}
+ onChange={(next) => {
+ pick(next);
+ setFailure(null);
+ }}
+ />
+ )}
+ {targetUnchecked && !after && (
+ <CmsTargetUnchecked
+ reading={targetReading}
+ onRetry={retryTarget}
+ disabled={phase.kind === 'sending'}
+ />
+ )}
+
{phase.kind === 'reading' ? (
<div className="flex items-center justify-center py-8" aria-busy="true">
<LoadingDots size="md" className="text-muted-foreground" />
@@ -387,7 +434,7 @@ export function BulkSendDialog({
<Button variant="outline" disabled={phase.kind === 'sending'} onClick={onClose}>
{t('cancel')}
</Button>
- <Button disabled={busy || ready.length === 0} onClick={() => void send()}>
+ <Button disabled={busy || ready.length === 0 || !target} onClick={() => void send()}>
{phase.kind === 'sending' && <LoadingDots className="mr-1" />}
{phase.kind === 'sending' ? t('sending') : t('send', { count: ready.length })}
</Button>
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx
index 9a97d84ac..69f269b33 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/_library-table.tsx
@@ -293,7 +293,10 @@ function CmsStatusMark({ status }: { status: CmsStatus }) {
const format = useFormatter();
const when = format.dateTime(new Date(status.at), { dateStyle: 'medium', timeStyle: 'short' });
const live = status.status === 'published' ? status.publishedUrl : null;
- const label = t(status.status, { when });
+ // A Webflow send (#1331, phase 2) says so: sent, it's a draft item there.
+ const label = t(status.target === 'webflow' ? `webflow.${status.status}` : status.status, {
+ when,
+ });
const icon = {
queued: <Clock className="h-3.5 w-3.5" />,
sent: <Send className="h-3.5 w-3.5" />,
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx
index 4410c8826..9d4bbf624 100644
--- a/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx
+++ b/web/src/app/[locale]/(dashboard)/dashboard/content/library/page.test.tsx
@@ -55,6 +55,10 @@ vi.mock('@/lib/content/cms-send-client', () => ({
readKeptFields: vi.fn(async () => new Map()),
readDeliveries: vi.fn(async () => []),
}));
+// The brand's Webflow connection (#1331, phase 2): none here.
+vi.mock('@/lib/webflow-client', () => ({
+ readWebflow: async () => ({ ok: true, configured: false, connection: null }),
+}));
vi.mock('@/lib/actions/content-authors', () => ({ getContentAuthors: vi.fn(async () => null) }));
/** jsdom's Blob has no text(): read it as a browser's FileReader would. */
@@ -380,15 +384,19 @@ describe('Send to CMS from a Library row (#1331)', () => {
expect(document.querySelector<HTMLInputElement>('#cms-slug')!.value).toBe('pricing');
await act(async () => inDialog('Send').click());
- expect(sendPagesToCms).toHaveBeenCalledWith('brand-1', [
- expect.objectContaining({
- draftId: 'd1',
- slug: 'pricing',
- html: '<p>Teams trust it.</p>',
- // Authors come with Quality (CE-038): while it is off, none goes.
- author: null,
- }),
- ]);
+ expect(sendPagesToCms).toHaveBeenCalledWith(
+ 'brand-1',
+ [
+ expect.objectContaining({
+ draftId: 'd1',
+ slug: 'pricing',
+ html: '<p>Teams trust it.</p>',
+ // Authors come with Quality (CE-038): while it is off, none goes.
+ author: null,
+ }),
+ ],
+ 'webhook',
+ );
expect(dialog()).toBeNull();
expect(readCmsStatuses).toHaveBeenCalledTimes(2);
});
@@ -469,6 +477,29 @@ describe('Send to CMS from a Library row (#1331)', () => {
expect(marks[1].getAttribute('href')).toBe('https://acme.example/churn');
});
+ it('says a page sent to Webflow is a draft item there', async () => {
+ getContentDrafts.mockResolvedValue([row({})]);
+ readCmsStatuses.mockResolvedValue(
+ new Map([
+ [
+ 'd1',
+ {
+ status: 'sent',
+ target: 'webflow',
+ at: '2026-10-24T10:00:00Z',
+ httpStatus: null,
+ error: null,
+ publishedUrl: null,
+ },
+ ],
+ ]),
+ );
+ await renderPage();
+ expect(
+ container.querySelector('[aria-label^="In Webflow as a draft item since Oct 24, 2026"]'),
+ ).not.toBeNull();
+ });
+
it('says the workflow’s reason for a page its webhook took that then failed', async () => {
getContentDrafts.mockResolvedValue([row({})]);
readCmsStatuses.mockResolvedValue(
@@ -534,9 +565,11 @@ describe('Send to CMS from a Library row (#1331)', () => {
}),
);
await act(async () => inDialog('Send').click());
- expect(sendPagesToCms).toHaveBeenCalledWith('brand-1', [
- expect.objectContaining({ draftId: 'd1' }),
- ]);
+ expect(sendPagesToCms).toHaveBeenCalledWith(
+ 'brand-1',
+ [expect.objectContaining({ draftId: 'd1' })],
+ 'webhook',
+ );
});
it('is for admins and managers only', async () => {
diff --git a/web/src/components/content/cms-target.tsx b/web/src/components/content/cms-target.tsx
new file mode 100644
index 000000000..55af3b7fd
--- /dev/null
+++ b/web/src/components/content/cms-target.tsx
@@ -0,0 +1,210 @@
+'use client';
+
+import { useEffect, useRef, useState, type KeyboardEvent } from 'react';
+import { useTranslations } from 'next-intl';
+import { Button } from '@/components/ui/button';
+import { LoadingDots } from '@/components/ui/loading-dots';
+import { cn } from '@/lib/utils';
+import type { CmsTarget } from '@/lib/content/cms-send-client';
+import { readWebflow } from '@/lib/webflow-client';
+
+/**
+ * Where Send to CMS sends (#1331, phase 2): the brand's webhook, or its
+ * Webflow collection once Settings › Integrations has it ready (connected,
+ * a collection with a body field). The choice, picked or sent to, is
+ * remembered per brand, in this browser; Webflow is the first choice where
+ * it's ready. A brand with
+ * Webflow connected but not ready sees it, off, so its pages don't go to
+ * the webhook unnoticed. A read that fails (or an API without Webflow)
+ * leaves the webhook as it was before Webflow: a webhook send doesn't need
+ * Webflow, and a person who picked Webflow before is told it couldn't be
+ * checked.
+ */
+
+const storageKey = (brandId: string) => `aeo:cms-target:${brandId}`;
+
+function remembered(brandId: string): CmsTarget | null {
+ try {
+ const value = localStorage.getItem(storageKey(brandId));
+ return value === 'webhook' || value === 'webflow' ? value : null;
+ } catch {
+ return null;
+ }
+}
+
+function remember(brandId: string, target: CmsTarget) {
+ try {
+ localStorage.setItem(storageKey(brandId), target);
+ } catch {
+ // Private mode or blocked storage: the choice just isn't kept.
+ }
+}
+
+/** The brand's Webflow, as Send to CMS reads it. */
+export type CmsWebflow =
+ /** Ready: pages go to this collection (its name; empty when it has none). */
+ | { ready: true; collection: string }
+ /** Connected, but its token refused or no collection picked yet. */
+ | { ready: false }
+ /** Not connected, not set up on this server, or not read: the webhook only. */
+ | null;
+
+/**
+ * The brand's send target: undefined while its Webflow connection is read,
+ * then where pages go and how to change it. A failed read is the webhook;
+ * `unchecked` says so when the person picked Webflow before, with `retry`.
+ */
+export function useCmsTarget(brandId: string) {
+ const [read, setRead] = useState<{
+ key: string;
+ webflow: CmsWebflow;
+ failed: boolean;
+ } | null>(null);
+ const [attempt, setAttempt] = useState(0);
+ const [picked, setPicked] = useState<{ brandId: string; target: CmsTarget } | null>(null);
+ const key = `${brandId}:${attempt}`;
+
+ useEffect(() => {
+ let cancelled = false;
+ readWebflow(brandId).then((result) => {
+ if (cancelled) return;
+ if (!result.ok) {
+ setRead({ key, webflow: null, failed: true });
+ return;
+ }
+ const connection = result.configured ? result.connection : null;
+ const webflow: CmsWebflow = !connection
+ ? null
+ : connection.status === 'connected' && connection.collectionId && connection.fieldMap.body
+ ? { ready: true, collection: connection.collectionName ?? '' }
+ : { ready: false };
+ setRead({ key, webflow, failed: false });
+ });
+ return () => {
+ cancelled = true;
+ };
+ }, [brandId, key]);
+
+ const current = read?.key === key ? read : null;
+ const webflow = current ? current.webflow : undefined;
+ const chosen = picked?.brandId === brandId ? picked.target : remembered(brandId);
+ const target: CmsTarget | undefined =
+ webflow === undefined ? undefined : webflow?.ready ? (chosen ?? 'webflow') : 'webhook';
+ // Read again after a failure: the note stays, as trying, until the answer.
+ const failed = current
+ ? current.failed
+ : (read?.failed ?? false) && read?.key.startsWith(`${brandId}:`) === true;
+
+ return {
+ /** The brand's Webflow; undefined while read; null without one, or when it couldn't be read. */
+ webflow,
+ target,
+ /** Couldn't be read, for a person who picked Webflow before: the page goes to the webhook. */
+ unchecked: failed && chosen === 'webflow',
+ /** Reading again, after a failure. */
+ reading: current === null,
+ retry: () => setAttempt((n) => n + 1),
+ pick: (next: CmsTarget) => {
+ setPicked({ brandId, target: next });
+ remember(brandId, next);
+ },
+ /** Pages went there: the brand's choice from now on, as if picked. */
+ sent: (to: CmsTarget) => remember(brandId, to),
+ };
+}
+
+const TARGETS = ['webflow', 'webhook'] as const;
+
+/**
+ * The two targets, when the brand has Webflow: the person picks where pages
+ * go. Webflow connected but not ready shows, off, with what to do. One tab
+ * stop, the picked card; the arrow keys move to the other and pick it,
+ * past Webflow while it's off.
+ */
+export function CmsTargetPicker({
+ value,
+ webflow,
+ onChange,
+ disabled,
+}: {
+ value: CmsTarget;
+ webflow: NonNullable<CmsWebflow>;
+ onChange: (target: CmsTarget) => void;
+ disabled?: boolean;
+}) {
+ const t = useTranslations('contentEditor.editor.send.target');
+ const cards = useRef<Partial<Record<CmsTarget, HTMLButtonElement | null>>>({});
+ const off = (target: CmsTarget) => disabled || (target === 'webflow' && !webflow.ready);
+ const onKey = (event: KeyboardEvent, i: number) => {
+ const step = ({ ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 } as const)[
+ event.key as 'ArrowRight'
+ ];
+ if (!step) return;
+ event.preventDefault();
+ const next = TARGETS[(i + step + TARGETS.length) % TARGETS.length];
+ if (off(next)) return;
+ onChange(next);
+ cards.current[next]?.focus();
+ };
+ return (
+ <div role="radiogroup" aria-label={t('label')} className="grid grid-cols-2 gap-2">
+ {TARGETS.map((target, i) => (
+ <button
+ key={target}
+ ref={(el) => void (cards.current[target] = el)}
+ type="button"
+ role="radio"
+ aria-checked={value === target}
+ tabIndex={value === target ? 0 : -1}
+ disabled={off(target)}
+ onClick={() => onChange(target)}
+ onKeyDown={(event) => onKey(event, i)}
+ className={cn(
+ 'min-w-0 rounded-xl border px-3 py-2.5 text-left transition-colors hover:bg-muted/50 disabled:cursor-not-allowed disabled:opacity-60 disabled:hover:bg-transparent',
+ value === target && 'border-foreground ring-1 ring-inset ring-foreground',
+ )}
+ >
+ <span className="block text-sm font-medium">{t(`${target}.title`)}</span>
+ <span className="block text-xs text-muted-foreground [overflow-wrap:anywhere]">
+ {target === 'webhook'
+ ? t('webhook.hint')
+ : webflow.ready
+ ? t('webflow.hint', { collection: webflow.collection || t('webflow.collection') })
+ : t('webflow.notReady')}
+ </span>
+ </button>
+ ))}
+ </div>
+ );
+}
+
+/** Webflow couldn't be checked for a person who picked it before: the page goes to the webhook. */
+export function CmsTargetUnchecked({
+ reading,
+ onRetry,
+ disabled,
+}: {
+ reading: boolean;
+ onRetry: () => void;
+ /** While sending: the target is fixed until the send is over. */
+ disabled?: boolean;
+}) {
+ const t = useTranslations('contentEditor.editor.send.target');
+ return (
+ <div
+ role="status"
+ className="flex flex-wrap items-center gap-x-3 gap-y-1.5 text-sm text-muted-foreground"
+ >
+ <span className="min-w-0 flex-1">{t('unchecked')}</span>
+ <Button
+ size="sm"
+ variant="outline"
+ disabled={reading || disabled}
+ aria-label={t('retry')}
+ onClick={onRetry}
+ >
+ {reading ? <LoadingDots /> : t('retry')}
+ </Button>
+ </div>
+ );
+}
diff --git a/web/src/components/content/send-to-cms-dialog.test.tsx b/web/src/components/content/send-to-cms-dialog.test.tsx
index 0a6cb3e10..06cde4712 100644
--- a/web/src/components/content/send-to-cms-dialog.test.tsx
+++ b/web/src/components/content/send-to-cms-dialog.test.tsx
@@ -11,6 +11,9 @@ vi.mock('sonner', () => ({ toast }));
const readDraftCms = vi.hoisted(() => vi.fn());
const sendPagesToCms = vi.hoisted(() => vi.fn());
vi.mock('@/lib/content/cms-send-client', () => ({ readDraftCms, sendPagesToCms }));
+// The brand's Webflow connection (#1331, phase 2): none unless a test gives one.
+const readWebflow = vi.hoisted(() => vi.fn());
+vi.mock('@/lib/webflow-client', () => ({ readWebflow }));
const { SendDialog } = await import('./send-to-cms-dialog');
@@ -71,6 +74,15 @@ beforeEach(() => {
onClose.mockReset();
toast.success.mockReset();
readDraftCms.mockReset().mockResolvedValue(neverSent);
+ readWebflow.mockReset().mockResolvedValue({ ok: true, configured: false, connection: null });
+ // The send target remembered per brand, in this browser.
+ const kept = new Map<string, string>();
+ vi.stubGlobal('localStorage', {
+ getItem: (key: string) => kept.get(key) ?? null,
+ setItem: (key: string, value: string) => void kept.set(key, value),
+ removeItem: (key: string) => void kept.delete(key),
+ clear: () => kept.clear(),
+ });
sendPagesToCms.mockReset().mockResolvedValue({
ok: true,
deliveries: [{ id: 'x1', draftId: 'd1', status: 'sent' }],
@@ -82,6 +94,7 @@ beforeEach(() => {
afterEach(() => {
act(() => root.unmount());
container.remove();
+ vi.unstubAllGlobals();
});
describe('SendDialog', () => {
@@ -94,19 +107,23 @@ describe('SendDialog', () => {
expect(dialog().textContent).toContain('15 characters');
await act(async () => button('Send').click());
- expect(sendPagesToCms).toHaveBeenCalledWith('brand-1', [
- {
- draftId: 'd1',
- title: 'Pour-over',
- slug: 'pour-over',
- metaTitle: 'Pour-over',
- metaDescription: 'Brew it slowly.',
- // The brand's byline line stays; the CMS's title field carries the H1.
- html: '<p>By Ada Lovelace</p>\n<p>Brew it slowly.</p>',
- author: 'Ada Lovelace',
- featuredImage: null,
- },
- ]);
+ expect(sendPagesToCms).toHaveBeenCalledWith(
+ 'brand-1',
+ [
+ {
+ draftId: 'd1',
+ title: 'Pour-over',
+ slug: 'pour-over',
+ metaTitle: 'Pour-over',
+ metaDescription: 'Brew it slowly.',
+ // The brand's byline line stays; the CMS's title field carries the H1.
+ html: '<p>By Ada Lovelace</p>\n<p>Brew it slowly.</p>',
+ author: 'Ada Lovelace',
+ featuredImage: null,
+ },
+ ],
+ 'webhook',
+ );
expect(toast.success).toHaveBeenCalledWith('Sent to your CMS');
expect(onClose).toHaveBeenCalled();
});
@@ -278,4 +295,208 @@ describe('SendDialog', () => {
expect(onClose).not.toHaveBeenCalled();
expect(toast.success).not.toHaveBeenCalled();
});
+
+ describe('to Webflow (#1331, phase 2)', () => {
+ const ready = {
+ ok: true,
+ configured: true,
+ connection: {
+ status: 'connected',
+ siteId: 's1',
+ siteName: 'Acme',
+ collectionId: 'c1',
+ collectionName: 'Blog Posts',
+ fieldMap: { body: 'post-body' },
+ connectedAt: '2026-10-25T10:00:00Z',
+ updatedAt: '2026-10-25T10:00:00Z',
+ },
+ };
+ const radio = (name: string) =>
+ [...dialog().querySelectorAll<HTMLButtonElement>('[role="radio"]')].find((r) =>
+ r.textContent?.startsWith(name),
+ );
+
+ it('offers no choice to a brand without Webflow', async () => {
+ await render();
+ expect(radio('Webflow')).toBeUndefined();
+ expect(dialog().textContent).toContain("The page goes to the brand's webhook");
+ });
+
+ it('shows Webflow connected but not ready, off, so the webhook isn’t picked unnoticed', async () => {
+ localStorage.setItem('aeo:cms-target:brand-1', 'webflow');
+ readWebflow.mockResolvedValue({
+ ...ready,
+ connection: { ...ready.connection, status: 'auth_failed' },
+ });
+ await render();
+ expect(radio('Webflow')!.disabled).toBe(true);
+ expect(radio('Webflow')!.textContent).toContain('Not ready');
+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');
+ await act(async () => button('Send').click());
+ expect(sendPagesToCms).toHaveBeenLastCalledWith('brand-1', expect.any(Array), 'webhook');
+ });
+
+ it('sends nothing while it reads where pages go', async () => {
+ readWebflow.mockReturnValue(new Promise(() => {}));
+ await render();
+ expect(button('Send').disabled).toBe(true);
+ expect(dialog().textContent).toContain('The page goes to your CMS with its slug and meta');
+ });
+
+ it('sends to the webhook when Webflow can’t be read, as before Webflow', async () => {
+ readWebflow.mockResolvedValue({ ok: false, code: 'failed' });
+ await render();
+ expect(radio('Webflow')).toBeUndefined();
+ expect(dialog().querySelector('[role="status"]')).toBeNull();
+ expect(button('Send').disabled).toBe(false);
+ await act(async () => button('Send').click());
+ expect(sendPagesToCms).toHaveBeenLastCalledWith('brand-1', expect.any(Array), 'webhook');
+ });
+
+ it('says Webflow couldn’t be checked to a person who picked it, and reads again', async () => {
+ localStorage.setItem('aeo:cms-target:brand-1', 'webflow');
+ readWebflow.mockResolvedValueOnce({ ok: false, code: 'failed' }).mockResolvedValue(ready);
+ await render();
+ expect(dialog().querySelector('[role="status"]')!.textContent).toContain(
+ "Couldn't check Webflow just now, so this send goes to your workflow.",
+ );
+ expect(button('Send').disabled).toBe(false);
+ await act(async () => button('Try again').click());
+ expect(readWebflow).toHaveBeenCalledTimes(2);
+ expect(radio('Webflow')!.getAttribute('aria-checked')).toBe('true');
+ expect(dialog().querySelector('[role="status"]')).toBeNull();
+ });
+
+ it('says Webflow isn’t ready when the brand has no webhook either', async () => {
+ readWebflow.mockResolvedValue({
+ ...ready,
+ connection: { ...ready.connection, status: 'auth_failed' },
+ });
+ sendPagesToCms.mockResolvedValue({ ok: false, code: 'no_webhook', field: null });
+ await render();
+ await act(async () => button('Send').click());
+ expect(alert()).toBe(
+ "This brand's Webflow isn't ready, and it has no webhook. Connect Webflow again or pick its collection in Settings › Integrations.",
+ );
+ });
+
+ it('moves between the two with the arrow keys, past Webflow while it’s off', async () => {
+ readWebflow.mockResolvedValue(ready);
+ await render();
+ expect(radio('Webflow')!.tabIndex).toBe(0);
+ expect(radio('Your workflow')!.tabIndex).toBe(-1);
+ // The dialog puts focus in itself first, a moment after it opens.
+ await vi.waitFor(() => expect(dialog().contains(document.activeElement)).toBe(true));
+ await act(async () => {
+ radio('Webflow')!.dispatchEvent(
+ new KeyboardEvent('keydown', { key: 'ArrowRight', bubbles: true }),
+ );
+ });
+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');
+ expect(document.activeElement).toBe(radio('Your workflow'));
+ expect(localStorage.getItem('aeo:cms-target:brand-1')).toBe('webhook');
+
+ act(() => root.unmount());
+ root = createRoot(container);
+ readWebflow.mockResolvedValue({
+ ...ready,
+ connection: { ...ready.connection, status: 'auth_failed' },
+ });
+ await render();
+ await act(async () => {
+ radio('Your workflow')!.dispatchEvent(
+ new KeyboardEvent('keydown', { key: 'ArrowLeft', bubbles: true }),
+ );
+ });
+ // Webflow, off, isn't picked: the brand's choice stays.
+ expect(localStorage.getItem('aeo:cms-target:brand-1')).toBe('webhook');
+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');
+ });
+
+ it('starts from the brand’s remembered choice', async () => {
+ localStorage.setItem('aeo:cms-target:brand-1', 'webhook');
+ readWebflow.mockResolvedValue(ready);
+ await render();
+ expect(radio('Your workflow')!.getAttribute('aria-checked')).toBe('true');
+ });
+
+ it('says the last send went to Webflow', async () => {
+ readWebflow.mockResolvedValue(ready);
+ readDraftCms.mockResolvedValue({
+ ...neverSent,
+ last: { status: 'sent', target: 'webflow', at: '2026-10-24T10:00:00Z', error: null },
+ });
+ await render();
+ expect(dialog().textContent).toContain('In Webflow as a draft item since Oct 24, 2026');
+ });
+
+ it('sends to the Webflow collection first, saying what changed on the way', async () => {
+ readWebflow.mockResolvedValue(ready);
+ sendPagesToCms.mockResolvedValue({
+ ok: true,
+ deliveries: [
+ {
+ id: 'x1',
+ draftId: 'd1',
+ status: 'sent',
+ updated: false,
+ changed: { tables: 2, images: 1 },
+ },
+ ],
+ });
+ await render();
+ expect(radio('Webflow')!.getAttribute('aria-checked')).toBe('true');
+ expect(radio('Webflow')!.textContent).toContain('A draft item in Blog Posts');
+ expect(dialog().textContent).toContain(
+ 'The page goes to Blog Posts in Webflow as a draft item',
+ );
+ await act(async () => button('Send').click());
+ expect(sendPagesToCms).toHaveBeenCalledWith('brand-1', expect.any(Array), 'webflow');
+ // Sent there: the brand's choice, so a failed read later says so.
+ expect(localStorage.getItem('aeo:cms-target:brand-1')).toBe('webflow');
+ expect(toast.success).toHaveBeenCalledWith('Sent to Webflow as a draft item', {
+ description: "2 tables went as lists. 1 image wasn't sent: add it in Webflow.",
+ });
+ });
+
+ it('sends to the webhook when picked, and remembers it for the brand', async () => {
+ readWebflow.mockResolvedValue(ready);
+ await render();
+ await act(async () => radio('Your workflow')!.click());
+ await act(async () => button('Send').click());
+ expect(sendPagesToCms).toHaveBeenLastCalledWith('brand-1', expect.any(Array), 'webhook');
+ expect(localStorage.getItem('aeo:cms-target:brand-1')).toBe('webhook');
+ });
+
+ it('says when Webflow updated the item, or why it didn’t take the page', async () => {
+ readWebflow.mockResolvedValue(ready);
+ sendPagesToCms.mockResolvedValueOnce({
+ ok: true,
+ deliveries: [{ id: 'x1', draftId: 'd1', status: 'sent', updated: true }],
+ });
+ await render();
+ await act(async () => button('Send').click());
+ expect(toast.success).toHaveBeenCalledWith('Updated in Webflow', { description: undefined });
+
+ sendPagesToCms.mockResolvedValueOnce({
+ ok: true,
+ deliveries: [
+ {
+ id: 'x2',
+ draftId: 'd1',
+ status: 'failed',
+ error: 'Another Webflow item has this slug.',
+ },
+ ],
+ });
+ await act(async () => button('Send').click());
+ expect(alert()).toBe("Webflow didn't take the page: Another Webflow item has this slug.");
+
+ sendPagesToCms.mockResolvedValueOnce({ ok: false, code: 'in_progress', field: null });
+ await act(async () => button('Send').click());
+ expect(alert()).toBe(
+ 'This page is already on its way to Webflow. Wait for it, then send again.',
+ );
+ });
+ });
});
diff --git a/web/src/components/content/send-to-cms-dialog.tsx b/web/src/components/content/send-to-cms-dialog.tsx
index 6c7389a7c..166b210e6 100644
--- a/web/src/components/content/send-to-cms-dialog.tsx
+++ b/web/src/components/content/send-to-cms-dialog.tsx
@@ -34,10 +34,12 @@ import {
type DraftCms,
} from '@/lib/content/cms-send-client';
import { exportPlaceholders, pageFields, titlePlaceholders } from '@/lib/content/ready-to-publish';
+import { CmsTargetPicker, CmsTargetUnchecked, useCmsTarget } from './cms-target';
/**
* Send to CMS (#1331): the page to the brand's webhook, for the workspace's
- * CMS or automation to publish. Its slug and meta are filled from the page,
+ * CMS or automation to publish, or to its Webflow collection as a draft item
+ * (phase 2, when Settings has Webflow ready). Its slug and meta are filled from the page,
* or what the draft kept, and editable; they stay on the draft. The page
* goes as Export makes it ready (CE-057): no placeholder goes, so they are
* filled first. From the editor's header and a Library row; rendered only
@@ -93,8 +95,21 @@ export function SendDialog({
const touched = useRef(new Set<keyof CmsFields>());
const [sending, setSending] = useState(false);
const [problem, setProblem] = useState<
- { code: CmsSendError; field: string | null } | { status: number } | { failed: string } | null
+ | { code: CmsSendError; field: string | null }
+ | { status: number }
+ | { failed: string; webflow: boolean }
+ | null
>(null);
+ const {
+ webflow,
+ target,
+ pick,
+ sent: keepTarget,
+ unchecked: targetUnchecked,
+ reading: targetReading,
+ retry: retryTarget,
+ } = useCmsTarget(brandId);
+ const collection = webflow?.ready ? webflow.collection || t('target.webflow.collection') : '';
useEffect(() => {
let cancelled = false;
@@ -137,11 +152,14 @@ export function SendDialog({
const slugWrong = wrong === 'slug' && !slugEmpty;
const send = async () => {
+ if (!target) return;
setSending(true);
setProblem(null);
- const result = await sendPagesToCms(brandId, [
- cmsPage({ draftId, title, html, fields, page, byline }),
- ]);
+ const result = await sendPagesToCms(
+ brandId,
+ [cmsPage({ draftId, title, html, fields, page, byline })],
+ target,
+ );
setSending(false);
if (!result.ok) {
setProblem({ code: result.code, field: result.field });
@@ -157,19 +175,37 @@ export function SendDialog({
setProblem(
refused
? { status: delivery.http_status! }
- : { failed: delivery.error ?? t('errors.failed') },
+ : { failed: delivery.error ?? t('errors.failed'), webflow: target === 'webflow' },
);
return;
}
- toast.success(t('sent'));
+ keepTarget(target);
+ if (target === 'webflow') {
+ // What of the page Webflow's rich text couldn't keep: tables went as lists, images not yet.
+ const changed = delivery?.changed;
+ toast.success(delivery?.updated ? t('sentWebflowUpdated') : t('sentWebflow'), {
+ description:
+ changed && (changed.tables || changed.images)
+ ? t('webflowChanged', { tables: changed.tables, images: changed.images })
+ : undefined,
+ });
+ } else {
+ toast.success(t('sent'));
+ }
onClose();
};
const problemText = (shown: NonNullable<typeof problem>) => {
if ('status' in shown) return t('errors.webhookStatus', { status: shown.status });
- if ('failed' in shown) return t('errors.webhookFailed', { reason: shown.failed });
+ if ('failed' in shown) {
+ return t(shown.webflow ? 'errors.webflowFailed' : 'errors.webhookFailed', {
+ reason: shown.failed,
+ });
+ }
const { code, field } = shown;
if (code === 'session' || code === 'workspace' || code === 'busy') return tFailure(code);
+ // Webflow not ready sent the page to the webhook: what to fix is Webflow.
+ if (code === 'no_webhook' && webflow && !webflow.ready) return t('errors.no_webhookWebflow');
// The server names the path ("pages.0.slug"); the field is its last part.
if (code === 'invalid' && field) {
return t('errors.invalidField', { field: field.split('.').pop() ?? 'other' });
@@ -185,9 +221,30 @@ export function SendDialog({
<DialogContent className="max-h-[calc(100dvh-2rem)] overflow-y-auto sm:max-w-lg">
<DialogHeader>
<DialogTitle>{t('title')}</DialogTitle>
- <DialogDescription>{t('description')}</DialogDescription>
+ <DialogDescription>
+ {!target
+ ? t('descriptionReading')
+ : target === 'webflow'
+ ? t('descriptionWebflow', { collection })
+ : t('description')}
+ </DialogDescription>
</DialogHeader>
+ {webflow && target && (
+ <CmsTargetPicker
+ value={target}
+ webflow={webflow}
+ disabled={sending}
+ onChange={(next) => {
+ pick(next);
+ setProblem(null);
+ }}
+ />
+ )}
+ {targetUnchecked && (
+ <CmsTargetUnchecked reading={targetReading} onRetry={retryTarget} disabled={sending} />
+ )}
+
{pageProblem && (
<div className="flex items-center gap-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-200">
<AlertTriangle className="h-4 w-4 shrink-0 text-amber-600 dark:text-amber-500" />
@@ -275,7 +332,7 @@ export function SendDialog({
</>
) : (
last &&
- t(`last.${last.status}`, {
+ t(last.target === 'webflow' ? `lastWebflow.${last.status}` : `last.${last.status}`, {
when: format.dateTime(new Date(last.at), {
dateStyle: 'medium',
timeStyle: 'short',
@@ -321,7 +378,12 @@ export function SendDialog({
</Button>
<Button
disabled={
- sending || pageProblem !== null || placeholders > 0 || wrong !== null || !kept
+ sending ||
+ pageProblem !== null ||
+ placeholders > 0 ||
+ wrong !== null ||
+ !kept ||
+ !target
}
onClick={() => void send()}
>
diff --git a/web/src/lib/content/cms-send-client.test.ts b/web/src/lib/content/cms-send-client.test.ts
index bd0a80bd8..bd15b09ba 100644
--- a/web/src/lib/content/cms-send-client.test.ts
+++ b/web/src/lib/content/cms-send-client.test.ts
@@ -78,7 +78,7 @@ describe('sendPagesToCms', () => {
expect(fetchMock).toHaveBeenCalledWith('/api/aeo/api/content-drafts/send', {
method: 'POST',
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer token-1' },
- body: JSON.stringify({ brandId: 'brand-1', pages: [page] }),
+ body: JSON.stringify({ brandId: 'brand-1', pages: [page], target: 'webhook' }),
});
expect(result).toEqual({
ok: true,
@@ -88,6 +88,13 @@ describe('sendPagesToCms', () => {
// Past the workspace's sends for the day: the pages left over.
answer(200, { deliveries: [{ id: 'x2', draftId: 'd1', status: 'queued' }], skipped: 3 });
expect(await sendPagesToCms('brand-1', [page])).toMatchObject({ ok: true, skipped: 3 });
+ // To the brand's Webflow collection (#1331, phase 2).
+ answer(200, { deliveries: [{ id: 'x3', draftId: 'd1', status: 'sent', updated: true }] });
+ expect(await sendPagesToCms('brand-1', [page], 'webflow')).toMatchObject({
+ ok: true,
+ deliveries: [{ updated: true }],
+ });
+ expect(JSON.parse(fetchMock.mock.calls.at(-1)![1].body)).toMatchObject({ target: 'webflow' });
});
it('gives the server’s reason, and the field a 400 names', async () => {
@@ -103,6 +110,16 @@ describe('sendPagesToCms', () => {
code: 'invalid',
field: 'pages.0.slug',
});
+ for (const code of [
+ 'webflow_not_configured',
+ 'no_webflow',
+ 'webflow_refused',
+ 'webflow_not_ready',
+ 'in_progress',
+ ]) {
+ answer(409, { code });
+ expect(await sendPagesToCms('brand-1', [page], 'webflow')).toMatchObject({ ok: false, code });
+ }
});
it('says when a request was more than the API’s proxy takes', async () => {
@@ -171,7 +188,7 @@ describe('readDraftCms', () => {
expect(await readDraftCms('d1')).toEqual({
fields: { slug: 'coffee', metaTitle: undefined, metaDescription: 'Slowly.' },
publishedUrl: 'https://example.com/coffee',
- last: { status: 'sent', at: '2026-10-24T10:00:02Z', error: null },
+ last: { status: 'sent', target: 'webhook', at: '2026-10-24T10:00:02Z', error: null },
});
expect(filters).toEqual([
['content_drafts', 'id', 'd1'],
@@ -258,6 +275,7 @@ describe('readCmsStatuses', () => {
'd1',
{
status: 'published',
+ target: 'webhook',
at: '2026-10-24T12:00:00Z',
httpStatus: 200,
error: null,
@@ -268,6 +286,7 @@ describe('readCmsStatuses', () => {
'd520',
{
status: 'failed',
+ target: 'webhook',
at: '2026-10-24T09:00:00Z',
httpStatus: null,
error: 'Not reached',
@@ -290,6 +309,19 @@ describe('readCmsStatuses', () => {
expect(statuses.get('d2')).toMatchObject({ status: 'queued', error: null });
});
+ it('says which sends went to Webflow', async () => {
+ statusReads = [
+ {
+ data: [delivery('d1', 'sent', '2026-10-24T10:00:00Z', { target: 'webflow' })],
+ error: null,
+ },
+ ];
+ expect((await readCmsStatuses(['d1'])).get('d1')).toMatchObject({
+ status: 'sent',
+ target: 'webflow',
+ });
+ });
+
it('leaves a read that fails with no sends, as before its table is there', async () => {
statusReads = [{ data: null, error: { message: 'relation does not exist' } }];
expect((await readCmsStatuses(['d1'])).size).toBe(0);
diff --git a/web/src/lib/content/cms-send-client.ts b/web/src/lib/content/cms-send-client.ts
index 5eac17a81..ba00a6b4c 100644
--- a/web/src/lib/content/cms-send-client.ts
+++ b/web/src/lib/content/cms-send-client.ts
@@ -9,10 +9,20 @@ import type { CmsFields, CmsPage } from '@/lib/content/cms-send';
* which Next runs one at a time, behind the editor's own.
*/
+/** Where pages go: the brand's webhook (phase 1) or its Webflow collection (phase 2). */
+export type CmsTarget = 'webhook' | 'webflow';
+
/** Why a send didn't go, as the server names it. */
export type CmsSendError =
| 'no_webhook'
| 'webhook_not_subscribed'
+ // Webflow (00283, 00284): not on this server, not connected, its token
+ // refused, no collection picked, or the page already on its way.
+ | 'webflow_not_configured'
+ | 'no_webflow'
+ | 'webflow_refused'
+ | 'webflow_not_ready'
+ | 'in_progress'
| 'daily_limit'
| 'forbidden'
| 'not_found'
@@ -33,6 +43,9 @@ export interface CmsDelivery {
http_status?: number | null;
/** Why it failed, as the server wrote it ("The webhook could not be reached"). */
error?: string | null;
+ /** Webflow, one page: its item updated (not made), and what of the page changed on the way. */
+ updated?: boolean;
+ changed?: { tables: number; images: number };
}
export type CmsSendResult =
@@ -44,6 +57,11 @@ export type CmsSendResult =
const KNOWN: readonly CmsSendError[] = [
'no_webhook',
'webhook_not_subscribed',
+ 'webflow_not_configured',
+ 'no_webflow',
+ 'webflow_refused',
+ 'webflow_not_ready',
+ 'in_progress',
'daily_limit',
'forbidden',
'not_found',
@@ -53,8 +71,15 @@ const KNOWN: readonly CmsSendError[] = [
/** The reasons any call can fail for, as the other calls read them (BUG-001). */
const GENERAL: readonly CmsSendError[] = ['session', 'workspace', 'busy'];
-/** Sends pages of one brand to its webhook: one is sent before this answers, more go on. */
-export async function sendPagesToCms(brandId: string, pages: CmsPage[]): Promise<CmsSendResult> {
+/**
+ * Sends pages of one brand to its webhook, or its Webflow collection: one is
+ * sent before this answers, more go on.
+ */
+export async function sendPagesToCms(
+ brandId: string,
+ pages: CmsPage[],
+ target: CmsTarget = 'webhook',
+): Promise<CmsSendResult> {
try {
const {
data: { session },
@@ -66,7 +91,7 @@ export async function sendPagesToCms(brandId: string, pages: CmsPage[]): Promise
'Content-Type': 'application/json',
Authorization: `Bearer ${session.access_token}`,
},
- body: JSON.stringify({ brandId, pages }),
+ body: JSON.stringify({ brandId, pages, target }),
});
const body = (await res.json().catch(() => ({}))) as {
code?: string;
@@ -91,6 +116,8 @@ export async function sendPagesToCms(brandId: string, pages: CmsPage[]): Promise
/** A draft's last send, as the Library shows it beside its status. */
export interface CmsStatus {
status: CmsDelivery['status'];
+ /** Where it went: the webhook, or Webflow (a draft item there once sent). */
+ target: CmsTarget;
/** When it was published, sent or queued. */
at: string;
/** What the webhook answered, when it did; else why it wasn't reached. */
@@ -117,11 +144,13 @@ function lastSend(row: {
sent_at: string | null;
published_at: string | null;
error: string | null;
-}): { status: CmsDelivery['status']; at: string; error: string | null } {
+ target?: string | null;
+}): { status: CmsDelivery['status']; target: CmsTarget; at: string; error: string | null } {
const interrupted =
row.status === 'queued' && Date.parse(row.created_at) < Date.now() - INTERRUPTED_AFTER_MS;
return {
status: interrupted ? 'failed' : (row.status as CmsDelivery['status']),
+ target: row.target === 'webflow' ? 'webflow' : 'webhook',
at: row.published_at ?? row.sent_at ?? row.created_at,
error: interrupted ? 'Not sent: interrupted' : row.error,
};
@@ -163,7 +192,12 @@ export async function readCmsStatuses(draftIds: string[]): Promise<Map<string, C
export interface DraftCms {
fields: Partial<CmsFields>;
publishedUrl: string | null;
- last: { status: CmsDelivery['status']; at: string; error: string | null } | null;
+ last: {
+ status: CmsDelivery['status'];
+ target: CmsTarget;
+ at: string;
+ error: string | null;
+ } | null;
}
/**
@@ -181,7 +215,7 @@ export async function readDraftCms(draftId: string): Promise<DraftCms | null> {
.maybeSingle(),
supabase
.from('content_draft_deliveries')
- .select('status, created_at, sent_at, published_at, error')
+ .select('status, created_at, sent_at, published_at, error, target')
.eq('draft_id', draftId)
.order('created_at', { ascending: false })
.limit(1)
diff --git a/web/src/types/supabase.ts b/web/src/types/supabase.ts
index 3910f247b..b16859a89 100644
--- a/web/src/types/supabase.ts
+++ b/web/src/types/supabase.ts
@@ -1580,6 +1580,8 @@ export type Database = {
sent_by: string | null
slug: string | null
status: string
+ target: string
+ target_collection: string | null
title: string
}
Insert: {
@@ -1599,6 +1601,8 @@ export type Database = {
sent_by?: string | null
slug?: string | null
status?: string
+ target?: string
+ target_collection?: string | null
title: string
}
Update: {
@@ -1618,6 +1622,8 @@ export type Database = {
sent_by?: string | null
slug?: string | null
status?: string
+ target?: string
+ target_collection?: string | null
title?: string
}
Relationships: [
@@ -4693,6 +4699,8 @@ export type Database = {
sent_by: string | null
slug: string | null
status: string
+ target: string
+ target_collection: string | null
title: string
}[]
SetofOptions: {