WeWeb Resend Integration
A WeWeb backend integration for Resend's email API, providing robust email sending capabilities within WeWeb backend workflows. This integration uses the official resend
package for reliable email delivery with features like HTML templates, attachments, and tracking.
Features
- Simple integration with Resend's email API
- Send transactional emails with HTML or plain text content
- Support for CC, BCC, and reply-to fields
- File attachments support
- Email tracking capabilities
- Domain management functions
- API key management
Installation
This package is designed to work with the WeWeb Supabase Backend Builder and Deno.
import { serve } from '@weweb/backend-core';
import { createResendIntegration } from '@weweb/backend-resend';
Usage
Basic Setup
import type { BackendConfig } from '@weweb/backend-core';
import { serve } from '@weweb/backend-core';
import Resend from '@weweb/backend-resend';
const config: BackendConfig = {
workflows: [
],
integrations: [
Resend,
],
production: false,
};
const server = serve(config);
Custom Configuration
You can customize the Resend client by using the createResendIntegration
function:
import { createResendIntegration } from '@weweb/backend-resend';
const customResend = createResendIntegration({
apiKey: 're_123456789',
});
If not specified, the integration will use the following environment variable:
RESEND_API_KEY
- Your Resend API Key
Available Methods
Send Email
Send transactional emails to one or multiple recipients.
const config = {
type: 'action',
id: 'send_welcome_email',
actionId: 'resend.send_email',
inputMapping: [
{
from: 'onboarding@yourdomain.com',
to: '$body.email',
subject: 'Welcome to Our Platform',
html: '<h1>Welcome!</h1><p>Thank you for signing up.</p>',
text: 'Welcome! Thank you for signing up.'
}
]
};
Get Email
Retrieve details about a sent email.
const config = {
type: 'action',
id: 'get_email_details',
actionId: 'resend.get_email',
inputMapping: [
{
id: '$body.emailId'
}
]
};
List Emails
Get a list of all sent emails with pagination support.
const config = {
type: 'action',
id: 'list_recent_emails',
actionId: 'resend.list_emails',
inputMapping: [
{
limit: 20
}
]
};
Create Domain
Add a new domain to your Resend account.
const config = {
type: 'action',
id: 'add_new_domain',
actionId: 'resend.create_domain',
inputMapping: [
{
name: 'marketing.yourdomain.com',
region: 'us-east-1'
}
]
};
List Domains
Get a list of all domains in your Resend account.
const config = {
type: 'action',
id: 'get_all_domains',
actionId: 'resend.list_domains',
inputMapping: [{}]
};
Example: Complete Email Service Application
import type { BackendConfig } from '@weweb/backend-core';
import { serve } from '@weweb/backend-core';
import Resend from '@weweb/backend-resend';
const config: BackendConfig = {
workflows: [
{
path: '/send-email',
methods: ['POST'],
security: {
accessRule: 'public',
},
inputsValidation: {
body: {
type: 'object',
properties: {
to: { type: 'string' },
subject: { type: 'string' },
message: { type: 'string' },
template: { type: 'string', enum: ['welcome', 'password_reset', 'invoice'] }
},
required: ['to', 'subject', 'message', 'template'],
},
},
workflow: [
{
type: 'action',
id: 'send_email',
actionId: 'resend.send_email',
inputMapping: [
{
from: 'support@yourdomain.com',
to: '$body.to',
subject: '$body.subject',
html: `
{{#if (eq $body.template 'welcome')}}
<h1>Welcome to Our Service</h1>
{{else if (eq $body.template 'password_reset')}}
<h1>Password Reset Request</h1>
{{else if (eq $body.template 'invoice')}}
<h1>Your Invoice</h1>
{{/if}}
<div>{{$body.message}}</div>
<footer>© Your Company 2025</footer>
`,
text: '$body.message'
},
],
},
],
},
],
integrations: [Resend],
production: false,
};
console.log('Starting email service on http://localhost:8000/send-email');
serve(config);
Authentication
This integration uses the official Resend client and requires a Resend API key to function:
You can get your API key from the Resend Dashboard.
Getting Started with Resend
- Create a Resend account at resend.com
- Verify your domain to ensure better deliverability
- Generate an API key from the dashboard
- Set the
RESEND_API_KEY
environment variable or provide it in the configuration
Resend offers features like:
- Email analytics and tracking
- Bounce handling
- Template management
- Webhook integration for delivery status
- Domain verification for improved deliverability
For full details, see Resend's documentation.