Setting up a consumer for the v2.analytics.conversation.aggregate webhook. The goal is to extract specific metric values like talk and hold durations for downstream processing.
The payload structure is deeply nested and inconsistent depending on the channel type. Voice calls have metrics directly under the interaction object, but chat or email might bury them further down or structure the array differently.
Here’s a snippet of the JSON I’m seeing for a voice interaction:
{
"interaction": {
"id": "abc-123",
"metrics": {
"talk": { "value": 120.5 },
"hold": { "value": 0 }
}
}
}
My current Python parser crashes when it hits a chat interaction because the metrics key is missing or empty at that level. I’ve tried using a simple dot-notation path resolver, but it fails when the structure shifts.
Is there a standard way to normalize these payloads before parsing? Or should I be checking the channel property first and branching logic based on that? Looking for a solid way to handle the varying depth without writing a massive if/else tree for every channel type.