We’ve been spinning up a Node.js consumer to handle the v2.analytics.conversation.aggregate event stream. The goal is to feed real-time queue stats into our custom agent desktop widget. The webhook hits our endpoint fine, 200 OKs all around. But the JSON structure inside the payload is giving me a headache when trying to extract the wait-time-avg metric for a specific queue.
Here’s the relevant chunk of the payload we’re seeing:
{
"event": {
"id": "evt_12345",
"type": "v2.analytics.conversation.aggregate",
"body": {
"queueId": "987654321",
"metrics": {
"waiting": 5,
"answered": 120,
"abandoned": 3
}
}
}
}
I’m using Express to parse the body. When I try to access req.body.event.body.metrics.waiting, I get undefined. I’ve logged the entire req.body object and it looks correct. I even tried JSON.parse(JSON.stringify(req.body)) just in case it was some weird proxy issue, but no luck.
The weird part is that req.body.event.type resolves correctly. It’s just the nested body object inside the event that seems inaccessible or malformed. I’m suspecting the platform might be sending the inner payload as a stringified JSON string rather than a parsed object, which would explain why direct dot notation fails.
Has anyone else hit this wall? Should I be manually parsing the inner body string if that’s the case? Or is there a specific SDK helper for unwrapping these analytics aggregates? I’ve checked the API docs for the analytics endpoints, but they don’t mention webhook payload serialization quirks.
Tried:
- Logging
typeof req.body.event.body - Using optional chaining
req.body?.event?.body?.metrics - Checking for
application/jsoncontent-type headers
Nothing works. The inner object is just ghosting me.