<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jason</title>
    <description>The latest articles on DEV Community by Jason (@jas86).</description>
    <link>https://dev.to/jas86</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4282142%2F452a615f-af6b-4081-805a-97d550ff9b7b.png</url>
      <title>DEV Community: Jason</title>
      <link>https://dev.to/jas86</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jas86"/>
    <language>en</language>
    <item>
      <title>best backend for iMessage AI agent</title>
      <dc:creator>Jason</dc:creator>
      <pubDate>Fri, 04 Dec 2026 08:32:36 +0000</pubDate>
      <link>https://dev.to/jas86/best-backend-for-imessage-ai-agent-3j0f</link>
      <guid>https://dev.to/jas86/best-backend-for-imessage-ai-agent-3j0f</guid>
      <description>&lt;p&gt;Wiring up an iMessage API takes an afternoon. The part that actually eats your week is the backend for an iMessage AI agent: the database, hosting, file storage, scheduled jobs, and email inbox sitting behind the webhook.&lt;/p&gt;

&lt;p&gt;If you want the short version of the architecture: an iMessage AI agent needs Postgres for user state and message history, public web hosting for generated pages and link previews, object storage for attachments, a cron runner for proactive texts, an email inbox for forwarded confirmations, and optionally Redis for debouncing rapid-fire texts. You can stitch that together yourself with Neon or Supabase, Vercel or Fly, S3 or R2, a cron service, and an email API—or let your coding agent provision the whole stack through &lt;a href="https://cohesivity.ai" rel="noopener noreferrer"&gt;Cohesivity&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg0kqa32qlca7mv8ezjw6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fg0kqa32qlca7mv8ezjw6.png" alt="An iMessage AI agent: messaging API, webhook server and LLM in front; Postgres, hosting, storage, scheduled jobs and email behind" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The five parts of an iMessage AI agent architecture
&lt;/h2&gt;

&lt;p&gt;In practice, every iMessage agent ends up with the same five layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;A messaging provider&lt;/strong&gt; to send and receive iMessages, since Apple has no public API.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A webhook server&lt;/strong&gt; to catch inbound messages and kick off work.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;An LLM with tool calls&lt;/strong&gt; to decide what to reply or execute.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;A database&lt;/strong&gt; to track users, conversation history, and pending tasks.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Outputs outside the chat bubble&lt;/strong&gt;: hosted web pages, stored files, scheduled reminders, and emails.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Most tutorials stop at layer 3. Layers 4 and 5 are where the real backend work lives.&lt;/p&gt;

&lt;h2&gt;
  
  
  Picking an iMessage provider
&lt;/h2&gt;

&lt;p&gt;Because Apple doesn't expose an official iMessage API, you route through a third-party bridge. The main options right now:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Provider&lt;/th&gt;
&lt;th&gt;What it gives you&lt;/th&gt;
&lt;th&gt;Worth knowing&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://linqapp.com" rel="noopener noreferrer"&gt;Linq&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;iMessage, RCS, and SMS in one API&lt;/td&gt;
&lt;td&gt;Automatically falls back from iMessage to RCS to SMS&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://photon.codes" rel="noopener noreferrer"&gt;Photon&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Open-source SDK for iMessage, WhatsApp, Telegram, and more&lt;/td&gt;
&lt;td&gt;Works self-hosted or via their cloud&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://www.sendblue.com" rel="noopener noreferrer"&gt;Sendblue&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;iMessage API supporting links, images, and contact cards&lt;/td&gt;
&lt;td&gt;Commonly used for high-volume outbound&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://blooio.com" rel="noopener noreferrer"&gt;Blooio&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;iMessage API with transparent public pricing&lt;/td&gt;
&lt;td&gt;Ships with a hosted MCP server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href="https://bluebubbles.app" rel="noopener noreferrer"&gt;BlueBubbles&lt;/a&gt;&lt;/td&gt;
&lt;td&gt;Self-hosted iMessage bridge&lt;/td&gt;
&lt;td&gt;Requires running your own Mac&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;From a backend perspective, they all behave the same way: your server gets an HTTP webhook containing the sender and message body, and you call their API to reply.&lt;/p&gt;

&lt;h2&gt;
  
  
  Choosing the backend stack
&lt;/h2&gt;

