Skip to content

Commit 7cf317e

Browse files
authored
Merge pull request #531 from trycompai/lewis/comp-marketing-emails
Marketing emails
2 parents 5ad0cf0 + 3d64479 commit 7cf317e

10 files changed

Lines changed: 210 additions & 210 deletions

File tree

apps/app/src/actions/organization/create-organization-action.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import {
1818
} from "./lib/utils";
1919
import { env } from "@/env.mjs";
2020
import ky from "ky";
21+
import { tasks } from "@trigger.dev/sdk/v3";
22+
import type { newOrgSequence } from "@/jobs/tasks/marketing/new-org-sequence";
2123

2224
export const createOrganizationAction = authActionClient
2325
.schema(organizationSchema)
@@ -86,6 +88,11 @@ export const createOrganizationAction = authActionClient
8688
unsubscribed: false,
8789
audienceId: process.env.RESEND_AUDIENCE_ID,
8890
});
91+
92+
await tasks.trigger<typeof newOrgSequence>("new-org-sequence", {
93+
email: session.user.email,
94+
name: session.user.name?.split(" ")[0] || "",
95+
});
8996
}
9097

9198
await db.onboarding.create({
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
import { task, retry, wait, logger } from "@trigger.dev/sdk/v3";
2+
import {
3+
Body,
4+
Button,
5+
Container,
6+
Font,
7+
Heading,
8+
Html,
9+
Preview,
10+
Section,
11+
Tailwind,
12+
Text,
13+
} from "@react-email/components";
14+
import { Footer } from "@comp/email/components/footer";
15+
import { Logo } from "@comp/email/components/logo";
16+
import { Resend } from "resend";
17+
18+
const resend = new Resend(process.env.RESEND_API_KEY);
19+
20+
export const newOrgSequence = task({
21+
id: "new-org-sequence",
22+
run: async (payload: {
23+
email: string;
24+
name: string;
25+
}) => {
26+
logger.info(`Start new sequence for user ${payload.email}`);
27+
28+
await wait.for({ seconds: 5 });
29+
30+
const firstEmailResult = await retry.onThrow(
31+
async ({ attempt }) => {
32+
const { data, error } = await resend.emails.send({
33+
from: "Lewis Carhart <lewis@mail.trycomp.ai>",
34+
to: payload.email,
35+
subject: "Welcome to Comp AI",
36+
react: WelcomeEmail({ name: payload.name }),
37+
});
38+
39+
if (error) {
40+
throw new Error(error.message);
41+
}
42+
43+
return data;
44+
},
45+
{ maxAttempts: 3 },
46+
);
47+
48+
await wait.for({ days: 3 });
49+
50+
return {
51+
success: true,
52+
};
53+
},
54+
});
55+
56+
const WelcomeEmail = ({
57+
name,
58+
}: {
59+
name: string;
60+
}) => {
61+
return (
62+
<Html>
63+
<Tailwind>
64+
<head>
65+
<Font
66+
fontFamily="Geist"
67+
fallbackFontFamily="Helvetica"
68+
webFont={{
69+
url: "https://cdn.jsdelivr.net/npm/@fontsource/geist-sans@5.0.1/files/geist-sans-latin-400-normal.woff2",
70+
format: "woff2",
71+
}}
72+
fontWeight={400}
73+
fontStyle="normal"
74+
/>
75+
76+
<Font
77+
fontFamily="Geist"
78+
fallbackFontFamily="Helvetica"
79+
webFont={{
80+
url: "https://cdn.jsdelivr.net/npm/@fontsource/geist-sans@5.0.1/files/geist-sans-latin-500-normal.woff2",
81+
format: "woff2",
82+
}}
83+
fontWeight={500}
84+
fontStyle="normal"
85+
/>
86+
</head>
87+
88+
<Preview>Get started with Comp AI</Preview>
89+
90+
<Body className="bg-[#fff] my-auto mx-auto font-sans">
91+
<Container
92+
className="border-transparent md:border-[#E8E7E1] my-[40px] mx-auto p-[20px] max-w-[600px]"
93+
style={{ borderStyle: "solid", borderWidth: 1 }}
94+
>
95+
<Logo />
96+
<Heading className="mx-0 my-[30px] p-0 text-[24px] font-normal text-[#121212] text-center">
97+
Welcome to Comp AI!
98+
</Heading>
99+
100+
<Section>
101+
<Text className="text-[14px] leading-[24px] text-[#121212]">
102+
Hey {name},
103+
<br />
104+
<br />
105+
We're excited to have you on board with Comp AI. I just wanted to reach out and say welcome!
106+
<br />
107+
<br />
108+
If I can help with anything, you can reach me by replying to this email, or book a call with me here: <a href="https://cal.com/team/compai/meet-us">https://cal.com/team/compai/meet-us</a>
109+
<br />
110+
<br />
111+
p.s. if you're interested, we're currently offering a fast-track path for SOC 2 Type I and II - if you're interested, let me know and I'll send you an invite to Slack :)
112+
</Text>
113+
</Section>
114+
115+
<Footer />
116+
</Container>
117+
</Body>
118+
</Tailwind>
119+
</Html>
120+
);
121+
};

package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
},
2525
"devDependencies": {
2626
"@biomejs/biome": "1.9.4",
27-
"@commitlint/cli": "^19.8.0",
28-
"@commitlint/config-conventional": "^19.8.0",
27+
"@commitlint/cli": "^19.8.1",
28+
"@commitlint/config-conventional": "^19.8.1",
2929
"@semantic-release/changelog": "^6.0.3",
3030
"@semantic-release/commit-analyzer": "^13.0.1",
3131
"@semantic-release/git": "^10.0.1",
@@ -36,7 +36,7 @@
3636
"husky": "^9.1.7",
3737
"semantic-release": "^24.2.3",
3838
"concurrently": "^9.1.2",
39-
"turbo": "^2.5.2",
39+
"turbo": "^2.5.3",
4040
"typescript": "5.8.3"
4141
},
4242
"lint-staged": {
@@ -51,27 +51,27 @@
5151
"packages/*"
5252
],
5353
"dependencies": {
54-
"@aws-sdk/client-s3": "^3.800.0",
55-
"@aws-sdk/client-securityhub": "^3.799.0",
54+
"@aws-sdk/client-s3": "^3.806.0",
55+
"@aws-sdk/client-securityhub": "^3.806.0",
5656
"@azure/core-http": "^3.0.5",
5757
"@azure/identity": "^4.9.1",
5858
"@hookform/resolvers": "^5.0.1",
5959
"@manypkg/cli": "^0.23.0",
6060
"@number-flow/react": "^0.5.9",
6161
"@prisma/adapter-pg": "6.5.0",
6262
"@types/d3": "^7.4.3",
63-
"@types/react": "^19.1.2",
64-
"ai": "^4.3.13",
63+
"@types/react": "^19.1.3",
64+
"ai": "^4.3.15",
6565
"d3": "^7.9.0",
6666
"dayjs": "^1.11.13",
6767
"gitmoji": "^1.1.1",
6868
"gray-matter": "^4.0.3",
6969
"react": "^19.1.0",
7070
"react-dnd": "^16.0.1",
7171
"react-dnd-html5-backend": "^16.0.1",
72-
"react-hook-form": "^7.56.1",
72+
"react-hook-form": "^7.56.3",
7373
"sharp": "^0.33.5",
7474
"use-debounce": "^10.0.4",
75-
"zod": "^3.24.3"
75+
"zod": "^3.24.4"
7676
}
7777
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import {
2+
Body,
3+
Button,
4+
Container,
5+
Font,
6+
Heading,
7+
Html,
8+
Preview,
9+
Section,
10+
Tailwind,
11+
Text,
12+
} from "@react-email/components";
13+
import { Footer } from "../../components/footer";
14+
import { Logo } from "../../components/logo";
15+
16+
interface Props {
17+
name: string;
18+
}
19+
20+
export const WelcomeEmail = ({
21+
name,
22+
}: Props) => {
23+
return (
24+
<Html>
25+
<Tailwind>
26+
<head>
27+
<Font
28+
fontFamily="Geist"
29+
fallbackFontFamily="Helvetica"
30+
webFont={{
31+
url: "https://cdn.jsdelivr.net/npm/@fontsource/geist-sans@5.0.1/files/geist-sans-latin-400-normal.woff2",
32+
format: "woff2",
33+
}}
34+
fontWeight={400}
35+
fontStyle="normal"
36+
/>
37+
38+
<Font
39+
fontFamily="Geist"
40+
fallbackFontFamily="Helvetica"
41+
webFont={{
42+
url: "https://cdn.jsdelivr.net/npm/@fontsource/geist-sans@5.0.1/files/geist-sans-latin-500-normal.woff2",
43+
format: "woff2",
44+
}}
45+
fontWeight={500}
46+
fontStyle="normal"
47+
/>
48+
</head>
49+
50+
<Preview>Get started with Comp AI</Preview>
51+
52+
<Body className="bg-[#fff] my-auto mx-auto font-sans">
53+
<Container
54+
className="border-transparent md:border-[#E8E7E1] my-[40px] mx-auto p-[20px] max-w-[600px]"
55+
style={{ borderStyle: "solid", borderWidth: 1 }}
56+
>
57+
<Logo />
58+
<Heading className="mx-0 my-[30px] p-0 text-[24px] font-normal text-[#121212] text-center">
59+
Welcome to Comp AI!
60+
</Heading>
61+
62+
<Footer />
63+
</Container>
64+
</Body>
65+
</Tailwind>
66+
</Html>
67+
);
68+
};

packages/email/emails/welcome.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/email/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export * from "./emails/invite-portal";
44
export * from "./emails/magic-link";
55
export * from "./emails/otp";
66
export * from "./emails/waitlist";
7-
export * from "./emails/welcome";
7+
export * from "./emails/marketing/welcome";
88

99
// Email sending functions
1010
export * from "./lib/invite-member";

packages/email/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"@react-email/render": "1.0.6",
2222
"@react-email/tailwind": "1.0.4",
2323
"date-fns": "^4.1.0",
24-
"react-email": "3.0.4",
24+
"react-email": "4.0.11",
2525
"responsive-react-email": "^0.0.5",
2626
"react": "^19.1.0",
2727
"react-dom": "^19.1.0"

packages/integrations/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
"exports": {
3232
".": "./src/index.ts"
3333
}
34-
}
34+
}

packages/notifications/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
},
1313
"dependencies": {
1414
"@novu/node": "^2.0.1",
15-
"nanoid": "5.1.0"
15+
"nanoid": "5.1.5"
1616
},
1717
"devDependencies": {
1818
"typescript": "^5.8.3"
1919
}
20-
}
20+
}

0 commit comments

Comments
 (0)