Lubili
Client work

atom, a publishing and audience automation platform

A client’s publishing and audience work outgrew a hosted automation tool. Lubili designed and delivered atom: one custom platform that publishes from Google Drive to Instagram, YouTube, LinkedIn and X, turns Instagram comments into private conversations and delivered resources, and can be operated by an AI assistant over MCP. It is live in production, serving an active user base.

Built by Lubili
Type
Custom publishing and Instagram automation platform with an MCP server
Role
Architecture, engineering and delivery of the full system for a client
Stack
Cloudflare Workers, D1, Queues and KV, TypeScript, Hono, Zod, Next.js (static export), Tailwind CSS, WebAuthn passkeys, OAuth 2.1 and MCP, Google Drive API, YouTube Data API, Instagram Graph API, messaging and webhooks, Vitest
atom overviewFiles in Google Drive are reviewed and approved by a person, either in the dashboard or through an AI assistant over MCP. Approved items are scheduled by a cloud scheduler and published to YouTube as videos and Shorts, to Instagram as Reels and Stories, and to LinkedIn and X. Separately, a keyword comment on an Instagram Reel is matched to a workflow, answered with a public reply and a private message, passes an optional follow check, and ends with a Google Drive file delivered in a direct message.DashboardReview, approveAI assistantOver MCPapprovesdrafts, schedulesGoogle DriveYour foldersReviewa person approvesSchedulecloud schedulerYouTubeVideos and ShortsInstagramReels and StoriesLinkedInCompany PageXPostsCOMMENT TO DMCommentOn a ReelMatchkeyword, ReelReply, DMpublic, privateFollow checkoptionalDelivered fileDrive link in a DM
Files in Drive become scheduled posts, and Instagram comments become private conversations. A person or an AI assistant stays in control.Scroll sideways or pinch to zoom

Context

The problem: a hosted automation tool was no longer enough

The client publishes short video to Instagram and YouTube from files kept in Google Drive. The workflow ran on a hosted automation tool, and its plan no longer fit the volume. LinkedIn and X were added later.

The same audience also asks for things in the comments: a guide, a link, a file. Answering each person by hand is slow, easy to miss and impossible to keep up at volume, and a hosted tool that only sends a reply does not follow the platform’s messaging rules, avoid duplicates or keep a person in control.

Publishing to two platforms is more than moving a file. Each has its own upload rules, quotas, scheduling model and ways to fail halfway. The client needed posts to go out on time without a computer switched on, comments answered once and on time, a person in control of what goes live and what is sent, and a clear record of what happened.

Why a custom platform

A general automation tool is built to connect steps. Scheduling, the state of each post, platform quotas and recovery after a half-finished publish are left to the workflow.

Owning that logic meant limits could come from the platforms’ own rules instead of a plan tier, and controls the client needed, such as an approval step and an AI assistant interface, could be built in.

One system owns both jobs because publishing and comment-to-DM depend on the same Instagram connection, the same limits, the same approval and the same audit trail.

Lubili’s role

Lubili designed, engineered and delivered atom for the client: the architecture, the scheduler and publishing engine, the Google Drive, YouTube, Instagram, LinkedIn and X integrations, the comment-to-DM engine and its messaging rules, the dashboard, the MCP server, security, and the automated test suite.

The system runs in production on serverless infrastructure and is operated through a dashboard and, optionally, an AI assistant.

What we built

