C# Webhook handler ignoring Cognigy JSON structure for CXone routing

We’ve got a C# Azure Function listening to Genesys Cloud webhooks. The goal is to take the incoming call data, check the intent via NICE Cognigy, and then update the interaction attributes in CXone based on that intent.

The problem is the payload structure. Cognigy sends a JSON object with the intent inside a context array, but my code expects a flat string. When I parse it, the intent variable comes back null, so the routing logic fails silently.

Here is the relevant part of the Cognigy response:

{
 "context": [
 {
 "intent": "billing_issue",
 "confidence": 0.98
 }
 ],
 "text": "I need to pay my bill"
}

And here is how I’m trying to read it in C#:

var cognigyResponse = await client.PostAsync(cognigyUrl, content);
var json = await cognigyResponse.Content.ReadAsStringAsync();
var data = JsonConvert.DeserializeObject<Dictionary<string, object>>(json);

var intent = data["intent"]?.ToString(); // This returns null

The docs for the NICE CXone API say I need to pass the correct interactionId to update attributes, but I can’t even get the intent string out of the JSON first. The data["intent"] key doesn’t exist because it’s nested in the array.

If I try data["context"], it returns a JArray or object, not the string. How do I extract that billing_issue value cleanly without writing a ton of nested null checks? Using .NET 6.