Problem
GC sits at 2025-04.130.0. The analytics.conversations.events webhook hits the Express route with a null botId after NLU handoff. Node 20.11.0 throws a TypeError on validation. JWT checks out.
{ "botId": null }
TypeError: Cannot read properties of null (reading ‘languageCode’)
Payload structure shifted again. Queue’s doing jack all.
Check your webhook subscription filters first. If you’re listening to analytics/conversations/events without a specific filter for botInteractions, the payload structure changes depending on whether the event originates from a human agent or the bot engine. You’re likely hitting a mixed-event batch where the botId is legitimately null for agent-handled segments, causing that TypeError.
You need to guard against null before accessing nested properties. Also, make sure you’re using the webhook:read scope on the token validating the signature, otherwise you might be getting stripped payloads if the integration has limited permissions.
app.post('/webhook', express.json({ verify: (req, res, buf) => { req.rawBody = buf; } }), (req, res) => {
const events = req.body.events || [];
events.forEach(event => {
// Safe navigation for botId
const botInfo = event.botId ? event.bot : null;
const langCode = botInfo?.languageCode || 'unknown';
// Process event
console.log(`Bot Lang: ${langCode}`);
});
res.status(200).send('OK');
});
The queue isn’t broken. Your validation logic is just too rigid for the event schema.