This guide shows you how to trigger a transcribing task when a row is added to a table in a Supabase database, using a Database Webhook and Edge Function.
video_url
column data from the new table row as the payload
Optional step 1: create a new Supabase project
Optional step 2: create a package.json file
package.json
file (e.g. if you are using Deno), create it manually in your project’s root folder.package.json
file you can skip this step.Run the CLI `init` command
/trigger
folder and give you an example task.Run this command in the root of your project to get started:trigger.config.ts
file in the root of your project./trigger
directory./trigger
directory with an example task, /trigger/example.[ts/js]
.video_transcriptions
.
Add two new columns, one called video_url
with the type text
, and another called transcription
, also with the type text
.
<project-ref>
with your Supabase project reference ID. This can be found in your Supabase project settings under ‘General’. /trigger
folder. Call it videoProcessAndUpdate.ts
.
This task takes a video from a public video url, extracts the audio using FFmpeg and transcribes the audio using Deepgram. The transcription summary will then be updated back to the original row in the video_transcriptions
table in Supabase.
You will need to install some additional dependencies for this task:
trigger.config.ts
file.
@trigger.dev/build
to your package.json
file under devDependencies
if you don’t already have it there.fluent-ffmpeg
you’ll also need to add them to external
in your trigger.config.ts
file.
DEEPGRAM_SECRET_KEY
, SUPABASE_PROJECT_URL
and SUPABASE_SERVICE_ROLE_KEY
as environment variables in your Trigger.dev project. This can be done in the ‘Environment Variables’ page in your project dashboard.
prod
secret key from the API keys page.
TRIGGER_SECRET_KEY
with the pasted value of your Trigger.dev prod
secret key.
video-processing-handler
. This function will be triggered by the Database Webhook.
trigger
folder use Node, so they must stay in there or they will not run,
especially if you are using a different runtime like Deno. Also do not add “npm:
” to imports
inside your task files, for the same reason.prod
secret key to, and once complete you should see your new Edge Function deployment in your Supabase Edge Functions dashboard.
There will be a link to the dashboard in your terminal output.
anon
public
API key from the table .
edge-function-hook
.
Select the new table you have created:
public
video_transcriptions
.
Choose the insert
event.
POST
and select the Edge Function you have created: video-processing-handler
.
Under ‘HTTP Headers’, add a new header with the key Authorization
and the value Bearer <your-api-key>
(replace <your-api-key>
with the anon
public
API key you copied earlier).
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.
To do this, go back to your Supabase project dashboard, click on ‘Table Editor’ in the left-hand menu, click on the video_transcriptions
table , and then click ‘Insert’, ‘Insert Row’ .
video_url
, with a public video url. .
You can use the following public video URL for testing: https://content.trigger.dev/Supabase%20Edge%20Functions%20Quickstart.mp4
.
videoProcessAndUpdate
task which has been triggered when you added a new row with the video url to your video_transcriptions
table.
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.