> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trymondo.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Functions

> Supabase Functions for Gumloop integration using Edge Functions

\##Explanation:
Trigger and Function: The SQL code creates a trigger that calls the notify\_generate\_pdf\_change function whenever the generate\_pdf column is updated. If the new value is true, it sends a notification on the generate\_pdf\_channel with the proposal ID.

Edge Function: The edge function listens for notifications on the generate\_pdf\_channel. When it receives a notification, it logs the proposal ID and can send data to Gumloop (you'll need to implement the actual integration logic).

\[[https://pkjljvknmdozvzwnwprq.supabase.co/functions/v1/watch-generate-pdf](https://pkjljvknmdozvzwnwprq.supabase.co/functions/v1/watch-generate-pdf)]

supabase functions download watch-generate-pdf

***

```Supabase Edge Function for generate_pdf boolean theme={null}
import "jsr:@supabase/functions-js/edge-runtime.d.ts";
import { createClient } from "jsr:@supabase/supabase-js@2";

const supabaseUrl = Deno.env.get('SUPABASE_URL')!;
const supabaseAnonKey = Deno.env.get('SUPABASE_ANON_KEY')!;
const supabaseClient = createClient(supabaseUrl, supabaseAnonKey);

const listenForGeneratePdfChanges = async () => {
  const { data, error } = await supabaseClient
    .from('generate_pdf_channel')
    .on('INSERT', payload => {
      const proposalId = payload.new.id;
      // Send data to Gumloop here
      console.log(`Gumloop flow triggered for proposal ID: ${proposalId}`);
      // Implement your Gumloop integration logic here
    })
    .subscribe();

  if (error) {
    console.error('Error subscribing to changes:', error);
  }
};

Deno.serve(async (req: Request) => {
  await listenForGeneratePdfChanges();
  return new Response('Listening for changes on generate_pdf...', {
    headers: { 'Content-Type': 'text/plain' },
  });
});
```
