You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Added overview for guides and examples section and split them all out
* New supabase guide wip
* Updated images and improved docs
* Trimmed the supabase prereqs
* Supabase guide wip
* more updates
* Replaced old database webhook guide
* Created one intro page and removed snippets
* Updated guide sidebar titles
* Code updates
* More improvements
* Updates and added images
* Compressed image
* Updated guides descriptions and edge function basic
* Removed bold
* Updated redirects
* Fixed broken links
* Updated intro
description: "This guide will show you how to trigger tasks from database changes using Sequin"
5
5
icon: "database"
6
6
---
@@ -22,9 +22,11 @@ As long as you create an HTTP endpoint that Sequin can deliver webhooks to, you
22
22
You'll need the following to follow this guide:
23
23
24
24
- A Next.js project with [Trigger.dev](https://trigger.dev) installed
25
-
<Info>
26
-
If you don't have one already, follow [Trigger.dev's Next.js setup guide](/guides/frameworks/nextjs) to setup your project. You can return to this guide when you're ready to write your first Trigger.dev task.
27
-
</Info>
25
+
<Info>
26
+
If you don't have one already, follow [Trigger.dev's Next.js setup
27
+
guide](/guides/frameworks/nextjs) to setup your project. You can return to this guide when
28
+
you're ready to write your first Trigger.dev task.
29
+
</Info>
28
30
- A [Sequin](https://console.sequinstream.com/register) account
29
31
- A Postgres database (Sequin works with any Postgres database version 12 and up) with a `posts` table.
30
32
@@ -42,36 +44,36 @@ Start by creating a new Trigger.dev task that takes in a Sequin change event as
42
44
import { OpenAI } from"openai";
43
45
import { upsertEmbedding } from"../util";
44
46
45
-
const openai =newOpenAI({
46
-
apiKey: process.env.OPENAI_API_KEY,
47
-
});
48
-
49
-
exportconst createEmbeddingForPost =task({
50
-
id: "create-embedding-for-post",
51
-
run: async (payload: {
52
-
record: {
53
-
id:number;
54
-
title:string;
55
-
body:string;
56
-
author:string;
57
-
createdAt:string;
58
-
embedding:string|null;
59
-
},
60
-
metadata: {
61
-
table_schema:string,
62
-
table_name:string,
63
-
consumer: {
64
-
id:string;
65
-
name:string;
66
-
};
67
-
};
68
-
}) => {
69
-
// Create an embedding using the title and body of payload.record
@@ -135,63 +141,69 @@ Start by creating a new Trigger.dev task that takes in a Sequin change event as
135
141
</Steps>
136
142
137
143
<Check>
138
-
You've successfully created a Trigger.dev task that will create an embedding for each post in your database. In the next step, you'll create an API endpoint that Sequin can deliver records to.
144
+
You've successfully created a Trigger.dev task that will create an embedding for each post in your
145
+
database. In the next step, you'll create an API endpoint that Sequin can deliver records to.
139
146
</Check>
140
147
141
148
## Setup API route
142
149
143
150
You'll now create an API endpoint that will receive posts from Sequin and then trigger the `create-embedding-for-post` task.
144
151
145
152
<Info>
146
-
This guide covers how to setup an API endpoint using the Next.js App Router. You can find examples for Next.js Server Actions and Pages Router in the [Trigger.dev documentation](https://trigger.dev/docs/guides/frameworks/nextjs).
153
+
This guide covers how to setup an API endpoint using the Next.js App Router. You can find examples
154
+
for Next.js Server Actions and Pages Router in the [Trigger.dev
This route handler will receive records from Sequin, parse them, and then trigger the `create-embedding-for-post` task.
172
183
173
-
This route handler will receive records from Sequin, parse them, and then trigger the `create-embedding-for-post` task.
174
184
</Step>
175
185
<Steptitle="Set secret keys">
176
186
You'll need to set four secret keys in a `.env.local` file:
177
187
178
-
```bash
179
-
SEQUIN_WEBHOOK_SECRET=your-secret-key
180
-
TRIGGER_SECRET_KEY=secret-from-trigger-dev
181
-
OPENAI_API_KEY=sk-proj-asdfasdfasdf
182
-
DATABASE_URL=postgresql://
183
-
```
188
+
```bash
189
+
SEQUIN_WEBHOOK_SECRET=your-secret-key
190
+
TRIGGER_SECRET_KEY=secret-from-trigger-dev
191
+
OPENAI_API_KEY=sk-proj-asdfasdfasdf
192
+
DATABASE_URL=postgresql://
193
+
```
184
194
185
-
The `SEQUIN_WEBHOOK_SECRET` ensures that only Sequin can access your API endpoint.
195
+
The `SEQUIN_WEBHOOK_SECRET` ensures that only Sequin can access your API endpoint.
186
196
187
-
The `TRIGGER_SECRET_KEY` is used to authenticate requests to Trigger.dev and can be found in the **API keys** tab of the Trigger.dev dashboard.
197
+
The `TRIGGER_SECRET_KEY` is used to authenticate requests to Trigger.dev and can be found in the **API keys** tab of the Trigger.dev dashboard.
198
+
199
+
The `OPENAI_API_KEY` and `DATABASE_URL` are used to create an embedding using OpenAI and connect to your database. Be sure to add these as [environment variables](https://trigger.dev/docs/deploy-environment-variables) in Trigger.dev as well.
188
200
189
-
The `OPENAI_API_KEY` and `DATABASE_URL` are used to create an embedding using OpenAI and connect to your database. Be sure to add these as [environment variables](https://trigger.dev/docs/deploy-environment-variables) in Trigger.dev as well.
190
201
</Step>
191
202
</Steps>
192
203
193
204
<Check>
194
-
You've successfully created an API endpoint that can receive record payloads from Sequin and trigger a Trigger.dev task. In the next step, you'll setup Sequin to trigger the endpoint.
205
+
You've successfully created an API endpoint that can receive record payloads from Sequin and
206
+
trigger a Trigger.dev task. In the next step, you'll setup Sequin to trigger the endpoint.
195
207
</Check>
196
208
197
209
## Create Sequin consumer
@@ -253,11 +265,10 @@ You'll now configure Sequin to send every row in your `posts` table to your Trig
253
265
</Frame>
254
266
7. Click the **Create Consumer** button.
255
267
</Step>
268
+
256
269
</Steps>
257
270
258
-
<Check>
259
-
Your Sequin consumer is now created and ready to send events to your API endpoint.
260
-
</Check>
271
+
<Check>Your Sequin consumer is now created and ready to send events to your API endpoint.</Check>
261
272
262
273
## Test end-to-end
263
274
@@ -301,10 +312,12 @@ You'll now configure Sequin to send every row in your `posts` table to your Trig
Every time a post is created or updated, Sequin will deliver the row payload to your API endpoint and Trigger.dev will run the `create-embedding-for-post` task.
319
+
Every time a post is created or updated, Sequin will deliver the row payload to your API endpoint
320
+
and Trigger.dev will run the `create-embedding-for-post` task.
308
321
</Check>
309
322
310
323
## Next steps
@@ -314,4 +327,4 @@ With Sequin and Trigger.dev, every post in your database will now have an embedd
314
327
From here, add error handling and deploy to production:
315
328
316
329
- Add [retries](/errors-retrying) to your Trigger.dev task to ensure that any errors are captured and logged.
317
-
- Deploy to [production](/guides/frameworks/nextjs#deploying-your-task-to-trigger-dev) and update your Sequin consumer to point to your production database and endpoint.
330
+
- Deploy to [production](/guides/frameworks/nextjs#deploying-your-task-to-trigger-dev) and update your Sequin consumer to point to your production database and endpoint.
Copy file name to clipboardExpand all lines: docs/guides/frameworks/supabase-edge-functions-basic.mdx
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,7 @@ This guide shows you how to set up and deploy a simple Supabase edge function ex
26
26
## Prerequisites
27
27
28
28
- Ensure you have the [Supabase CLI](https://supabase.com/docs/guides/cli/getting-started) installed
29
+
- Since Supabase CLI version 1.123.4, you must have [Docker Desktop installed](https://supabase.com/docs/guides/functions/deploy#deploy-your-edge-functions) to deploy Edge Functions
29
30
- Ensure TypeScript is installed
30
31
-[Create a Trigger.dev account](https://cloud.trigger.dev)
31
32
-[Create a new Trigger.dev project](/guides/dashboard/creating-a-project)
0 commit comments