Skip to content

Commit 4085ad9

Browse files
authored
Merge pull request #12 from triggerdotdev/dev
Resend.com integration, fix for github webhooks, and more
2 parents 63776c7 + 3caa793 commit 4085ad9

73 files changed

Lines changed: 4490 additions & 268 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
![](apps/webapp/public/images/coming-soon-banner.png)
1+
### The Trigger.dev Private beta is now open. Sign up for access [here](https://bcymafitv0e.typeform.com/tddsignup#source=GitHubReadme).
22

3+
 
34

4-
### We are now accepting users 😊! Request early access [here](https://bcymafitv0e.typeform.com/tddsignup#source=GitHubReadme).
5+
![Hero](https://raw.githubusercontent.com/triggerdotdev/trigger.dev/eebe37109e33beae6390ee19029fce8a5934c84b/apps/webapp/public/images/logo-banner.png)
56

6-
 
77

88
---
99

@@ -12,7 +12,9 @@
1212

1313
![Logo](https://trigger.dev/_next/static/media/triggerdotdev-logo.9226e5d0.png?imwidth=256)
1414

15-
[![Twitter Follow](https://img.shields.io/twitter/follow/triggerdotdev)](https://twitter.com/intent/follow?screen_name=triggerdotdev)
15+
[![Twitter](https://img.shields.io/twitter/url/https/twitter.com/triggerdotdev.svg?style=social&label=Follow%20%40trigger.dev)](https://twitter.com/triggerdotdev)
16+
17+
1618

1719
# ⚙️ Automate complex workflows with code
1820

apps/docs/examples/examples.mdx

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
---
22
title: "Example workflows"
3-
sidebarTitle: "Example workflows"
4-
description: "Example workflows."
3+
sidebarTitle: "Overview"
4+
description: "Example workflows to use in your projects."
55
---
66

7-
# Example workflows
7+
<Warning>
8+
Trigger.dev is in private beta. We are now inviting users from our waitlist
9+
[here.](https://bcymafitv0e.typeform.com/tddsignup?typeform-source=trigger.dev#source=Docs)
10+
</Warning>
11+
12+
Not sure what to build? Take a look through our examples for inspiration.
13+
You can use these workflows in your product by following the instructions on each page.
814

915
<CardGroup>
10-
<Card title="GitHub" icon="rectangle-terminal" href="/examples/github"></Card>
11-
<Card
12-
title="Shopify"
13-
icon="rectangle-terminal"
14-
href="/examples/shopify"
15-
></Card>
16-
<Card title="Slack" icon="rectangle-terminal" href="/examples/slack"></Card>
16+
<Card title="GitHub" icon="github" href="/examples/github">
17+
When a GitHub issue is created or modified, post a message to Slack.
18+
</Card>
19+
<Card title="Shopify" icon="shopify" href="/examples/shopify">
20+
Create a new product in my Shopify store.
21+
</Card>
22+
<Card title="Slack" icon="slack" href="/examples/slack">
23+
Post to Slack when a GitHub issue is created or modified.
24+
</Card>
25+
<Card title="Resend" icon="envelope" href="/examples/resend"></Card>
1726
</CardGroup>

apps/docs/functions/logging.mdx

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,38 @@ sidebarTitle: "Logging"
44
description: "There are 4 different types of logs you can add as workflow steps."
55
---
66

7-
## Coming soon
7+
If you'd like to add additional logging to your workflow run, you can use our built-in logging utility
8+
9+
## Usage
10+
11+
```ts
12+
import { Trigger } from "@trigger.dev/sdk";
13+
14+
new Trigger({
15+
id: "my-trigger",
16+
on: scheduleEvent({ rateOf: { minutes: 5 } }),
17+
run: async (event, ctx) => {
18+
await ctx.logger.info("It's been 5 minutes since the last run!");
19+
},
20+
}).listen();
21+
```
22+
23+
This will log the message to your workflow run page in the Trigger dashboard
24+
25+
There are 4 different types of logs you can add as workflow steps:
26+
27+
```ts
28+
await ctx.logger.info("It's been 5 minutes since the last run!");
29+
await ctx.logger.debug("This is a debug log");
30+
await ctx.logger.warn("This is a warning");
31+
await ctx.logger.error("This is an error");
32+
```
33+
34+
You can also include a second argument to the logger to add additional metadata to the log:
35+
36+
```ts
37+
await ctx.logger.info("It's been 5 minutes since the last run!", {
38+
foo: "bar",
39+
baz: 123,
40+
});
41+
```

apps/docs/functions/loops-conditionals-etc.mdx

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,47 @@ sidebarTitle: "Loops, Conditionals…"
44
description: "Write any type of code."
55
---
66

7-
## Coming soon
7+
Currently, we don't have anything special for loops or conditionals. You can just write plain-old TypeScript code and it will Just Work™.
8+
9+
## Loops
10+
11+
When you perform an action (sendEvent, delays, etc.) inside of a loop, make sure to create unique keys for each action to make sure that your workflows are [Resumable](/guides/resumability):
12+
13+
```ts
14+
for (let i = 0; i < 10; i++) {
15+
await ctx.waitFor(`Wait ${i}`, { seconds: 30 });
16+
17+
await slack.postMessage(`⭐️ New Star ${i}`, {
18+
channelName: "github-stars",
19+
text: `@${starredBy} just starred ${repoName}!`,
20+
});
21+
}
22+
```
23+
24+
## Parallel Execution
25+
26+
You can run actions in parallel using `Promise.all`, like so:
27+
28+
```ts
29+
await Promise.all(
30+
messages.map((message) =>
31+
slack.postMessage(message.id, {
32+
channelName: "github-stars",
33+
text: message.text,
34+
})
35+
)
36+
);
37+
```
38+
39+
## Conditionals
40+
41+
You can use `if` statements to conditionally execute code, just like normal code:
42+
43+
```ts
44+
if (ctx.event.payload.action === "opened") {
45+
await slack.postMessage("New Issue", {
46+
channelName: "github-issues",
47+
text: `@${ctx.event.payload.sender.login} just opened an issue!`,
48+
});
49+
}
50+
```

apps/docs/get-help.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: "Get in touch with us!"
3+
sidebarTitle: "Get help"
4+
description: "Contact us if you have any questions, or would like help with any issues."
5+
---
6+
7+
<Note>We are active in the community and will respond to all messages.</Note>
8+
9+
Please email us at <a href="mailto:help@trigger.dev">help@trigger.dev</a> or choose one of the options below:
10+
11+
<CardGroup>
12+
<Card
13+
title="Join the communty"
14+
icon="discord"
15+
href="https://discord.gg/nkqV9xBYWy"
16+
>
17+
The place to meet other users, the team and to get product updates.
18+
</Card>
19+
<Card
20+
title="Schedule a call"
21+
icon="video"
22+
href="https://cal.com/team/triggerdotdev/support"
23+
>
24+
A call with someone from our support team. We are happy to help.
25+
</Card>
26+
</CardGroup>

apps/docs/getting-started.mdx

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ sidebarTitle: "Quick start"
44
description: "Get your first workflow running in just a few minutes"
55
---
66

7+
<Warning>
8+
Trigger.dev is in private beta. We are now inviting users from our waitlist
9+
[here.](https://bcymafitv0e.typeform.com/tddsignup?typeform-source=trigger.dev#source=Docs)
10+
</Warning>
11+
712
Trigger.dev workflows are written in your codebase and run in your existing infrastructure. This means:
813

914
- They are version controlled with the rest of your code.
@@ -182,6 +187,15 @@ When you run your server and this code executes, it will trigger the workflow. Y
182187

183188
## Next steps
184189

190+
<Card
191+
title="Join the communty"
192+
icon="discord"
193+
href="https://discord.gg/nkqV9xBYWy"
194+
>
195+
Meet other users, get help and product updates. We will respond to all
196+
messages and will help with any issues.
197+
</Card>
198+
185199
There are many things we didn't cover here, including Webhook and Scheduled triggers. Below are a some more features to explore:
186200

187201
### Triggers
@@ -192,13 +206,13 @@ Triggers are what cause your workflows to run.
192206
<Card title="Webhooks" icon="rectangle-terminal" href="/triggers/webhooks">
193207
Easily subscribe to the APIs you're using
194208
</Card>
195-
<Card title="Scheduled" icon="sliders" href="/triggers/scheduled">
209+
<Card title="Scheduled" icon="clock" href="/triggers/scheduled">
196210
Trigger your workflows on a repeating schedule
197211
</Card>
198-
<Card title="Custom events" icon="heading" href="/triggers/custom-events">
212+
<Card title="Custom events" icon="code" href="/triggers/custom-events">
199213
More details on custom events
200214
</Card>
201-
<Card title="More coming soon" icon="heading">
215+
<Card title="More coming soon" icon="bookmark">
202216
On received email, HTTP endpoint and AWS Event Bridge
203217
</Card>
204218
</CardGroup>
@@ -213,11 +227,14 @@ Triggers are what cause your workflows to run.
213227
>
214228
We are making it easy to use lots of APIs by adding integrations.
215229
</Card>
216-
<Card title="Delays" icon="sliders" href="/functions/delays">
230+
<Card title="Fetch" icon="server" href="/functions/fetch">
231+
Call any API from your workflow
232+
</Card>
233+
<Card title="Delays" icon="alarm-clock" href="/functions/delays">
217234
Add delays to your workflows. They're resilient so it doesn't matter if your
218235
server goes down.
219236
</Card>
220-
<Card title="Send event" icon="heading" href="/functions/send-event">
237+
<Card title="Send event" icon="code" href="/functions/send-event">
221238
Send an event, to trigger a custom event workflow
222239
</Card>
223240
</CardGroup>

apps/docs/guides/event-driven.mdx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: "Event Driven Architecture"
3+
sidebarTitle: "Event Driven"
4+
description: "How to build an event driven architecture using Trigger.dev"
5+
---
6+
7+
## Intro
8+
9+
Coming soon...

apps/docs/guides/resumability.mdx

Lines changed: 67 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,72 @@
11
---
22
title: "Resumability"
33
sidebarTitle: "Keys and Resumability"
4-
description: "Keys and Resumability"
4+
description: "Understand how keys work to ensure resumability of long-running workflows in Trigger.dev"
55
---
66

7-
## Coming soon
7+
## Intro
8+
9+
In this article, we'll cover how Trigger.dev handles resumability of long-running workflows. We'll also cover how to use keys to ensure that your workflows are resumable.
10+
11+
## What is resumability?
12+
13+
Resumability is the ability of a workflow run to continue from where it left off after a failure or interruption. For example, if a workflow run is interrupted due to a network failure, it should be able to resume from where it left off when the network is back up.
14+
15+
We accomplish this by storing the state of the workflow run in a database, and when a workflow run is resumed we will call the `Trigger.run` function again.
16+
17+
We use step "keys" to determine which steps have already been executed. If a step has already been executed, we will skip it and move on to the next step.
18+
19+
## How to use keys
20+
21+
Like we mentioned above, we use step keys to determine which steps have already been executed. They are defined by you inside your `Trigger.run` function, for example when you call `slack.postMessage`:
22+
23+
```ts
24+
await slack.postMessage("⭐️ New Star", {
25+
channelName: "github-stars",
26+
text: `@${starredBy} just starred ${repoName}!`,
27+
});
28+
```
29+
30+
In this example, the key is the string `"⭐️ New Star"`. This means that if the workflow is interrupted and then resumed, the `slack.postMessage` step will be skipped because it has already been executed.
31+
32+
If you make multiple calls to `slack.postMessage`, you should use different keys for each call. For example:
33+
34+
```ts
35+
await slack.postMessage("⭐️ New Star", {
36+
channelName: "github-stars",
37+
text: `@${starredBy} just starred ${repoName}!`,
38+
});
39+
40+
await slack.postMessage("🚨 Critical Issue", {
41+
channelName: "critical-issues",
42+
text: `@${assignee} just opened a critical issue in ${repoName}!`,
43+
});
44+
```
45+
46+
If you are calling a step multiple times with the same key, it will only be executed once. For example, if you call `slack.postMessage` with the key `"⭐️ New Star"` twice, it will only be executed once.
47+
48+
## How to use keys with loops
49+
50+
If you are using a loop, you should use the loop index as the key. For example:
51+
52+
```ts
53+
for (let i = 0; i < 10; i++) {
54+
await ctx.waitFor(`Wait ${i}`, { seconds: 30 });
55+
56+
await slack.postMessage(`⭐️ New Star ${i}`, {
57+
channelName: "github-stars",
58+
text: `@${starredBy} just starred ${repoName}!`,
59+
});
60+
}
61+
```
62+
63+
## When to use keys
64+
65+
The following functions in Trigger.dev require a `key` parameter:
66+
67+
- Integration actions (e.g. `slack.postMessage`)
68+
- [delays](/functions/delays)
69+
- [sendEvent](/functions/send-event)
70+
- [fetch](/functions/fetch)
71+
72+
[Logging](/functions/logging) does not require a key, as we are currently using the log message as the key.

0 commit comments

Comments
 (0)