Skip to content

Commit 6014359

Browse files
committed
Updated images and improved docs
1 parent 45c27c1 commit 6014359

7 files changed

+41
-45
lines changed

docs/guides/frameworks/supabase-edge-functions-ffmpeg-deepgram.mdx

Lines changed: 41 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,14 @@ description: "This guide shows you how to trigger a task when a row is added to
77
import Prerequisites from "/snippets/framework-prerequisites.mdx";
88
import SupabasePrerequisites from "/snippets/supabase-prerequisites.mdx";
99
import CliInitStep from "/snippets/step-cli-init.mdx";
10-
import CliDevStep from "/snippets/step-cli-dev.mdx";
11-
import CliRunTestStep from "/snippets/step-run-test.mdx";
12-
import CliViewRunStep from "/snippets/step-view-run.mdx";
1310
import UsefulNextSteps from "/snippets/useful-next-steps.mdx";
1411
import TriggerTaskNextjs from "/snippets/trigger-tasks-nextjs.mdx";
1512
import NextjsTroubleshootingMissingApiKey from "/snippets/nextjs-missing-api-key.mdx";
1613
import NextjsTroubleshootingButtonSyntax from "/snippets/nextjs-button-syntax.mdx";
1714
import WorkerFailedToStartWhenRunningDevCommand from "/snippets/worker-failed-to-start.mdx";
1815
import SupabaseDocsCards from "/snippets/supabase-docs-cards.mdx";
1916

20-
## Overview
17+
## Workflow overview
2118