Inside atom: publishing to four channels and comment-to-DM on Instagram

  • Google Drive media library

    Connects through OAuth and syncs from Drive’s change feed, including folders backed up with Drive for desktop. New files arrive as “in review”, duplicates are linked, and files are checked for completeness before they can be approved. Drive access is read-only: atom never changes, moves or deletes a file.

  • Drafts and composer

    Instagram Reels and Stories, YouTube videos and Shorts, LinkedIn Company Page posts and X posts, with captions, titles, tags, privacy and thumbnails where a platform has them. Fields are validated against each platform’s rules before anything is submitted, and a draft can be saved, scheduled or published now.

  • A cloud scheduler

    A one-minute cron claims due jobs, hands them to a queue and sweeps for overdue or stuck work, so posts go out with every device switched off. A global pause switch and a dry-run mode stop or rehearse everything without losing a job.

  • YouTube publishing

    Resumable uploads streamed from Drive in windows, with the confirmed offset saved so an interrupted upload resumes instead of restarting. Privacy is always set explicitly, scheduling uses YouTube’s own publish time, and upload, processing and visibility are tracked separately.

  • Instagram publishing

    Creates a Reel or Story container, waits for Meta to finish processing, then publishes exactly once. If the outcome is ever unclear, atom asks Meta what happened instead of sending the request again. The video reaches Meta through a short-lived, single-use link or a resumable upload.

  • LinkedIn and X publishing

    Posts to a LinkedIn Company Page (text up to 3,000 characters, with the video) and to X (text only, one video, or up to four images) are published by atom. They can be scheduled or published now, use the same approval step as the other platforms, and are checked against each platform’s limits before they are submitted.

  • Comment-to-DM automations

    Someone comments a keyword on a Reel, and atom replies in public, sends a private message and delivers a Google Drive file. Workflows are unlimited, each is tied to one or more Reels, with trigger keywords, several public-reply variations, the message texts and the file link. They can be draft, active, paused or archived, cloned and restored, and deleting one keeps its history.

  • Follow gate

    A workflow can require the person to follow the account first, using Instagram’s own follow status. It is on by default for new workflows. An unknown answer is never treated as yes or no, so nobody is wrongly told to follow, and nobody gets the file by mistake.

  • Delivery limits

    One private reply per comment and one file per conversation. A per-person cap (3 by default) stops anyone being sent the same file again and again, and a person who reaches it gets a short message instead. Sending is paced, with back-off when the platform asks for it.

  • Messaging rules built in

    The private-reply window of 7 days and the 24-hour window after a person responds are checked in one place before every send, and are never stretched. A duplicate webhook cannot produce a second reply or a second file.

  • Testing and analytics

    A dry run exercises a workflow without sending anything. Statistics are shown per workflow and date range, and “submitted” is kept apart from “delivered”. A setup screen lists what is connected and permitted, and claims nothing it cannot verify.

  • Quota awareness

    YouTube’s upload allowance is counted and checked, and Instagram’s publishing limit is read from Meta, not hard-coded. A job that would exceed a limit is deferred and resumes by itself when capacity returns, so it is never lost or failed.

  • Dashboard

    Connections for each account, a schedule with a live execution log for every job, what is currently live on each platform, usage and quotas, and system health. It works on a phone.

  • MCP server

    A remote MCP server with OAuth 2.1 and four scopes (read, draft, schedule, publish) exposes 19 tools for publishing and a further 20 for automations, so an AI assistant can find files, prepare drafts, schedule posts, check results, and create, test, activate or pause a comment-to-DM workflow. It calls the same services as the dashboard, so both behave identically.

  • Security and access

    Passkeys, owner-only Google sign-in and single-use recovery codes. Platform tokens are encrypted at rest with AES-256-GCM, every API route denies by default, and security-relevant actions go to a separate audit log.

Engineering

Key decisions

  1. The database is the truth, the queue only delivers.

    Every state change and its dispatch request are written in one transaction, and the queue is treated as at-least-once. A duplicate delivery finds a newer version or a held lease and does nothing, so a retry cannot publish twice.

  2. Reconcile, never repeat.

    After any request that may have succeeded, such as a timeout during publish, atom checks what the platform recorded before it acts again. A post that cannot be confirmed goes to “needs attention” for a person instead of being sent a second time.

  3. Stream, never store.

    Video moves from Drive to the platform in bounded windows and is never buffered whole or copied. That keeps memory flat and avoids holding a second copy of the client’s media.

  4. Defer, do not fail.

    A used-up quota, a revoked token or a paused switch moves a job to a waiting state with a reason and a resume time. Nothing is marked failed for a cause that will clear.

  5. One reply per comment, even when the platform sends it twice.

    Incoming events are recorded once, and each step of a conversation is saved as durable work that can be retried safely. A repeated webhook finds work already done and does nothing.

  6. Messaging rules live in one place.

    A single policy decides whether a message may be sent, and it is checked again right before every send. Retries and background runs never extend a window.

  7. Overlap is refused, not guessed.

    A comment can start at most one workflow. If two workflows would claim the same comment on the same Reel, activation is refused and shows the exact conflict.

  8. The assistant prepares, the owner decides.

    Publishing straight from an assistant needs the publish scope, an owner switch that is off by default, and a single-use confirmation tied to the exact content previewed. Activating or deleting an automation also needs explicit confirmation. There are no admin tools over MCP, and text from Drive is returned as data, never as instructions.

  9. One module per platform.

    Each platform sits behind its own connector with its own state, quota entry and error mapping, so a problem with one cannot stop the others. LinkedIn and X were added this way, as new connectors. Adding another platform is a new module, not a rewrite.

  10. Built for tight limits.

    The serverless platform’s per-request CPU and outbound-call limits shaped the design: work is bounded, streamed and resumable, and heavy steps run as queued jobs instead of inside a request.

