Node.js Lambda: Genesys Cloud Webhook Payload Parsing Issue

Trying to parse Genesys Cloud conversation events in a Node.js Lambda. The payload structure seems inconsistent when using EventBridge vs direct webhook.

Here’s the handler:

exports.handler = async (event) => {
 const body = event.body ? JSON.parse(event.body) : event;
 console.log('Received:', JSON.stringify(body));
 
 if (body.eventType === 'conversation:update') {
 // process update
 }
 return { statusCode: 200 };
};

The issue:

  • Direct webhook sends a clean JSON object with eventType at root
  • EventBridge wraps it in detail and detailType
  • event.body is undefined for EventBridge events
  • Parsing fails silently because JSON.parse() isn’t called on the right property

Tried checking event.detail first, but that breaks direct webhooks. Is there a standard way to normalize this in the Lambda?

Also, the conversation:update events seem to fire twice for the same state change. Should I implement deduplication based on id and version?