Issue with Brevo Integration: Duplicate Contact Error for Existing Contacts
-
Dear support team,
I am using the Brevo integration with Contact Form 7 to send emails. However, I have encountered an issue where the following error occurs when a form is submitted with an email address that already exists in Brevo:
HTTP response: 400 Bad Request {"code":"duplicate_parameter","message":"Unable to create contact, email is already associated with another Contact","metadata":{"duplicate_identifiers":["email"]}}
Expected Behavior:
- If a contact with the provided email address already exists in Brevo, I expect the following:
- The contact’s details should remain unchanged.
- The email should still be sent.
Current Situation:
- When the contact already exists, the integration throws an error, and the email is not sent.
- I have tried setting the
updateEnabled
parameter tofalse
using thewpcf7_sendinblue_contact_parameters
filter hook, but this does not resolve the issue. - Setting
updateEnabled
totrue
overwrites existing contact details, which is not the desired behavior.
Attempts Made:
- I have tried several adjustments using the
wpcf7_sendinblue_contact_parameters
filter hook:- Setting
updateEnabled
tofalse
. - Adding a
duplicateParameter
to ignore duplicates. - Setting
emailBlacklisted
tofalse
to ensure emails are sent.
- Setting
- Unfortunately, the error persists.
Question:
- Is there a way to configure Contact Form 7 so that emails are sent without modifying existing contact details in Brevo?
- How can I prevent this error from occurring while maintaining email functionality?
Scenario:
Imagine a customer who has previously placed an order via WooCommerce and is already listed in the Brevo contact database with the correct details (e.g., email, first name, and last name). Later, the same customer submits a Contact Form 7 form using the same email address but with a slightly different or incorrect first or last name (due to a typo or mistake). In this case:
- Brevo tries to create a new contact because the name differs from the existing record.
- Since the email already exists in Brevo, the API rejects the request with a “duplicate_parameter” error.
- As a result, the email associated with the form submission is not sent, and the customer is left without any response.
This behavior is problematic because it prevents successful communication with existing customers, which is critical for customer support and maintaining good relationships. At the same time, updating or overwriting existing contact details in Brevo is not desirable, as it can lead to data inconsistencies.
Relevant Resources:
I greatly appreciate your assistance with this issue and look forward to your suggestions.
my function now:
// *** Brevo & Contact Form 7: Ensure existing contacts are not updated, but emails are still sent ***
// ===========================================================================
// Prevents errors for existing contacts in Brevo by applying the correct API parameters.
add_filter('wpcf7_sendinblue_contact_parameters', 'luizaxl_handling_brevo_contacts');
function luizaxl_handling_brevo_contacts($params) {
// Check if the contact already exists
$params['updateEnabled'] = false; // Prevent updates to existing contacts
// Force email sending, even for existing contacts
$params['emailBlacklisted'] = false; // Ensure emails are always sent
// Ensure no new contacts are created if a duplicate exists
if (isset($params['duplicateParameter'])) {
$params['duplicateParameter'] = 'skip'; // Ignore creation of duplicates
}
return $params;
} - If a contact with the provided email address already exists in Brevo, I expect the following:
- You must be logged in to reply to this topic.