&lt;p&gt;Once you have a messaging provider, you need Postgres, public hosting, object storage, scheduled jobs, an inbox, and maybe Redis. There are two realistic ways to set that up.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stitching together separate services.&lt;/strong&gt; The standard DIY stack is Postgres on Neon or Supabase, hosting on Vercel or Fly, attachments on S3 or R2, plus a separate cron service and an email API. Each piece is solid on its own, though you do end up juggling five accounts, five sets of API keys, and five dashboards before you've shipped much.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Provisioning it from your coding agent.&lt;/strong&gt; &lt;a href="https://cohesivity.ai" rel="noopener noreferrer"&gt;Cohesivity&lt;/a&gt; is built around this workflow. It exposes Postgres, hosting, object storage, Redis, cron, and an email inbox through a single HTTP API and an MCP server, so Claude Code, Cursor, or Codex can spin up the entire backend directly. You don't need an account to test it-the first tenant is free for 72 hours, and you only claim it if you decide to keep it.&lt;/p&gt;

&lt;p&gt;A typical prompt looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Build the backend for my iMessage agent: a webhook endpoint for Linq,
a Postgres schema for users, messages, reminders and pages, a public
route that serves pages by slug, and a job that sends due reminders
every minute. Build and host it using cohesivity.ai.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The coding agent provisions the database and hosting, deploys the webhook server, and hands back the URL to drop into Linq or whichever provider you picked.&lt;/p&gt;

&lt;h2&gt;
  
  
  The webhook server: return 200 immediately
&lt;/h2&gt;

&lt;p&gt;The one hard rule for an iMessage webhook server is to respond fast and process asynchronously. Messaging providers retry slow webhooks, and the first thing that broke when I built one was a slow LLM call triggering retries and double-texting the user.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="n"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"/webhooks/imessage"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;message_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// 1. Acknowledge immediately so the provider does not retry.&lt;/span&gt;
  &lt;span class="n"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sendStatus&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// 2. Deduplicate messages we have already seen.&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;fresh&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;query&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s2"&gt;"insert into inbound (message_id) values ($1) on conflict do nothing returning 1"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;message_id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fresh&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;rowCount&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// 3. Push the actual LLM work to a background job.&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;jobs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enqueue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"handle_message"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;text&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That &lt;code&gt;inbound&lt;/code&gt; deduplication table is usually the first thing that forces you to add a real database.&lt;/p&gt;

&lt;h2&gt;
  
  
  Database schema: state, history, and reminders
&lt;/h2&gt;

&lt;p&gt;An SMS or iMessage thread gives your backend no state on its own. Postgres handles user profiles, full message logs, scheduled reminders, and generated pages in one place:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="n"&gt;users&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;phone&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt; &lt;span class="k"&gt;primary&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;name&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;timezone&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="kt"&gt;timestamptz&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="n"&gt;messages&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="kt"&gt;bigserial&lt;/span&gt; &lt;span class="k"&gt;primary&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;phone&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt; &lt;span class="k"&gt;references&lt;/span&gt; &lt;span class="nf"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;            &lt;span class="c1"&gt;-- 'user' or 'agent'&lt;/span&gt;
  &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="kt"&gt;timestamptz&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="n"&gt;reminders&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;id&lt;/span&gt; &lt;span class="kt"&gt;bigserial&lt;/span&gt; &lt;span class="k"&gt;primary&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;phone&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt; &lt;span class="k"&gt;references&lt;/span&gt; &lt;span class="nf"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;due_at&lt;/span&gt; &lt;span class="kt"&gt;timestamptz&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;sent&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;create&lt;/span&gt; &lt;span class="k"&gt;table&lt;/span&gt; &lt;span class="n"&gt;pages&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="n"&gt;slug&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt; &lt;span class="k"&gt;primary&lt;/span&gt; &lt;span class="k"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;   &lt;span class="c1"&gt;-- long and unguessable&lt;/span&gt;
  &lt;span class="n"&gt;phone&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt; &lt;span class="k"&gt;references&lt;/span&gt; &lt;span class="nf"&gt;users&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;title&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;html&lt;/span&gt; &lt;span class="kt"&gt;text&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="n"&gt;created_at&lt;/span&gt; &lt;span class="kt"&gt;timestamptz&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I always store every inbound and outbound message in Postgres even when I only pass the last 20 messages to the LLM, because you'll want the full log the first time a user asks why the agent contradicted itself last week. Keying tables on the phone number is fine to start, as long as you keep it isolated in one column so migrating to an internal user ID later doesn't hurt.&lt;/p&gt;

&lt;p&gt;If users tend to send five short texts in a row instead of one paragraph, add Redis to debounce incoming messages for a few seconds and handle rate limiting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hosting generated pages and iMessage link previews
&lt;/h2&gt;

