Trying to wire up a webhook that triggers when a queue metric breaches SLA. The goal is to push a formatted message to a specific Slack channel. I’ve set up the subscription in the portal to listen for v2:queues:metrics:realtime:events. The payload arrives at my endpoint, but filtering for the breach condition in the code is messy. I’m checking if data.value is less than the target in the queue config, but the units don’t always match. Here’s the basic Node.js handler I’m using:
app.post('/webhook', (req, res) => {
const event = req.body;
if (event.type === 'v2:queues:metrics:realtime:events') {
// Logic to check SLA and post to Slack
}
res.sendStatus(200);
});
The issue is determining the exact threshold value from the queue settings within the webhook payload itself. The event data doesn’t seem to include the target SLA percentage, just the current value. I’d have to make a separate API call to /api/v2/queues/{id} to get the config, which feels heavy for every event. Is there a way to include the target in the webhook payload or should I just cache the queue configs locally? Also, the Slack webhook requires a JSON body with text and channel keys. Anyone got a clean example of this flow?