-
-
Notifications
You must be signed in to change notification settings - Fork 728
Added examples to the intro table and updated react email #1878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,12 +144,13 @@ We recommend using our [Cursor rules](https://trigger.dev/changelog/cursor-rules | |
|
||
#### The generated code | ||
|
||
```tsx trigger/welcome.tsx | ||
```tsx emails/trigger-welcome-email.tsx | ||
import { | ||
Body, | ||
Button,reac | ||
Button, | ||
Container, | ||
Head, | ||
Heading, | ||
Hr, | ||
Html, | ||
Img, | ||
|
@@ -159,11 +160,13 @@ import { | |
Text, | ||
} from "@react-email/components"; | ||
|
||
const baseUrl = process.env.VERCEL_URL | ||
? `https://${process.env.VERCEL_URL}` | ||
: ""; | ||
const baseUrl = process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : ""; | ||
|
||
export const TriggerDevWelcomeEmail = () => ( | ||
export interface TriggerWelcomeEmailProps { | ||
name: string; | ||
} | ||
|
||
export const TriggerWelcomeEmail = ({ name }: TriggerWelcomeEmailProps) => ( | ||
<Html> | ||
<Head /> | ||
<Preview>Welcome to Trigger.dev - Your background jobs platform!</Preview> | ||
|
@@ -177,13 +180,14 @@ export const TriggerDevWelcomeEmail = () => ( | |
alt="Trigger.dev" | ||
/> | ||
<Hr style={hr} /> | ||
<Heading>Welcome, {name}!</Heading> | ||
<Text style={paragraph}> | ||
Thanks for signing up for Trigger.dev! You're now ready to start | ||
creating powerful background jobs and workflows. | ||
Thanks for signing up for Trigger.dev! You're now ready to start creating powerful | ||
background jobs and workflows. | ||
</Text> | ||
<Text style={paragraph}> | ||
You can monitor your jobs, view runs, and manage your projects right | ||
from your dashboard. | ||
You can monitor your jobs, view runs, and manage your projects right from your | ||
dashboard. | ||
</Text> | ||
<Button style={button} href="https://cloud.trigger.dev/dashboard"> | ||
View your Trigger.dev Dashboard | ||
|
@@ -201,9 +205,8 @@ export const TriggerDevWelcomeEmail = () => ( | |
. | ||
</Text> | ||
<Text style={paragraph}> | ||
You can create your first job using our SDK, set up integrations, | ||
and configure triggers to automate your workflows. Take a look at | ||
our{" "} | ||
You can create your first job using our SDK, set up integrations, and configure triggers | ||
to automate your workflows. Take a look at our{" "} | ||
<Link style={anchor} href="https://trigger.dev/docs/examples"> | ||
examples | ||
</Link>{" "} | ||
|
@@ -217,8 +220,7 @@ export const TriggerDevWelcomeEmail = () => ( | |
to connect with other developers and get help when you need it. | ||
</Text> | ||
<Text style={paragraph}> | ||
We're here to help you build amazing things. If you have any | ||
questions, check out our{" "} | ||
We're here to help you build amazing things. If you have any questions, check out our{" "} | ||
<Link style={anchor} href="https://trigger.dev/docs"> | ||
documentation | ||
</Link>{" "} | ||
|
@@ -233,7 +235,7 @@ export const TriggerDevWelcomeEmail = () => ( | |
</Html> | ||
); | ||
|
||
export default TriggerDevWelcomeEmail; | ||
export default TriggerWelcomeEmail; | ||
|
||
const main = { | ||
backgroundColor: "#0E0C15", | ||
|
@@ -288,6 +290,50 @@ const footer = { | |
}; | ||
``` | ||
|
||
And then to trigger the email, you can use the following task: | ||
|
||
```tsx trigger/triggerWelcomeEmail.tsx | ||
import { logger, task } from "@trigger.dev/sdk/v3"; | ||
import { Resend } from "resend"; | ||
import TriggerWelcomeEmail from "emails/triggerdotdev-welcome-email"; | ||
|
||
// Initialize Resend client | ||
const resend = new Resend(process.env.RESEND_API_KEY); | ||
|
||
export const sendEmail = task({ | ||
id: "trigger-welcome-email", | ||
run: async (payload: { to: string; name: string; subject: string; from?: string }) => { | ||
try { | ||
to: payload.to, | ||
}); | ||
|
||
const { data, error } = await resend.emails.send({ | ||
// The from address needs to be a verified email address | ||
from: payload.from || "[email protected]", // Default from address | ||
to: payload.to, | ||
subject: payload.subject, | ||
react: <TriggerWelcomeEmail name={payload.name} />, | ||
}); | ||
|
||
if (error) { | ||
logger.error("Failed to send email", { error }); | ||
throw new Error(`Failed to send email: ${error.message}`); | ||
} | ||
|
||
logger.info("Email sent successfully", { emailId: data?.id }); | ||
|
||
return { | ||
id: data?.id, | ||
status: "sent", | ||
}; | ||
} catch (error) { | ||
logger.error("Unexpected error sending email", { error }); | ||
throw error; | ||
} | ||
}, | ||
}); | ||
``` | ||
|
||
## Learn more | ||
|
||
### React Email docs | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.