Skip to content

Commit 796f120

Browse files
authored
Docs/sendgrid doc (#359)
* added sengrid integration to the catalog * added documention for sendgrid integration * updated the mint.json file
1 parent 4ce96b7 commit 796f120

File tree

4 files changed

+156
-2
lines changed

4 files changed

+156
-2
lines changed

apps/webapp/app/services/externalApis/integrationCatalog.server.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { plain } from "./integrations/plain";
44
import { resend } from "./integrations/resend";
55
import { slack } from "./integrations/slack";
66
import { stripe } from "./integrations/stripe";
7+
import { sendgrid } from "./integrations/sendgrid";
78
import { supabaseManagement, supabase } from "./integrations/supabase";
89
import { typeform } from "./integrations/typeform";
910
import type { Integration } from "./types";
@@ -34,8 +35,9 @@ export const integrationCatalog = new IntegrationCatalog({
3435
plain,
3536
resend,
3637
slack,
37-
typeform,
3838
stripe,
3939
supabaseManagement,
4040
supabase,
41+
sendgrid,
42+
typeform,
4143
});
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import type { Integration } from "../types";
2+
3+
export const sendgrid: Integration = {
4+
identifier: "sendgrid",
5+
name: "SendGrid",
6+
packageName: "@trigger.dev/sendgrid@latest",
7+
authenticationMethods: {
8+
apikey: {
9+
type: "apikey",
10+
help: {
11+
samples: [
12+
{
13+
title: "Creating the client",
14+
code: `
15+
import { SendGrid } from "@trigger.dev/sendgrid";
16+
17+
const sendgrid = new SendGrid({
18+
id: "__SLUG__",
19+
apiKey: process.env.SENDGRID_API_KEY!,
20+
});
21+
`,
22+
},
23+
{
24+
title: "Using the client",
25+
code: `
26+
client.defineJob({
27+
id: "send-sendgrid-email",
28+
name: "Send SendGrid Email",
29+
version: "0.1.0",
30+
trigger: eventTrigger({
31+
name: "send.email",
32+
schema: z.object({
33+
to: z.string(),
34+
subject: z.string(),
35+
text: z.string(),
36+
}),
37+
}),
38+
integrations: {
39+
sendgrid,
40+
},
41+
run: async (payload, io, ctx) => {
42+
await io.sendgrid.sendEmail({
43+
to: payload.to,
44+
from: "Trigger.dev <[email protected]>",
45+
subject: payload.subject,
46+
text: payload.text,
47+
});
48+
},
49+
});
50+
`,
51+
highlight: [
52+
[13, 15],
53+
[17, 22],
54+
],
55+
},
56+
],
57+
},
58+
},
59+
},
60+
};

docs/integrations/apis/sendgrid.mdx

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: Introduction
3+
---
4+
5+
<Snippet file="integration-getting-started.mdx" />
6+
7+
## Installation
8+
9+
<CodeGroup>
10+
11+
```bash npm
12+
npm install @trigger.dev/sendgrid@latest
13+
```
14+
15+
```bash pnpm
16+
pnpm install @trigger.dev/sendgrid@latest
17+
```
18+
19+
```bash yarn
20+
yarn add @trigger.dev/sendgrid@latest
21+
```
22+
23+
</CodeGroup>
24+
25+
## Authentication
26+
27+
SendGrid integration supports API Keys. To authenticate, you'll need to create an instance of the SendGrid class and provide your API key.
28+
29+
```ts
30+
import { SendGrid } from "@trigger.dev/sendgrid";
31+
32+
const sendgrid = new SendGrid({
33+
id: "sendgrid",
34+
apiKey: process.env.SENDGRID_API_KEY!,
35+
});
36+
37+
```
38+
39+
## Example
40+
41+
In this example we use [Zod](/documentation/guides/zod), a TypeScript-first schema declaration and validation library.
42+
43+
```ts
44+
import { SendGrid } from "@trigger.dev/sendgrid";
45+
import { Job, eventTrigger } from "@trigger.dev/sdk";
46+
import { z } from "zod";
47+
48+
// Create an instance of SendGrid
49+
const sendgrid = new SendGrid({
50+
id: "sendgrid",
51+
apiKey: process.env.SENDGRID_API_KEY!,
52+
});
53+
54+
// Define a Trigger.dev job
55+
client.defineJob({
56+
id: "send-sendgrid-email",
57+
name: "Send SendGrid Email",
58+
version: "0.1.0",
59+
trigger: eventTrigger({
60+
name: "send.email",
61+
schema: z.object({
62+
to:z.string(),
63+
subject: z.string(),
64+
text: z.string(),
65+
}),
66+
}),
67+
integrations: {
68+
sendgrid,
69+
},
70+
run: async (payload, io, ctx) => {
71+
await io.sendgrid.sendEmail({
72+
to: payload.to,
73+
from: "Trigger.dev <[email protected]>",
74+
subject: payload.subject,
75+
text: payload.text,
76+
});
77+
},
78+
});
79+
80+
```
81+
82+
## Tasks
83+
84+
| Function Name | Description |
85+
| ------------- | ------------- |
86+
| `sendEmail` | Send an email |

docs/mint.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,13 @@
213213
"integrations/apis/slack"
214214
]
215215
},
216-
"integrations/apis/typeform"
216+
"integrations/apis/typeform",
217+
{
218+
"group": "Sendgrid",
219+
"pages": [
220+
"integrations/apis/sendgrid"
221+
]
222+
}
217223
]
218224
},
219225
{

0 commit comments

Comments
 (0)