Overview
Grouple uses 14 database triggers to automate critical business logic β ensuring emails are sent, currencies are synced, timestamps are recorded, and settlements are created automatically without manual API calls.Triggers by Table
enquiries Table
| Trigger | Event | Timing | Action |
|---|---|---|---|
tr_sync_enquiry_currency | INSERT | BEFORE | Calls sync_enquiry_currency() β sets currency_code from the cityβs default currency |
on_enquiry_created_broadcast | INSERT | AFTER | Calls broadcast_enquiry_to_venues() β matches and creates venue_leads for relevant venues |
send_enquiry_notification | INSERT | AFTER | Calls send-lead-email Edge Function via HTTP β sends lead notification emails to matched venues |
venue_leads Table
| Trigger | Event | Timing | Action |
|---|---|---|---|
before_insert_venue_leads_set_rfq_number | INSERT | BEFORE | Calls set_merchant_rfq_number() β assigns a sequential RFQ number per merchant |
send_email_on_new_lead | INSERT | AFTER | Calls grouple_notifications.trigger_lead_email() β additional lead email notification |
trg_set_venue_lead_timestamps | UPDATE | BEFORE | Calls fn_set_venue_lead_timestamps() β records accepted_at, declined_at, closed_won_at, closed_lost_at based on status change |
trg_record_response_time | UPDATE | AFTER | Calls fn_record_response_time() β logs response time to lead_response_times when merchant first responds |
proposals Table
| Trigger | Event | Timing | Action |
|---|---|---|---|
trigger_sync_settlement | UPDATE | AFTER | Calls sync_confirmed_proposal_to_settlements() β creates/updates commission_settlements when proposal is confirmed |
proposal-updated-email | UPDATE | AFTER | Calls send-proposal-email Edge Function via HTTP β emails customer when proposal is updated/sent |
proposal-confirmation-email | UPDATE | AFTER | Calls reservation-confirmation-emails Edge Function via HTTP β sends confirmation to both parties when proposal is confirmed |
customers Table
| Trigger | Event | Timing | Action |
|---|---|---|---|
on_customer_created_link_enquiries | INSERT | AFTER | Calls link_customer_to_enquiries() β links pre-existing enquiries (submitted before signup) to the new customer record |
merchants Table
| Trigger | Event | Timing | Action |
|---|---|---|---|
trigger_sync_venue_currency | UPDATE | AFTER | Calls sync_venue_currency_from_merchant() β syncs currency_code to all venues when merchant updates their currency |
venues Table
| Trigger | Event | Timing | Action |
|---|---|---|---|
tr_check_venue_limit | INSERT | BEFORE | Calls check_venue_limit() β prevents venue creation if merchant has reached their planβs max_venues limit |
venue_knowledge Table
| Trigger | Event | Timing | Action |
|---|---|---|---|
tr_check_menu_pdf_limit | INSERT | BEFORE | Calls check_menu_pdf_limit() β prevents PDF upload if merchant has reached their planβs max_menu_pdfs limit |