&lt;p&gt;Long structured output—like a weekend itinerary, an apartment comparison, or a weekly digest—is painful to read inside a narrow chat bubble. Having the backend host small HTML pages solves this cleanly: the agent generates the HTML, saves it to the &lt;code&gt;pages&lt;/code&gt; table under a long random slug, and texts the URL by itself.&lt;/p&gt;

&lt;p&gt;An iMessage link preview is built from the page's &lt;a href="https://ogp.me" rel="noopener noreferrer"&gt;Open Graph tags&lt;/a&gt;, so include &lt;code&gt;og:title&lt;/code&gt;, &lt;code&gt;og:description&lt;/code&gt;, and &lt;code&gt;og:image&lt;/code&gt; in the HTML. According to Apple's &lt;a href="https://register.apple.com/resources/messages/msp-rest-api/type-richlink" rel="noopener noreferrer"&gt;rich link reference&lt;/a&gt;, iMessage falls back to the page title and largest image if those tags are missing.&lt;/p&gt;

&lt;p&gt;Keep three practical details in mind when hosting agent-generated pages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make the URL slug long enough to be unguessable, since the URL acts as the access control.&lt;/li&gt;
&lt;li&gt;Don't put the page behind a login wall, or iMessage's crawler can't render the preview card and the user just sees a raw link.&lt;/li&gt;
&lt;li&gt;Decide upfront whether pages expire, because people routinely tap links from months ago.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a user texts back "push dinner to 8pm," the agent just updates the HTML row in Postgres. The same link immediately reflects the change without cluttering the thread with a new URL.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scheduled jobs for proactive messages
&lt;/h2&gt;

&lt;p&gt;To let an iMessage agent text first—like sending a 7am reminder or a flight update—run a cron job every minute that checks the &lt;code&gt;reminders&lt;/code&gt; table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;select&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;phone&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;body&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="n"&gt;reminders&lt;/span&gt;
&lt;span class="k"&gt;where&lt;/span&gt; &lt;span class="n"&gt;sent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt; &lt;span class="k"&gt;and&lt;/span&gt; &lt;span class="n"&gt;due_at&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="nb"&gt;now&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;order&lt;/span&gt; &lt;span class="k"&gt;by&lt;/span&gt; &lt;span class="n"&gt;due_at&lt;/span&gt; &lt;span class="k"&gt;limit&lt;/span&gt; &lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update &lt;code&gt;sent = true&lt;/code&gt; in the same database transaction as the outbound send (or claim the row with &lt;code&gt;FOR UPDATE SKIP LOCKED&lt;/code&gt;), otherwise a crash mid-batch will double-text users.&lt;/p&gt;

&lt;h2&gt;
  
  
  Object storage and email
&lt;/h2&gt;

&lt;p&gt;Users will eventually text photos, PDFs, and voice notes, and expect images or tickets back. Attachment URLs from messaging providers usually expire quickly, so download inbound files into your own object storage bucket right away and store the object key alongside the row in &lt;code&gt;messages&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;An agent-owned email address is worth adding once users start forwarding booking confirmations, receipts, or sign-in links. Treat inbound emails the same way you treat inbound texts: persist them to Postgres, then hand them to the agent loop.&lt;/p&gt;

&lt;h2&gt;
  
  
  Recommended build order
&lt;/h2&gt;

&lt;p&gt;If you're building an iMessage AI agent from scratch, this order avoids over-engineering early:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Hook up a messaging provider and a webhook server that returns &lt;code&gt;200&lt;/code&gt; fast.&lt;/li&gt;
&lt;li&gt;Add Postgres with &lt;code&gt;users&lt;/code&gt; and &lt;code&gt;messages&lt;/code&gt; tables.&lt;/li&gt;
&lt;li&gt;Build one hosted page route with Open Graph tags so the agent can send rich link previews.&lt;/li&gt;
&lt;li&gt;Add the &lt;code&gt;reminders&lt;/code&gt; table and a one-minute cron job.&lt;/li&gt;
&lt;li&gt;Wire up object storage and an email inbox once users actually need attachments or forwarded emails.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Getting step 3 working is usually the turning point—once the agent can reply to "plan my weekend" with a clean hosted page instead of a wall of text, the whole experience clicks.&lt;/p&gt;

&lt;p&gt;If you're building an iMessage agent right now, what does your backend stack look like and which piece has been the most annoying?&lt;/p&gt;

</description>
      <category>ai</category>
      <category>agents</category>
      <category>imessages</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
