Skip to main content

Overview

Lovable is an AI-powered platform that lets you build full-stack web apps from natural language prompts. You can integrate Brew into any Lovable project to send on-brand emails triggered by user actions in your app. Brew works with Lovable through its REST API. Since the API requires an API key, Lovable uses Supabase Edge Functions to keep your credentials secure.

What Brew Handles for You

Building email into an app usually means writing HTML templates, handling unsubscribes, managing bounces, and worrying about deliverability. Brew takes care of all of that so you can focus on your app.
  • On-brand design without HTML - Describe your email in plain language. Brew generates production-ready, responsive emails that match your brand’s colors, fonts, logo, and tone of voice. No HTML coding or email design skills needed.
  • Compliance built in - Marketing emails (automations and campaigns) automatically include a physical address and unsubscribe link in the footer. Brew’s preflight audit blocks any send that’s missing required compliance elements, keeping you aligned with CAN-SPAM and GDPR.
  • Unsubscribe management - Brew handles the entire unsubscribe flow: a branded unsubscribe page, contact status updates, and automatic suppression from future marketing sends. You don’t need to build any of this yourself.
  • Bounce and complaint handling - Hard bounces and spam complaints are automatically suppressed, protecting your sender reputation without any code on your end.
  • Contact auto-creation - When you trigger an automation or send a transactional email, Brew automatically creates or updates the contact record. No separate contact creation step needed in your app.
  • Works across every email client - Gmail, Outlook, Apple Mail, Yahoo, mobile - email HTML is notoriously tricky. Every email Brew generates is responsive and tested across clients.
  • Analytics without instrumentation - Opens, clicks, bounces, and deliverability are tracked automatically in Brew’s dashboard. No event tracking code required in your Lovable app.

Three Ways to Send Emails with Brew

Brew has three types of emails. Here’s how each one works in the context of a Lovable app:
TypeWhat it doesHow it’s triggered
AutomationsMulti-step email sequences with delays, branching, and conditions. Think welcome series, onboarding drips, or order follow-ups.Triggered from your Lovable app via API when an event happens (user signs up, places an order, etc.)
TransactionalSingle, immediate emails for things like password resets, receipts, or account notifications.Triggered from your Lovable app via API when a user action requires an instant email.
CampaignsOne-time sends to a segment of your audience. Think newsletters, product announcements, or promotions.Created and sent (or scheduled) inside Brew’s dashboard. Not triggered from your app.
Automations and transactional emails can both be triggered directly from your Lovable app using the setup below. Campaigns are designed and sent from Brew’s UI, so there’s nothing to configure in Lovable for those.

Prerequisites

Brew Account

Sign up at brew.new and set up your brand.

Verified Domain

Verify your sending domain to send emails from your own address.

API Key

Create a new API key in Settings → API in your Brew dashboard.

Lovable with Supabase

Connect Supabase to your Lovable project to use Edge Functions.

Connect Brew to Lovable

These steps apply to both automations and transactional emails.
1

Connect Supabase to your Lovable project

Lovable uses Supabase Edge Functions to securely handle API keys. If you haven’t connected Supabase yet, click the Supabase icon in your Lovable project and follow the authorization steps.
2

Add your Brew API key as a secret

In your Lovable project, go to Supabase → Secrets:
  • Add a new secret with the name BREW_API_KEY
  • Paste your Brew API key as the value
Get your API key from Settings → API in your Brew dashboard.

Automations

Automations are multi-step email flows you design in Brew and trigger from your Lovable app when something happens, like a user signing up, placing an order, or abandoning a cart. Brew handles the entire sequence: delays, branching, follow-ups.

Set up in Brew

1

Create your automation

In Brew, go to the Create page, select Automation, and describe the flow you want. For example: “Create a 3-email welcome series for new users. First email welcomes them, second shares a quick-start guide, third nudges them to book a demo.”
2

Set an event ID and define your payload

Give your automation a descriptive event ID like user_signup or order_placed. Define the payload schema (the data your app will send), for example: email, firstName, plan.
3

Publish

Publish your automation to make it available via API.
Learn more about building automations in the Automations guide.

Prompt Lovable

Copy and paste this prompt into Lovable’s chat:
Integrate Brew automation API for triggering email sequences.

API Details:
- Base URL: https://brew.new/api
- Auth: Bearer token using the BREW_API_KEY secret
- Endpoint: POST /automations/{eventId}/trigger
- Content-Type: application/json

Request body format:
{
  "payload": {
    "email": "user@example.com",
    "firstName": "Jane",
    "plan": "premium"
  }
}

