Stage 3 — Publish Loop
How the publish loop watches for approval replies, fires the CMS webhook, and closes the loop with the final URL.
How the Publish Loop Runs
Stage 3 runs every 15 minutes, quietly polling your inbox over IMAP for replies to the draft emails sent in Stage 2. When it finds a reply containing "approved" (case-insensitive, any phrasing — "approved!", "looks great — approved", "approved, please publish"), it matches the reply's message-id back to the sheet row using the draft_message_id column, pulls the stored article content out of your knowledge base, and fires the publish webhook at your CMS. On successful publish, the sheet row's draft_status flips to published and the publish_url column gets populated with the live URL. If the publish webhook fails (CMS down, auth token expired, bad payload), the row's draft_status flips to failed and you get a diagnostic in Telegram.
The publisher reads approval replies — it does not send anything. Your AI employee's email-sending tools are separate from this; Stage 3 is purely a listener on your inbox using the email credentials you already configured for the Email Management features.
How Replies Match to Rows
Every draft email that Stage 2 sends has a unique Message-ID. When Stage 2 records the sheet row as draft_status=sent, it also writes the Message-ID into the draft_message_id column. When Stage 3 finds an "approved" reply in your inbox, the reply's In-Reply-To header points back to the original draft's Message-ID, which the publisher uses as a lookup key against the draft_message_id column. This is why you should reply to the draft email rather than composing a fresh email — a fresh email has no In-Reply-To header and the publisher cannot match it to a row.
What Actually Gets Published
The publisher publishes the final approved version of the article — the one in the Google Doc you just approved. The draft content is stored in your knowledge base keyed by the row ID at the moment Stage 2 finishes, so even if you iterated on the draft over email, the version that ships is whatever was in the Doc at approval time. The publish payload includes the article body (as structured sections with headings, paragraphs, lists, and the embedded hero image), the title, the slug, the keyword, the meta description derived from the first paragraph, and any tags configured on the row. Different CMSes expect different field names — the CMS-specific adapter handles the translation.
Approving and publishing in one reply
Close the loop on a draft.
No Reply, No Alarm
If you leave a draft sitting in your inbox for a day or a week without replying, the publisher does not escalate, resend, or nudge you. Drafts that are not approved simply stay in the sheet at draft_status=sent indefinitely. This is deliberate — you may be intentionally holding off on publishing (review cycle, internal feedback, change of plans), and automatic reminders would undermine the calm cadence the pipeline is designed for. If you want a nudge, ask your AI employee explicitly ("remind me about any draft emails I haven't replied to in a week").