Skip to content

How to use webhooks or similar in Supabase? #259

Answered by kiwicopple
leibole asked this question in Questions
Discussion options

You must be logged in to vote

Hey @leibole, we have actually built this into our Realtime server, but we haven't yet finished the Dynamic Configuration (supabase/realtime#48). We'll do this after we move out of Alpha.

So here is a workaround ( it could use some improvements):

1. Enable the HTTP extension

2. Create a function to send the payload

create or replace function send_to_webhook() returns trigger AS $trigger$
declare
  rec RECORD;
  payload TEXT;
  column_name TEXT;
  column_value TEXT;
  payload_items JSONB;
begin
  -- Set record row depending on operation
  CASE TG_OP
  WHEN 'INSERT', 'UPDATE' THEN
     rec := NEW;
  WHEN 'DELETE' THEN
     rec := OLD;
  ELSE
     RAISE EXCEPTION 'Unknown TG_OP: "%". Should…

Replies: 4 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@drewbietron
Comment options

@gushecht
Comment options

@drewbietron
Comment options

@eamondunne
Comment options

Answer selected by erkeen
Comment options

You must be logged in to vote
1 reply
@drewbietron
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
7 participants