Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions apps/app/src/actions/organization/create-organization-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,21 @@ export const createOrganizationAction = authActionClient
const resend = new Resend(process.env.RESEND_API_KEY);

await resend.contacts.create({
firstName: session.user.name?.split(" ")[0] || "",
lastName: session.user.name?.split(" ")[1] || "",
firstName:
session.user.name?.split(" ")[0] ||
session.user.email.split("@")[0] ||
"",
lastName:
session.user.name?.split(" ")[1] ||
session.user.email.split("@")[1] ||
"",
email: session.user.email,
unsubscribed: false,
audienceId: process.env.RESEND_AUDIENCE_ID,
});

await tasks.trigger<typeof newOrgSequence>("new-org-sequence", {
email: session.user.email,
name: session.user.name?.split(" ")[0] || "",
});
}

Expand Down
109 changes: 19 additions & 90 deletions apps/app/src/jobs/tasks/marketing/new-org-sequence.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
import { task, retry, wait, logger } from "@trigger.dev/sdk/v3";
import {
Body,
Button,
Container,
Font,
Heading,
Html,
Preview,
Section,
Tailwind,
Text,
} from "@react-email/components";
import { Footer } from "@comp/email/components/footer";
import { Logo } from "@comp/email/components/logo";
import { task, retry, logger, wait } from "@trigger.dev/sdk/v3";
import { Resend } from "resend";

const resend = new Resend(process.env.RESEND_API_KEY);
Expand All @@ -21,101 +7,44 @@ export const newOrgSequence = task({
id: "new-org-sequence",
run: async (payload: {
email: string;
name: string;
}) => {
logger.info(`Start new sequence for user ${payload.email}`);

await wait.for({ seconds: 5 });
await wait.for({
minutes: 15,
});

const firstEmailResult = await retry.onThrow(
async ({ attempt }) => {
logger.info(`Sending first email to ${payload.email} - attempt ${attempt}`);

const { data, error } = await resend.emails.send({
from: "Lewis Carhart <lewis@mail.trycomp.ai>",
replyTo: "Lewis Carhart <lewis@trycomp.ai>",
to: payload.email,
subject: "Welcome to Comp AI",
react: WelcomeEmail({ name: payload.name }),
subject: "Comp AI",
text: `Hey,

Thanks for signing up to Comp AI! I just wanted to reach out to let you know you can reach out to me anytime by replying to this email, or by booking a call with me here: https://cal.com/team/compai/meet-us

p.s. if you want us to do SOC 2 for you, reply to this email and I can send you some details :)

Best,
Lewis
Founder, Comp AI`
});

if (error) {
throw new Error(error.message);
console.log(error);
}

return data;
},
{ maxAttempts: 3 },
);

await wait.for({ days: 3 });

return {
success: true,
};
},
});

const WelcomeEmail = ({
name,
}: {
name: string;
}) => {
return (
<Html>
<Tailwind>
<head>
<Font
fontFamily="Geist"
fallbackFontFamily="Helvetica"
webFont={{
url: "https://cdn.jsdelivr.net/npm/@fontsource/geist-sans@5.0.1/files/geist-sans-latin-400-normal.woff2",
format: "woff2",
}}
fontWeight={400}
fontStyle="normal"
/>

<Font
fontFamily="Geist"
fallbackFontFamily="Helvetica"
webFont={{
url: "https://cdn.jsdelivr.net/npm/@fontsource/geist-sans@5.0.1/files/geist-sans-latin-500-normal.woff2",
format: "woff2",
}}
fontWeight={500}
fontStyle="normal"
/>
</head>

<Preview>Get started with Comp AI</Preview>

<Body className="bg-[#fff] my-auto mx-auto font-sans">
<Container
className="border-transparent md:border-[#E8E7E1] my-[40px] mx-auto p-[20px] max-w-[600px]"
style={{ borderStyle: "solid", borderWidth: 1 }}
>
<Logo />
<Heading className="mx-0 my-[30px] p-0 text-[24px] font-normal text-[#121212] text-center">
Welcome to Comp AI!
</Heading>

<Section>
<Text className="text-[14px] leading-[24px] text-[#121212]">
Hey {name},
<br />
<br />
We're excited to have you on board with Comp AI. I just wanted to reach out and say welcome!
<br />
<br />
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>
<br />
<br />
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 :)
</Text>
</Section>

<Footer />
</Container>
</Body>
</Tailwind>
</Html>
);
};
});
20 changes: 11 additions & 9 deletions packages/email/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": ["dist/**"],
"files": [
"dist/**"
],
"scripts": {
"build": "tsup index.ts --format cjs,esm --dts",
"dev": "tsup index.ts --format cjs,esm --watch --dts",
Expand All @@ -17,19 +19,19 @@
"dependencies": {
"@comp/ui": "workspace:*",
"@comp/utils": "workspace:*",
"@react-email/components": "0.0.31",
"@react-email/render": "1.0.6",
"@react-email/components": "0.0.36",
"@react-email/render": "0.0.9-canary.2",
"@react-email/tailwind": "1.0.4",
"date-fns": "^4.1.0",
"react-email": "4.0.11",
"responsive-react-email": "^0.0.5",
"react": "^19.1.0",
"react-dom": "^19.1.0"
"react-dom": "^19.1.0",
"react-email": "4.0.11",
"responsive-react-email": "^0.0.5"
},
"devDependencies": {
"typescript": "^5.8.3",
"@types/react": "^19.1.2",
"@types/react-dom": "^19.1.1",
"@types/react": "^19.1.3",
"@types/react-dom": "^19.1.3",
"tsup": "^8.4.0"
}
}
}
Loading