Duplicate tickets when second department is CCd

Duplicate tickets when second department is CCd

Hello,

We have two departments with their own email addresses. However customers often CC the other address, which is effectively creating a new ticket in the other department:

1. If a new email - will create one new ticket in each department

2. If a reply - will create a new ticket in the wrong department, while also adding the response to the existing ticket

Is there a way to prevent this, or eventually write an automation to detect and delete a new duplicate ticket?

Any help would be welcome.