Node.js Lambda parsing Genesys Cloud routing queue event payload

Hitting a wall with the webhook handler. The Lambda receives the event but the payload structure looks different than the docs suggest. Trying to extract the queue ID and call count.

exports.handler = async (event) => {
 const body = JSON.parse(event.body);
 console.log(body);
 // body is undefined here
 return { statusCode: 200, body: 'OK' };
};

The console log shows the raw event object has the data in event.body but it’s a string. Parsing it fails with SyntaxError: Unexpected token u in JSON at position 0. The token is valid. Just need to know where the actual JSON is hiding in the event object for the .queue event type.

Node wraps the POST body in event.body as a string, not an object. Parse it first.

const payload = JSON.parse(event.body);
const queueId = payload.data.queueId;