postfix - Processing email with my own script

we have a trouble ticket system that reads an IMAP folder and either creates or updates tickets when new email arrives. The problem is that the ticket is updated with the *complete* content of the email. This means if the email was a reply to a reply to reply, the same text would appear in the ticket multiple times.

What I would like to do is parse the email and cut off all of the replies. I can figure out a script to do the actually processing of the email file. What I am having trouble with is how to get postfix to send the email to my script, then send it back into postfix to be delivered and obviously keeping it from being parsed again.

I looked through the postfix doc and the FILTER_README file, and it seem that the content_filter is what I am looking for. What I am missing is the mechanism whereby postfix does not send the message back into the filter.