Getting SyntaxError: Unexpected token u in JSON at position 0 when trying to parse the event payload in a Node.js Lambda handler for Genesys Cloud interaction.v2 webhooks. The handler is supposed to extract the interactionId and push it to a SQS queue for downstream processing, but the body comes through as undefined or malformed despite standard AWS SDK v3 setup.
Here’s the minimal reproduction:
import { SQSClient, SendMessageCommand } from "@aws-sdk/client-sqs";
export const handler = async (event) => {
const payload = JSON.parse(event.body);
const interactionId = payload.interactionId;
const client = new SQSClient({ region: process.env.AWS_REGION });
await client.send(new SendMessageCommand({
QueueUrl: process.env.QUEUE_URL,
MessageBody: JSON.stringify({ id: interactionId })
}));
return { statusCode: 200, body: "OK" };
};
The webhook delivery log in Genesys shows a 200 OK, so the platform isn’t retrying. The event.body is definitely there, but JSON.parse chokes. Is the payload structure different for interaction.v2 compared to standard REST payloads? Or is there a specific encoding issue with the webhook event format that requires pre-processing before parsing? Checking CloudWatch logs shows the raw event object has a body field, but it’s not standard JSON string format.