Best way to connect Supabase and MailerLite

Hi everyone, I’m trying to figure out the best way to connect Supabase to MailerLite. We have an app_users table where users are created and updated. Right now, we’re using a trigger and webhook that sends data to Zapier, but the trigger fires even when no fields change. I only want it to fire on new inserts or when actual data changes, not every update event. What’s the best way to wire Supabase and MailerLite together for this use case? Should I be using Edge Functions, a direct HTTP request, or something else entirely?
3 Replies
chamath
chamath6d ago
Hey, I see, this seems to be a case of noisy triggers. Can we first try tightening some validation on the function called by the trigger? Example code snippet: BEGIN -- Only fire on INSERT or when something actually changes IF (TG_OP = 'INSERT') OR (OLD.* IS DISTINCT FROM NEW.*) THEN -- your custom Zapier triggering logic END IF; RETURN NEW; END; So this way, The trigger won’t fire on redundant updates (setting the same value). It still fires for true data changes and new inserts. Let me know if this makes sense. And give it a try and let me know if you need any help integrating something like this into your existing setup. Happy to jump on a small call with you!
Ankur
Ankur6d ago
@typeunknown you don't need really need zapier to send the email. You can create one edge function that call the mailer lite rest api to send the email . trigger that edge function using db triggers + pg_net extension. Make sure your trigger setup for only insert (not for other case like update/delete)
typeunknown
typeunknownOP5d ago
Hi, we're not triggering an email we're adding a user to a mailing list and updating fields when they're updated in supabase.

Did you find this page helpful?