EventBridge duplicate events for same interactionId in Studio webhook

How do you handle duplicate EventBridge records when the source is a webhook? We’ve set up a flow to push data to a custom endpoint via the Webhook action. That endpoint then forwards to AWS EventBridge. The logic seems sound, but we’re seeing double entries in our consumer queue for single events.

Here is the basic flow:

  1. Webhook action sends POST to our internal API.
  2. Internal API puts record onto EventBridge.
  3. SQS consumer processes the record.

The problem is step 3. We get two messages with the same interactionId within milliseconds. The JSON payload looks identical except for the timestamp generated by EventBridge.

{
 "source": "genesys.cloud",
 "detail-type": "Conversation.Answered",
 "detail": {
 "interactionId": "x-00000000-0000-0000-0000-000000000000",
 "timestamp": "2023-10-27T14:00:00Z"
 }
}

I’ve checked the flow. The webhook action is only triggered once per conversation state change. There are no loops. The internal API logs show only one incoming request from Genesys. So the duplication is happening between our API and EventBridge, or perhaps EventBridge is retrying a successful put?

I tried adding a deduplication key in the SQS consumer using the interactionId. But since the events arrive almost simultaneously, both messages get processed before the first one commits to our database. We end up with race conditions.

Has anyone solved this? Should we be using a unique event ID from Genesys instead of interactionId? Or is there a setting in the Webhook action to prevent retries? The docs mention idempotency but don’t give code examples for EventBridge. We’re using Python with boto3 to put the records. The put_events call returns success for both. It feels like a race condition in our producer code.