Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.grouple.pro/llms.txt

Use this file to discover all available pages before exploring further.

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

TriggerEventTimingAction
tr_sync_enquiry_currencyINSERTBEFORECalls sync_enquiry_currency() β€” sets currency_code from the city’s default currency
on_enquiry_created_broadcastINSERTAFTERCalls broadcast_enquiry_to_venues() β€” matches and creates venue_leads for relevant venues
send_enquiry_notificationINSERTAFTERCalls send-lead-email Edge Function via HTTP β€” sends lead notification emails to matched venues

venue_leads Table

TriggerEventTimingAction
before_insert_venue_leads_set_rfq_numberINSERTBEFORECalls set_merchant_rfq_number() β€” assigns a sequential RFQ number per merchant
send_email_on_new_leadINSERTAFTERCalls grouple_notifications.trigger_lead_email() β€” additional lead email notification
trg_set_venue_lead_timestampsUPDATEBEFORECalls fn_set_venue_lead_timestamps() β€” records accepted_at, declined_at, closed_won_at, closed_lost_at based on status change
trg_record_response_timeUPDATEAFTERCalls fn_record_response_time() β€” logs response time to lead_response_times when merchant first responds

proposals Table

TriggerEventTimingAction
trigger_sync_settlementUPDATEAFTERCalls sync_confirmed_proposal_to_settlements() β€” creates/updates commission_settlements when proposal is confirmed
proposal-updated-emailUPDATEAFTERCalls send-proposal-email Edge Function via HTTP β€” emails customer when proposal is updated/sent
proposal-confirmation-emailUPDATEAFTERCalls reservation-confirmation-emails Edge Function via HTTP β€” sends confirmation to both parties when proposal is confirmed

customers Table

TriggerEventTimingAction
on_customer_created_link_enquiriesINSERTAFTERCalls link_customer_to_enquiries() β€” links pre-existing enquiries (submitted before signup) to the new customer record

merchants Table

TriggerEventTimingAction
trigger_sync_venue_currencyUPDATEAFTERCalls sync_venue_currency_from_merchant() β€” syncs currency_code to all venues when merchant updates their currency

venues Table

TriggerEventTimingAction
tr_check_venue_limitINSERTBEFORECalls check_venue_limit() β€” prevents venue creation if merchant has reached their plan’s max_venues limit

venue_knowledge Table

TriggerEventTimingAction
tr_check_menu_pdf_limitINSERTBEFORECalls check_menu_pdf_limit() β€” prevents PDF upload if merchant has reached their plan’s max_menu_pdfs limit

Key Trigger Flows

New Enquiry β†’ Leads Created β†’ Emails Sent

Customer submits enquiry
        ↓
BEFORE INSERT: tr_sync_enquiry_currency β†’ sets currency from city
        ↓
AFTER INSERT: on_enquiry_created_broadcast β†’ fn_match_venues_for_enquiry()
  Creates venue_leads records for matched venues
        ↓
AFTER INSERT on venue_leads: before_insert_venue_leads_set_rfq_number
  Sets merchant_rfq_number
        ↓
AFTER INSERT on venue_leads: send_email_on_new_lead
  Sends lead email to merchant
        ↓
AFTER INSERT on enquiries: send_enquiry_notification
  Also calls send-lead-email Edge Function (belt-and-suspenders)

Proposal Confirmed β†’ Settlement Created β†’ Emails Sent

Customer confirms proposal β†’ proposal.status = "confirmed"
        ↓
AFTER UPDATE: trigger_sync_settlement
  Creates commission_settlements record with applied_commission_rate
        ↓
AFTER UPDATE: proposal-confirmation-email
  Calls reservation-confirmation-emails Edge Function
  Sends confirmation to customer + merchant