Response format:
{
  "success": true,
  "executionId": "exec_abc123",
  "automationId": "kx7777hn1pqfvpq",
  "eventId": "user_signup",
  "status": "running",
  "contact": {
    "email": "user@example.com",
    "action": "created"
  }
}

Create a Supabase Edge Function called "trigger-automation" that:
1. Reads BREW_API_KEY from environment secrets
2. Accepts eventId and payload in the request body
3. Calls POST https://brew.new/api/automations/{eventId}/trigger with Bearer token auth
4. Returns the response to the client

The "email" field is always required in the payload. The eventId is a string you define in Brew when creating the automation (e.g. "user_signup", "order_placed").

Docs: https://docs.brew.new/emails/automations
Lovable will generate a Supabase Edge Function and wire it into your app automatically.

When to use automations

  • User signup - Trigger user_signup to start a welcome series
  • Onboarding - Trigger onboarding_started to send a multi-step getting started sequence
  • Trial ending - Trigger trial_ending to send a reminder sequence nudging users to upgrade
  • Re-engagement - Trigger user_inactive to win back users who haven’t logged in recently

Transactional Emails

Transactional emails are single, immediate emails sent when a user action requires an instant response, like a password reset link or an order receipt.

Set up in Brew

1

Create your transactional email

In Brew, go to the Create page, select the Transactional tab, and describe the email you need. For example: “Create a password reset email with a reset link and expiry time.”
2

Add variables

Use triple curly braces for dynamic content: {{{firstName}}}, {{{resetUrl}}}. Brew’s AI will often insert these automatically based on your prompt.
3

Publish and copy your chatId

Click Publish to get your unique chatId. You’ll need this for API calls from Lovable.
Learn more about creating transactional emails in the Transactional Emails guide.

Prompt Lovable

Copy and paste this prompt into Lovable’s chat:
Integrate Brew email API for sending transactional emails.

API Details:
- Base URL: https://brew.new/api
- Auth: Bearer token using the BREW_API_KEY secret
- Endpoint: POST /send/transactional
- Content-Type: application/json

Request body format:
{
  "chatId": "YOUR_TEMPLATE_ID",
  "to": "recipient@example.com",
  "variables": {
    "firstName": "Jane",
    "resetUrl": "https://yourapp.com/reset?token=abc123"
  }
}

Response format:
{
  "success": true,
  "data": {
    "sent": 1,
    "failed": 0,
    "results": [
      { "email": "recipient@example.com", "id": "email_abc123" }
    ]
  },
  "meta": { "requestId": "req_xyz789" }
}

Create a Supabase Edge Function called "send-email" that:
1. Reads BREW_API_KEY from environment secrets
2. Accepts chatId, to, and variables in the request body
3. Calls the Brew API with Bearer token auth
4. Returns the response to the client

The "chatId" is the template ID from Brew. Design your email in Brew first, then publish it to get the chatId.

Docs: https://docs.brew.new/emails/transactional-emails
Lovable will generate a Supabase Edge Function and wire it into your app automatically. You can also override the subject line, sender, and reply-to address per request by adding subject, from, and replyTo fields to the request body.

When to use transactional emails

  • Password resets - Send a reset link immediately when requested
  • Order receipts - Confirm a purchase the moment it’s completed
  • Payment failed - Notify the user instantly so they can update their payment method
  • Account notifications - Plan upgrades, billing alerts, security events

Test Your Integration

Once Lovable finishes generating the code, trigger the email flow in your app (for example, submitting a signup form or requesting a password reset). Check your email analytics in Brew to confirm the email was delivered.

Troubleshooting

Make sure your BREW_API_KEY is correctly added in Supabase Secrets. Also verify that your sending domain is verified in Brew by checking Settings → Domains in your dashboard.
Double-check that the Edge Function is reading the secret correctly. The Authorization header should be Bearer YOUR_API_KEY with no extra spaces or quotes.
For transactional emails, make sure the variables object includes all variables used in your template. For automations, make sure the payload includes email and all required fields defined in your schema. Field names are case-sensitive.
Verify that the automation is published and active in Brew. Check that the event ID in your API call matches the one configured in Brew. The automation status must be active, not draft or paused.
Make sure you have completed domain verification including DKIM and SPF records. We recommend using a subdomain like updates.yourdomain.com for sending.
Lovable may sometimes show false positive build errors. Test your app live by triggering the actual email flow. If the Edge Function deploys successfully in Supabase, the integration is likely working.

Need Help?

Our team is ready to support you at every step of your journey with Brew. Choose the option that works best for you:

Search Documentation

Type in the “Ask any question” search bar at the top left to instantly find relevant documentation pages.

ChatGPT/Claude Integration

Click “Open in ChatGPT” at the top right of any page to analyze documentation with ChatGPT or Claude for deeper insights.