Webhooks Overview
What are webhooks?
Webhooks allow your server to receive real-time notifications whenever something happens in SkyLight Chat — a new contact is created, a message is received, a booking is made, and more.
Instead of polling the API repeatedly, you configure a webhook endpoint (an HTTPS URL on your server), and SkyLight Chat will POST a signed JSON payload to it whenever subscribed events occur.
SkyLight Chat ──── POST ────► https://yourapp.com/webhooks/skylightchat
How it works
Create a webhook
Register your endpoint URL and choose which events to subscribe to — via the dashboard or the REST API.
Receive the event
SkyLight Chat sends a POST request to your URL with a signed JSON payload within seconds of the event occurring.
Verify the signature
Every request includes an X-Skylight-Signature header — an HMAC-SHA256 signature of the payload. Verify it before processing.
Process the event
Parse the event field to determine what happened and update your system accordingly.
Respond with 2xx
Respond with any 2xx status code (e.g., 200 OK) to acknowledge receipt. If you respond with a non-2xx status or don't respond within 30 seconds, the delivery will be retried.
Quick example
Here is a minimal webhook handler in Node.js:
import express from 'express'
import crypto from 'crypto'
const app = express()
app.use(express.json())
app.post('/webhooks/skylightchat', (req, res) => {
const secret = process.env.SKYLIGHTCHAT_WEBHOOK_SECRET
const signature = req.headers['x-skylight-signature']
const expected = 'sha256=' + crypto
.createHmac('sha256', secret)
.update(JSON.stringify(req.body))
.digest('hex')
if (signature !== expected) {
return res.status(401).send('Invalid signature')
}
const { event, data } = req.body
switch (event) {
case 'contact.created':
console.log('New contact:', data.contact.name)
break
case 'message.received':
console.log('New message from:', data.contact.name)
break
case 'booking.created':
console.log('New booking:', data.booking.id)
break
}
res.status(200).send('OK')
})
app.listen(3000)
