© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
27 replies
gduteaud

Invoking an edge function via Supabase trigger/function

Hi all,

I'm working on implementing a RAG system in Supabase. Here's the desired flow for the part I'm focusing on at the moment:

New row is inserted in "document_chunks" table -> trigger fires to execute function "call_embed_edge_function" -> function runs, sends http post request to invoke "embed" edge function and pass "chunk_id" and "chunk_content" to it -> edge function runs, generates embed and updates row based on "chunk_id"

The issue I'm having now is that, while I've troubleshooted my trigger + function to the point where I don't get Supabase errors on attempting insert into "document_chunks", my edge function is still not getting invoked i.e. both invocations and logs are completely empty in the dashboard.

Here are the function & trigger definitions for reference:

create or replace function public.call_embed_edge_function()
returns trigger
language plpgsql
as $$
begin

perform
  net.http_post(
    url:=supabase_url() || '/functions/v1/embed',
    headers:= jsonb_build_object(
    'Content-Type', 'application/json',
    'Authorization', current_setting('request.headers')::json->>'authorization'
    ),
    body := jsonb_build_object(
      'chunk_id', new.id,
      'chunk_content', new.content
    )
  );

return null;

end;
$$;

CREATE or replace TRIGGER on_chunk_insert
AFTER INSERT ON public.document_chunks
FOR EACH ROW
EXECUTE PROCEDURE public.call_embed_edge_function();
create or replace function public.call_embed_edge_function()
returns trigger
language plpgsql
as $$
begin

perform
  net.http_post(
    url:=supabase_url() || '/functions/v1/embed',
    headers:= jsonb_build_object(
    'Content-Type', 'application/json',
    'Authorization', current_setting('request.headers')::json->>'authorization'
    ),
    body := jsonb_build_object(
      'chunk_id', new.id,
      'chunk_content', new.content
    )
  );

return null;

end;
$$;

CREATE or replace TRIGGER on_chunk_insert
AFTER INSERT ON public.document_chunks
FOR EACH ROW
EXECUTE PROCEDURE public.call_embed_edge_function();


Anyone see what I'm doing wrong?

Thanks,
GD
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Edge function <> Trigger
SupabaseSSupabase / help-and-questions
13mo ago
Webhook not invoking Edge Function
SupabaseSSupabase / help-and-questions
3y ago
Invoking Edge Function from Browser
SupabaseSSupabase / help-and-questions
4y ago
call an edge function via webhook
SupabaseSSupabase / help-and-questions
7mo ago