diff --git a/AGENTS.md b/AGENTS.md index 45bd33c7..0bdbd36e 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -95,6 +95,7 @@ longer exist — only some keep an alias. |---|---| | `wizard migrate statsig` | `migrate-statsig` | | `wizard migrate resend` | `migrate-email-resend` | +| `wizard migrate loops` | `migrate-email-loops` | **Commands vs. skills:** those audit subcommands **are** skills, promoted to commands via `cli: role: command`. A `role: skill` skill is reachable only via diff --git a/context/skills/migrate-email/config.yaml b/context/skills/migrate-email/config.yaml index 6f9a304f..abd69f4b 100644 --- a/context/skills/migrate-email/config.yaml +++ b/context/skills/migrate-email/config.yaml @@ -16,3 +16,6 @@ variants: - id: resend display_name: Resend tags: [resend] + - id: loops + display_name: Loops + tags: [loops] diff --git a/context/skills/migrate-email/references/loops/account.md b/context/skills/migrate-email/references/loops/account.md new file mode 100644 index 00000000..fec6f523 --- /dev/null +++ b/context/skills/migrate-email/references/loops/account.md @@ -0,0 +1,99 @@ +# Loops account + +What the migration needs from the person's Loops account. The agent never changes the account: it reads what the person exports or allows. + +Every request in this file goes to `app.loops.so`, Loops' one host, even when the app's client points at another URL with `WithBaseURL` or `apiRoot`, as `sdk-reference.md` says. + +## DNS records + +A sending domain set up at Loops carries these records. Keep all of them until the cutover is done. The Loops dashboard shows the exact names and values under Settings, then Domain, then View records. It can also download them as a zone file, or share them on a public records page. + +| Record | Name | What it does | +|---|---|---| +| `TXT` (SPF) | `envelope.` | Loops' SPF, on its own label | +| `MX` | `envelope.` | Takes Loops' bounces for its return path | +| DKIM | the `_domainkey` names Loops shows | Signs Loops' mail | +| `TXT` (DMARC) | `_dmarc` | Loops shows a default one. Shared by every provider on the domain | + +- Loops sends from the From name the person sets in each email, on the team's sending domain, such as `hello@mail.example.com`. A Loops team has one sending domain. An app that sends from several domains uses one Loops team, with its own API key, per domain: each domain has its own records. +- PostHog's sender uses its own label for its MAIL FROM, `feedback` by default. Never give PostHog the label `envelope`, which Loops uses. +- Loops' SPF record sits at `envelope.`, not at the sending domain. Leave it alone. When PostHog's SPF record goes to a name that already has a `v=spf1` record, merge PostHog's include into it. +- PostHog's DKIM records have their own names, so they sit next to Loops' DKIM records. +- Keep the one `_dmarc` record of the domain or its parent. Never add a second one, even when Loops' records page shows one. + +## Migration key + +Loops API keys have no permissions to choose: every key can send and change the account. So the run never reads the app's own key. When the person chooses the API over the dashboard for template content, or when the suppression import below checks addresses, whichever comes first, ask them to create a separate key for the migration in Loops (Settings, then API, then Generate key), store it in `LOOPS_MIGRATION_API_KEY` in the git-ignored env file, and write it into the plan as Step 3's plan layout says. Use it only for the reads below. Its last use is the suppression check in Step 5. At the end of Step 5, on every way out of it, ask the person to revoke the key in Loops (the trash icon next to it on the API settings page) and remove its variable from the env file, and note in the plan whether they did. The report reminds them when they didn't. Never print the key, and never write it into another file. + +An app with several Loops teams, one per sending domain, needs one migration key per team: each team's emails and contacts are visible only to its own keys. Match each site to its team by the API key variable its client reads. Ask for one key per team, each in its own variable, such as `LOOPS_MIGRATION_API_KEY_MAIL_EXAMPLE_COM`, read each team's emails and audience with its own key, and ask the person to revoke every one at the end of Step 5. + +The steps call this key the full-access provider key. + +## Template content + +Every Loops site sends a Loops email, so each site that moves needs the content of the email's published version: Step 3 checks it, and Step 7 brings it into the code, or the person makes a template in PostHog from it when they ask for one. The API returns the content, but not as HTML: it answers the body in LMX, Loops' markup, which `mapping.md` turns into HTML under "Templates". The dashboard has no export of an email's HTML, so its copy is a preview send. + +**Read from the API.** With `Authorization: Bearer $LOOPS_MIGRATION_API_KEY`: + +1. `GET https://app.loops.so/api/v1/transactional-emails/{transactionalId}` answers `publishedEmailMessageId` and `dataVariables`, the names the published version uses. +2. `GET https://app.loops.so/api/v1/email-messages/{publishedEmailMessageId}` answers `subject`, `previewText`, `fromName`, `fromEmail` (the part before the sending domain), `replyToEmail`, `ccEmail` and `bccEmail` (only when set), `languageCode` (only when set), `emailFormat` (`styled` or `plain`), `dataVariablesFallbacks` (only when set), and `lmx`, the body in LMX. +3. For a `