Node 18 Lambda failing to parse Genesys Cloud webhook events. The body field arrives as a string, but JSON.parse throws a SyntaxError on the second event in a batch. First event parses fine. Looks like the payload structure might be different than the docs suggest for batched events. Here’s the handler and the error.
export const handler = async (event: APIGatewayProxyEvent) => {
try {
const body = JSON.parse(event.body);
console.log(body);
} catch (e) {
console.error(e);
}
};
SyntaxError: Unexpected token o in JSON at position 1