Custom versus off the shelf

Where a custom platform goes further than a no-code tool

Hosted automation tools such as Zapier are a good fit for many workflows. atom exists because this one needed things a tool of that kind is not built to provide.

  • Scheduling that is part of the system

    Jobs have explicit states, overdue work is found and recovered, and publishing can be paused or rehearsed with a switch.

  • Large files, streamed

    Video goes from Drive to the platform in resumable windows, so the limits are those of YouTube and Instagram themselves.

  • Platform rules built in

    Reel format checks before upload, YouTube privacy always explicit, quotas read from the platforms, and unclear results reconciled instead of repeated.

  • Conversation rules that protect the account

    Reply windows, one reply per comment, per-person limits and a follow check are enforced before every message, instead of being left to each workflow.

  • Custom control

    An approval step, a live execution log and an MCP interface for AI assistants, designed around how the client works.

  • Extensible by design

    Google Drive, YouTube, Instagram, LinkedIn and X today. Because each platform is a connector behind a common interface, any tool or platform that offers a developer API can be added, subject to its terms and API access.

Results

Results of atom

  • Live in production and serving an active user base.
  • Posts go out on schedule with no computer switched on.
  • Every action is recorded, with a live log for each job and a separate audit trail.
  • Duplicate and missed publishes are guarded against: steps are idempotent and unclear results are reconciled.
  • An AI assistant can handle the routine work while the owner keeps final control.
  • Platform limits, not a plan tier, decide what can be published.
  • Comments are answered once, even when the platform sends the same event twice.
  • A person who reaches the delivery limit gets a short message instead of the file, so no one is flooded.
  • Every automation action is logged and can be reviewed, and a workflow can be tested without sending anything.

Architecture

The full system

For engineering readers. Everything in the drawing is described in the text above.

atom architectureA cron trigger every minute, an AI assistant over MCP with OAuth 2.1, the dashboard and Instagram webhooks start work, and the client team uses the dashboard. All of it reaches one TypeScript Worker on Cloudflare. The Worker has four interfaces: a Hono REST API that denies by default, the static dashboard, an MCP server with scopes and confirmations, and access control with passkeys, Google sign-in and recovery codes. Behind them are six core services: a Drive-backed media library, a composer, a scheduler with a recovery sweeper, a publish engine built as a job state machine, a quota service, and an automation engine that turns Instagram comments into direct messages. The dashboard API and MCP call the same services. Five connectors, one per platform, share one interface: Google Drive is read-only, YouTube uploads in resumable windows, Instagram creates a container and publishes once, and LinkedIn and X publish posts. The Worker uses Cloudflare services: a D1 database that holds the authoritative state, a queue that only delivers, and a KV namespace for the OAuth provider. The platforms are Google Drive through its API, YouTube through the Data API, Instagram through the Graph API, and LinkedIn and X through their own connectors.WHAT STARTS WORKCron triggerEvery minuteAI assistantMCP, OAuth 2.1InstagramSigned webhooksDashboardPasskeys, GooglePEOPLEClient teamActive usersONE WORKER ON CLOUDFLAREatom, TypeScriptINTERFACESREST APIHono, ZodDeny by default, CSRFDashboardStatic assetsNo server renderingMCP serverStreamable HTTPScopes, confirmationsAccess controlPasskeys, GoogleRecovery codes, auditThe dashboard API and MCP call the same servicesCORE SERVICESMedia libraryDrive feedRead-only syncDuplicate linksComposerZod validationVideos, ReelsLinkedIn, X postsSchedulerEvery minuteClaims due jobsRecovery sweeperPublish engineState machineIdempotent stepsReconciliationQuota serviceUsage ledgerDefers, not failsMeta, YouTubeAutomationsComment to DMKeywords, ReelsFollow gate, limitsCONNECTORS, ONE PER PLATFORMDriveRead-onlyReads, never writesYouTubeResumableWindowed uploadInstagramContainerPublish onceLinkedInCompany PageText and videoXPostsText, images, videoCLOUDFLARE SERVICESD1 databaseAuthoritative statepublish_jobs: the truthoutbox: dispatch intentsjob_events: append-only logaudit_logs: security trailQueueDelivery onlyAt-least-once deliveryRecovery sweeper behind itKVOAuth provider onlyHashed MCP tokensPLATFORMSGoogle DriveDrive API v3YouTubeData API v3InstagramGraph APILinkedInCompany PageXPostsread-onlyresumablepublish oncepublishpublish
One Worker, one source of truth. The dashboard and the AI assistant call the same services, and each platform sits behind its own connector.Scroll sideways or pinch to zoom

