Skip to content

Commit d849e29

Browse files
bchapuisclaude
andcommitted
Add ONBOARDING_EMAIL support and fix email templates
Add optional per-email from address to EmailService, used by welcome emails via the new ONBOARDING_EMAIL env variable. Align HTML templates with their text counterparts and add missing footer to invitation HTML. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e7ea797 commit d849e29

4 files changed

Lines changed: 14 additions & 8 deletions

File tree

apps/api/src/auth.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,7 @@ async function completeOAuthLogin(
525525
onboardingUrl: c.env.ONBOARDING_URL,
526526
});
527527
const result = await emailService.send({
528+
from: c.env.ONBOARDING_EMAIL,
528529
to: userData.email,
529530
subject: emailContent.subject,
530531
html: emailContent.html,

apps/api/src/context.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export interface Bindings {
7070
STRIPE_PRICE_ID_PRO?: string;
7171
STRIPE_METER_ID?: string;
7272
ONBOARDING_URL?: string;
73+
ONBOARDING_EMAIL?: string;
7374
}
7475

7576
export interface Variables {

apps/api/src/services/email-service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { AwsClient } from "aws4fetch";
33
import type { Bindings } from "../context";
44

55
export interface EmailOptions {
6+
from?: string;
67
to: string | string[];
78
subject: string;
89
html?: string;
@@ -52,7 +53,7 @@ export class EmailService {
5253
* Send an email using Amazon SES
5354
*/
5455
async send(options: EmailOptions): Promise<EmailResult> {
55-
const { to, subject, html, text, replyTo } = options;
56+
const { from, to, subject, html, text, replyTo } = options;
5657

5758
if (!to || !subject) {
5859
return {
@@ -78,7 +79,7 @@ export class EmailService {
7879

7980
const params = new URLSearchParams();
8081
params.set("Action", "SendEmail");
81-
params.set("Source", this.fromAddress);
82+
params.set("Source", from ?? this.fromAddress);
8283

8384
for (let i = 0; i < toArray.length; i++) {
8485
params.set(`Destination.ToAddresses.member.${i + 1}`, toArray[i]);

apps/api/src/services/email-templates.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function getWelcomeEmail(params: WelcomeEmailParams): {
2424

2525
const text = `Let's automate something${userName ? `, ${userName}` : ""}.
2626
27-
Dafthunk is a visual way to build serverless workflows. Drag nodes, connect them, deploy to the edge.
27+
Dafthunk is a visual way to build serverless workflows on Cloudflare. Drag nodes, connect them, deploy to the edge.
2828
2929
Here are some quick tips:
3030
• Start from a use case template to see how nodes wire together
@@ -38,14 +38,14 @@ ${onboardingUrl ? `Want a walkthrough? Book an onboarding session: ${onboardingU
3838
Questions? GitHub issues or Discord.
3939
4040
Happy automating,
41-
The Dafthunk team
41+
Bertil Chapuis
4242
4343
4444
Dafthunk · Visual workflow automation
4545
${websiteUrl}`;
4646

4747
const html = `<p>Let's automate something${userName ? `, ${userName}` : ""}.</p>
48-
<p>Dafthunk is a visual way to build serverless workflows. Drag nodes, connect them, deploy to the edge.</p>
48+
<p>Dafthunk is a visual way to build serverless workflows on Cloudflare. Drag nodes, connect them, deploy to the edge.</p>
4949
<p>Here are some quick tips:</p>
5050
<ul>
5151
<li>Start from a use case template to see how nodes wire together</li>
@@ -55,8 +55,10 @@ ${websiteUrl}`;
5555
<li>Browse the Nodes Reference to see all 400+ available nodes</li>
5656
<li>Bonus: it's open source (MIT). Self-host it and contribute</li>
5757
</ul>
58-
${onboardingUrl ? `<p>Want a walkthrough? <a href="${onboardingUrl}">Book an onboarding session</a></p>\n` : ""}<p><a href="${docsUrl}">Docs</a> · Questions? GitHub issues or Discord.</p>
59-
<p>Happy automating,<br>The Dafthunk team</p>`;
58+
${onboardingUrl ? `<p>Want a walkthrough? <a href="${onboardingUrl}">Book an onboarding session</a></p>\n` : ""}<p><a href="${docsUrl}">Docs</a></p>
59+
<p>Questions? GitHub issues or Discord.</p>
60+
<p>Happy automating,<br>Bertil Chapuis</p>
61+
<p>—<br>Dafthunk · Visual workflow automation<br><a href="${websiteUrl}">${websiteUrl}</a></p>`;
6062

6163
return { subject, text, html };
6264
}
@@ -102,7 +104,8 @@ ${websiteUrl}`;
102104

103105
const html = `<p>${inviterName} invited you to join ${organizationName} on Dafthunk as a ${role}.</p>
104106
<p><a href="${invitationsUrl}">View Invitation</a></p>
105-
<p>This invite expires on ${expiresFormatted}.</p>`;
107+
<p>This invite expires on ${expiresFormatted}.</p>
108+
<p>—<br>Dafthunk · Visual workflow automation<br><a href="${websiteUrl}">${websiteUrl}</a></p>`;
106109

107110
return { subject, text, html };
108111
}

0 commit comments

Comments
 (0)