How can I filter incoming email to only add the latest comment to an Incident?

ben_kahn
Kilo Expert

Hi,

 

I've noticed that when an Incident is updated via email, the activity feed quickly becomes very clogged and hard to read - when customers reply via email, the comment that is added contains the entire body of the email that they are replying to. This leads to very long comments that contain a lot of duplicated text. Is there an easy way to filter incoming messages so that only the customer's response is added to the Comments section of the Incident? I'm thinking I could use a <HR></HR> tag or something similar and include a "Don't write below this line" message in the outbound notification email, and then filter out everything below that in the inbound mail, but am unsure how to go about setting that up. I think initially our email config was done by the previous administrator with help from our implementation partner so I really don't have much insight as to how that works.

 

Thanks!

1 ACCEPTED SOLUTION

ben_kahn
Kilo Expert

Thanks for the suggestions and help everyone. I ended up using the method outlined here:



http://glassputan.wordpress.com/2012/03/08/managing-email-replies/



It seems to be working great in my DEV instance, will push it live today.


View solution in original post

16 REPLIES 16

Awesome, thanks!


email.body_text.replace(/<div style='display:inline'>Ref:MSG.*/,'')


That's all I would have to put in the Inbound action for it to delete the REF and everything after it?


What would be the code for it to cut everything off after the first <hr/>?


Hi Alan,



Yes, if you replace any reference in the inbound action to email.body_text with the line above containing the regex replace, it should replace the full contents of the email with everything after the first occurrence of the Ref and everything after it.   To replace the hr, you would substitute email.body_text with:



email.body_text.replace(/<hr\/>.*/, '')



Make sure you test these as I have not thoroughly tested the regex's.


I got to thinking and decided that removing everything after a <div> in the email.body_html would work well too if it's an HTML message which most emails seem to be (and I'll make a backup one looking for text if it comes in without html for some reason).


But I can't get the .* or */ to work cause .* gives a syntax error and */ starts commenting out things.


email.body_html.replace('<div>',''); seems to work but of course that doesn't replace everything after the <div> Any ideas?


Hi Alan,



If I understand correctly, the following regex should select everything after the first <div> tag:



/<div>.*/


ben_kahn
Kilo Expert

Thanks for the suggestions and help everyone. I ended up using the method outlined here:



http://glassputan.wordpress.com/2012/03/08/managing-email-replies/



It seems to be working great in my DEV instance, will push it live today.