One Worker and one source of truth. The dashboard and the AI assistant call the same services, and each platform sits behind its own connector. Four more drawings follow: a post’s life, the streaming path to YouTube and Instagram, a comment becoming a delivered file, and the assistant workflow.

The life of a post

The life of a publishing jobA publishing job moves from scheduled to queued, running, at the platform and published. Four side states exist: paused when a token is revoked or publishing is switched off, deferred when a quota is used up and resumes at reset, needs attention when an outcome is unclear and must be reconciled first, and failed when the platform refuses. A job can be cancelled until it has started. Below, reliable delivery: every state change is written with an outbox row in one D1 transaction, the queue delivers at least once, a consumer takes a lease and checks the version, does one step and saves its result first. A repeated delivery finds a newer version or a held lease and does nothing.PUBLISHING JOB STATESpublish_jobs, one row per post and platformScheduledwaiting for its timeQueuedsent via the outboxRunningheld by one workerAt platformprocessingPublishedIDs and link savedPausedDeferredNeeds attentionFailedtoken revoked,switch offquota used up,resumes at resetoutcome unclear,reconcile firstplatform said no,reason recordedCancel works untila job has startedRELIABLE DELIVERYAt-least-once delivery, exactly-once effectsone D1 transactionState changeoptimistic versionOutbox rowsame transactionQueueat-least-onceConsumerlease, version checkOne stepresult saved firstA repeated delivery finds a newer version or a held lease, and does nothing.
Jobs move through explicit states, and no delivery or retry can publish a post twice.Scroll sideways or pinch to zoom

Streaming from Drive to YouTube and Instagram

Streaming from Drive to YouTube and InstagramGoogle Drive is read-only and the file stays in Drive. For YouTube: preflight checks format, size and quota, a resumable session is opened with privacy always set, each window is streamed from Drive to YouTube, and the confirmed offset is saved so an interrupted upload resumes. After the upload atom checks processing, sets the thumbnail and relies on YouTube's own publish time. For Instagram: preflight checks the file, size and limit, a Reel or Story container is created, the video is delivered through a short-lived single-use link or a resumable upload, and the post is published once, with reconciliation if the outcome is unclear. Offsets and container IDs are saved in the database before the next step.Google DriveRead-onlyRange readsFile stays in DriveYOUTUBEWindowed resumable uploadPreflightformat, size, quotaOpen sessionprivacy always setStream windowDrive to YouTubeSave offsetresume after a breakYouTubeData API v3Never buffered, never stored: each window is piped from Drive to YouTube.Afterwards: processing check, thumbnail and YouTube's own publish time.INSTAGRAMContainer, then publish oncePreflightfile, size, limitCreate containerReel or StoryDeliver videolink or uploadPublish oncereconcile if unsureInstagramGraph APIMeta pulls a short-lived, single-use link, or atom uploads the bytes.Container IDs are saved first, so a retry resumes instead of repeating.Offsets and container IDs live in the database, so a restart picks up where it stopped.
The video is never buffered whole and never copied. Progress is saved after every step.Scroll sideways or pinch to zoom