2219
Generate a transcription from a video URL using [Supabase](https://supabase.com), [FFmpeg](https://www.ffmpeg.org/) and [Deepgram](https://deepgram.com) and Trigger.dev.
2320

@@ -40,25 +37,24 @@ The Edge Function triggers a deployed Trigger.dev task which takes a payload fro
4037
- Ensure TypeScript is installed
4138
- [Create a Trigger.dev account](https://cloud.trigger.dev)
4239
- [Create a new Trigger.dev project](/guides/dashboard/creating-a-project)
43-
- [Create a new Deepgram account](https://deepgram.com/)
40+
- [Create a new Deepgram account](https://deepgram.com/) and get your API key from the dashboard
4441

4542
## Initial setup
4643

4744
<Steps>
4845
<SupabasePrerequisites />
4946
<CliInitStep />
50-
<CliDevStep />
51-
<CliRunTestStep />
52-
<CliViewRunStep />
5347
</Steps>
5448

5549
## Create and deploy the video processing Trigger.dev task
5650

57-
Before setting up your Edge Function and Database Webhook, you'll first need to create your Trigger.dev task. This can be tested independently from the rest of the setup.
51+
Before setting up your Edge Function and Database Webhook, you'll need to create your Trigger.dev task. This can be tested independently from the rest of the workflow.
5852

59-
Create a new task file in your `/trigger` folder (the same place your example task is). Call it `videoProcessAndUpdate.ts`.
53+
Create a new task file in your `/trigger` folder (the same place your 'Hello World' task is). Call it `videoProcessAndUpdate.ts`.
6054

61-
This task with take a video url, extract the audio using FFmpeg and transcribe the audio using Deepgram. We will add the Supabase `update` step further on in the tutorial.
55+
This task with take a video from a public video url, extract the audio using FFmpeg and transcribe the audio using Deepgram.
56+
57+
<Note>We will add the Supabase `update` step further on in the tutorial.</Note>
6258

6359
```ts /trigger/videoProcessAndUpdate.ts
6460
import { createClient as createDeepgramClient } from "@deepgram/sdk";
@@ -144,12 +140,11 @@ export const videoProcessAndUpdate = task({
144140
### Adding the FFmpeg build extension
145141

146142
<Note>
147-
{" "}
148-
This task can also be tested in `dev` without adding the build extension, but we recommend adding the**
149-
** extension during the setup process.{" "}
143+
This task can also be tested in `dev` without adding the build extension, but we recommend adding
144+
the extension during the setup process.
150145
</Note>
151146

152-
Before you can deploy and test the task, you'll first need to add our FFmpeg extension to your project configuration like this:
147+
Before you can deploy the task, you'll need to add our FFmpeg extension:
153148

154149
```ts trigger.config.ts
155150
import { ffmpeg } from "@trigger.dev/build/extensions/core";
@@ -172,9 +167,15 @@ export default defineConfig({
172167

173168
You'll also need to add `@trigger.dev/build` to your `package.json` file under `devDependencies` if you don't already have it there.
174169

170+
### Adding the Deepgram environment variable
171+
172+
You will need to add your `DEEPGRAM_SECRET_KEY` as an environment variable in your Trigger.dev project. You can do this in the Trigger.dev dashboard under the 'environment variables' tab.
173+
174+
![Adding environment variables](/images/environment-variables-page.jpg)
175+
175176
### Deploying your task
176177

177-
You can now deploy your task and test it in the dashboard.
178+
You can now deploy your task and test it in the Trigger.dev [dashboard](https://cloud.trigger.dev).
178179

179180
<CodeGroup>
180181

@@ -194,17 +195,17 @@ yarn dlx trigger.dev@latest deploy
194195

195196
### Testing your task
196197

197-
To test this task in the dashboard, you can use the following payload:
198+
To test this task in the dashboard, select the `prod` environment and use the following payload:
198199

199200
```json
200201
{
201202
"audioUrl": "https://dpgr.am/spacewalk.wav"
202203
}
203204
```
204205

205-
Congratulations, You should now see the video transcription in a successful run.
206+
Congratulations! You should now see the video transcription logged in a successful run.
206207

207-
## Create and deploy the Edge Function and configure the Database Webhook
208+
## Create and deploy a Supabase Edge Function and configure the Database Webhook
208209

209210
### Add your Trigger.dev prod secret key to the Supabase dashboard
210211

@@ -220,7 +221,7 @@ Add `TRIGGER_SECRET_KEY` <Icon icon="circle-4" iconType="solid" size={20} color=
220221

221222
### Create a new Edge Function using the Supabase CLI
222223

223-
Now create a new Edge Function using the Supabase CLI. We will call it `video-processing-handler`. This will trigger our task using the data received from the Database Webhook.
224+
Now create an Edge Function using the Supabase CLI. Call it `video-processing-handler`. This will trigger your task using the data received from the Database Webhook.
224225

225226
```bash
226227
supabase functions new video-processing-handler
@@ -249,7 +250,6 @@ Deno.serve(async (req) => {
249250
});
250251
```
251252

252-
<Note>You can only import the `type` from the task.</Note>
253253
<Note>
254254
Tasks in the `trigger` folder use Node, so they must stay in there or they will not run,
255255
especially if you are using a different runtime like Deno. Also do not add "`npm:`" to imports
@@ -274,20 +274,17 @@ There will be a link to the dashboard in your terminal output, or you can find i
274274

275275
### Create a new table in your Supabase dashboard
276276

277-
Next, in your Supabase project dashboard, click on 'Table Editor' <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" /> in the left-hand menu and create a new table. <Icon icon="circle-2" iconType="solid" size={20} color="A8FF53" />
277+
Next, in your Supabase dashboard, click on 'Table Editor' <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" /> in the left-hand menu and create a new table. <Icon icon="circle-2" iconType="solid" size={20} color="A8FF53" />
278278

279279
![How to create a new table](/images/supabase-new-table-1.png)
280280

281-
In this example we will call our table `video_transcriptions`. <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" />
282-
283-
Add two new columns, one called `video_url` with the type `text`, and another called `transcription`, also with the type `text`. <Icon icon="circle-2" iconType="solid" size={20} color="A8FF53" />
281+
Call your table `video_transcriptions`. <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" />
284282

285-
<Warning> REPLACE IMAGE BELOW</Warning>
286-
![How to add a new column](/images/supabase-new-table-2.png)
283+
Add two new columns, one called `video_url` with the type `text` <Icon icon="circle-2" iconType="solid" size={20} color="A8FF53" />, and another called `transcription`, also with the type `text` <Icon icon="circle-3" iconType="solid" size={20} color="A8FF53" />.
287284

288285
### Create a new Database Webhook
289286

290-
First, go to your Supabase project dashboard, click 'Project settings' <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" />, then the 'API' tab <Icon icon="circle-2" iconType="solid" size={20} color="A8FF53" />, and copy the `anon` `public` API key from the table <Icon icon="circle-3" iconType="solid" size={20} color="A8FF53" />.
287+
In your Supabase project dashboard, click 'Project settings' <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" />, then the 'API' tab <Icon icon="circle-2" iconType="solid" size={20} color="A8FF53" />, and copy the `anon` `public` API key from the table <Icon icon="circle-3" iconType="solid" size={20} color="A8FF53" />.
291288

292289
![How to find your Supabase API keys](/images/supabase-api-key.png)
293290

@@ -324,14 +321,14 @@ and select the Edge Function you have created: `video-processing-handler`.{" "}
324321

325322
Your Database Webhook is now ready to use.
326323

327-
### Triggering the task
324+
## Triggering the task
328325

329-
### Enabling updates to your supabase tables
326+
### Adding the logic to update the table row
330327

331-
First, you must go back to your task code and add in the Supabase logic:
328+
First, you must go back to your `videoProcessAndUpdate` task code from earlier and add in the Supabase logic. This will:
332329

333-
- Creating a Supabase client (you must update your environment variables in order for this to work)
334-
- Function to update the table row with the exact match of the `video_url` payload with the new transcription
330+
- Create a Supabase client (you must update your environment variables in order for this to work)
331+
- Create a function which updates the table row with the exact match of the `video_url` payload with the new generated transcription.
335332

336333
```ts /trigger/videoProcessAndUpdate.ts
337334
import { createClient as createDeepgramClient } from "@deepgram/sdk";
@@ -434,31 +431,30 @@ export const videoProcessAndUpdate = task({
434431
});
435432
```
436433

437-
### Testing the entire setup
434+
### Adding your Supabase environment variables
435+
436+
You will need to add your `SUPABASE_PROJECT_URL` and `SUPABASE_SERVICE_ROLE_KEY` as environment variables in your Trigger.dev project.
437+
438+
![Adding environment variables](/images/environment-variables-page.jpg)
439+
440+
### Testing the entire workflow
438441

439442
Your `video-processing-handler` Edge Function is now set up to trigger the `videoProcessAndUpdate` task every time a new row is inserted into your `video_transcriptions` table.
440443

441444
To do this, go back to your Supabase project dashboard, click on 'Table Editor' <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" /> in the left-hand menu, click on the `video_transcriptions` table <Icon icon="circle-2" iconType="solid" size={20} color="A8FF53" /> , and then click 'Insert', 'Insert Row' <Icon icon="circle-3" iconType="solid" size={20} color="A8FF53" />.
442445

443446
![How to insert a new row 1](/images/supabase-new-table-3.png)
444447

445-
Add a new item under `video_url`, with a public video url. <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" />
448+
Add a new item under `video_url`, with a public video url. <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" />.
446449

447-
<Warning> CHANGE IMAGE BELOW </Warning>
450+
You can use the following public video URL for testing: `https://dpgr.am/spacewalk.wav`.
448451

449452
![How to insert a new row 2](/images/supabase-new-table-4.png)
450453

451-
<Warning> CHANGE IMAGE BELOW </Warning>
452-
453-
![How to view the logs](/images/supabase-logs.png)
454-
455-
Then, check your [cloud.trigger.dev](http://cloud.trigger.dev) project 'Runs' list <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" /> and you should see a processing `videoProcessAndUpdate` task <Icon icon="circle-2" iconType="solid" size={20} color="A8FF53" /> which has been triggered when you added a new row with the video url to your `video_transcriptions` table.
454+
Once the new table row has been inserted, check your [cloud.trigger.dev](http://cloud.trigger.dev) project 'Runs' list <Icon icon="circle-1" iconType="solid" size={20} color="A8FF53" /> and you should see a processing `videoProcessAndUpdate` task <Icon icon="circle-2" iconType="solid" size={20} color="A8FF53" /> which has been triggered when you added a new row with the video url to your `video_transcriptions` table.
456455

457456
Once the run has completed successfully, go back to your Supabase `video_transcriptions` table, and you should see that in the row containing the original video URL, the transcription has now been added to the `transcription` column.
458457

459-
<Warning> REPLACE BELOW IMAGE </Warning>
460-
![How to insert a new row 2](/images/supabase-trigger-screenshot.png)
461-
462-
**Congratulations! You have completed a full loop from Supabase to Trigger.dev and back again.**
458+
**Congratulations! You have completed the full workflow from Supabase to Trigger.dev and back again.**
463459

464460
<SupabaseDocsCards />
16.6 KB
Loading
16.4 KB
Loading

docs/images/supabase-new-table-2.png

86.1 KB
Loading

docs/images/supabase-new-table-3.png

822 Bytes
Loading

docs/images/supabase-new-table-4.png

352 KB
Loading
16.2 KB
Loading

0 commit comments

Comments
 (0)