Webhooks & Realtime

SendHub.ai provides real-time data through Supabase Realtime โ€” subscribe to database changes and react instantly.

Subscribe to Events

// All new messages in a workspace
const channel = sendhub
  .channel('my-inbox')
  .on('postgres_changes', {
    event: 'INSERT',
    schema: 'public',
    table: 'messages',
    filter: `business_id=eq.${workspaceId}`,
  }, (payload) => {
    const msg = payload.new
    console.log(`${msg.direction}: ${msg.content}`)
  })
  .subscribe()

// Clean up
sendhub.removeChannel(channel)

Available Events

TableEventUse case
messagesINSERTNew message received or sent
messagesUPDATEDelivery status changed (sent โ†’ delivered โ†’ read)
conversationsINSERTNew conversation started
conversationsUPDATEStatus or assignment changed
contactsINSERTNew contact created
contactsUPDATEContact details or tags changed

Filtering

Scope subscriptions with the filter parameter:

// Only inbound messages
filter: 'direction=eq.inbound'

// Specific conversation
filter: `conversation_id=eq.${convoId}`

// Specific workspace
filter: `business_id=eq.${workspaceId}`

WhatsApp Status Webhooks

For Business API channels, WhatsApp delivery status updates (sent, delivered, read) are received via webhook and automatically update delivery_status on messages. No configuration needed.