From a comment to a delivered file

From a comment to a delivered fileSomeone comments a keyword on an Instagram Reel. The webhook is checked and recorded once, the comment is matched to one workflow by keyword and Reel, atom posts a public reply and sends one private reply, the person replies or taps a button, an optional follow check runs using Instagram's own follow status, and a Google Drive link is delivered. Every step is saved as durable work, so a retry resumes and never repeats. Four safeguards apply: one reply per comment even when events repeat, messaging windows of 7 days and 24 hours checked before every send, a per-person delivery limit, and paced sending with back-off.A COMMENT BECOMES A CONVERSATIONInstagram, one workflow per commentCommenton a ReelWebhook checksigned, onceMatchkeyword, ReelPublic replyone of severalPrivate replyone per commentFollow checkoptional gateDelivera Drive linkThe person replies or taps a button. That opens a 24-hour window for the next message.The follow check uses Instagram's own answer. An unknown answer is never treated as yes or no.Every step is saved as durable work, so a retry resumes where it stopped and never repeats.Two workflows cannot claim the same comment. Activation is refused and shows the conflict.SAFEGUARDSRules checked before every messageOne reply per commentIdempotent ingestRepeated events do nothingWork saved before it runsMessaging windows7 days, 24 hoursChecked before every sendNever extended by a retryDelivery limitsPer personOne file per conversationCap of 3, then a short notePaced sendingBack-off built inSlows down when askedHeld work is never lostDuplicate webhooks never cause a second reply or a second file.
A comment is answered once, the platform's messaging rules are checked before every send, and nobody is sent the same file twice.Scroll sideways or pinch to zoom

How an AI assistant works with atom

How an AI assistant works with atomAn AI assistant works through six MCP tools: it finds a file in Drive, registers it, approves it when the owner has said so, creates a draft, schedules it and checks the result. The assistant passes file IDs and text; video never passes through it. Activating a comment-to-DM workflow needs the same confirmation and owner switch. Publishing straight from an assistant, on any of the four platforms, is a separate path with four safeguards: four least-privilege scopes with publish off by default, a single-use five-minute confirmation bound to the exact content, an owner switch that is off by default, and a posture that treats Drive text as data and exposes no admin tools over MCP.ROUTINE WORK, ONE STEP AT A TIMEMCP tools for publishing and comment-to-DMFinddrive.findRegistermedia.registerApprovemedia.approveDraftdraft.createScheduleschedule.createCheckjobs.getThe assistant passes file IDs and text. Video never passes through it: atom reads the file from Drive.Approval needs the owner's instruction and the schedule scope.SAFEGUARDSPublishing straight from an assistant is a separate, gated pathFour scopesLeast privilegeread, draft, schedule, publishpublish is off by defaultSingle-use confirmationFive minutesBound to the exact contentVoid if the draft changesOwner switchOff by defaultAssistant publishing stays offuntil the owner turns it onData, not instructionsInjection-safe by designDrive text is returned as dataNo admin tools over MCP
The assistant prepares and schedules. Publishing directly from it needs a scope, a switch and a confirmation.Scroll sideways or pinch to zoom

Stack

Technology

  • Cloudflare Workers, D1, Queues and KV
  • TypeScript
  • Hono
  • Zod
  • Next.js (static export)
  • Tailwind CSS
  • WebAuthn passkeys
  • OAuth 2.1 and MCP
  • Google Drive API
  • YouTube Data API
  • Instagram Graph API, messaging and webhooks
  • Vitest

For your business

Similar problems Lubili can solve

Any workflow that has outgrown a hosted automation tool: scheduled publishing, lead magnets or guides delivered from comments, questions answered from a post, giveaway entries, document or media pipelines, multi-platform integrations, and processes that need approval, quotas, recovery and an audit trail. Lubili also builds the AI assistant interface (MCP) on top of such systems.

Client work. Client details are kept confidential.

Want comments turned into conversations, and content published on time?

Book a free consultation, and we will look at what you need, what a custom platform would involve, and whether it is the right choice.

Free. No obligation. You get a one-page written summary.