Sanitize email body of received emails

We have the need to remove a custom message (injected by our firewall) from all the emails received from our customers.

Right now the only way we have are exploiting the extension point:

Work-Channel-Triage-Email.MapEmailToEmailTriageExtn

and we had to change the Email Service > Request > Message data > Handle HTML Content from “As HTML attachment” to “Inline - Prefer HTML”, which is now giving us a some troubles, because some of the emails are NOT correctly detected as HTML!

Is there another extension point that we can keep the old configuration “As HTML attachment” and change the email body?

With this setting we have noticed that if we replace the text in the previous extension point, then the body is sourced from the attachment, instead of the one in the property.

@AleMax225 :warning: This is a GenAI-powered tool. All generated answers require validation against the provided references.

After researching alternative extension points for your specific situation, I have several approaches that might help solve your issue while allowing you to keep the “As HTML attachment” configuration.

Alternative Extension Points

The Work-Channel-Triage-Email.ProcessEmailInformation extension point could be a viable alternative to the MapEmailToEmailTriageExtn you’re currently using. This data transform is executed after the initial extraction of email content but before the email is fully triaged and routed, making it suitable for sanitizing operations.

The key difference is in its timing in the processing flow:

  • It’s called earlier in the processing sequence
  • It’s specifically designed for mapping extracted information for further case processing
  • You could implement sanitization logic within this data transform to filter out the firewall-injected message

Handling HTML Attachments

When using the “As HTML attachment” setting, the email HTML content is stored as an attachment. While there isn’t a documented extension point specifically for modifying HTML attachments after creation, you do have options:

  1. Custom Activity Approach: You could create a custom activity that:
    • Executes after the HTML attachment is created
    • Retrieves the attachment content
    • Removes the firewall message
    • Updates the attachment with the sanitized content
    • This activity can be called from the flow that processes the email
  2. Case Attachment Extension Points: Pega provides extension points for customizing how attachments are processed when added to a case. You might be able to leverage these to intercept and modify the HTML attachment during case creation.

The “Property vs. Attachment” Challenge

I noted your observation about how “the body is sourced from the attachment, instead of the one in the property” when using “As HTML attachment.” This is expected behavior since this setting is designed to store the HTML in an attachment rather than directly in a property.

To address this specific challenge, you might consider:

  1. First processing the attachment to remove the firewall message
  2. Then copying the sanitized content to the appropriate property if needed for display or further processing

Next Steps

I would recommend trying the Work-Channel-Triage-Email.ProcessEmailInformation extension point first, as it might allow you to intercept and sanitize the email content before it becomes an attachment. If that doesn’t solve the issue, the custom activity approach targeting the HTML attachment directly would be my next suggestion.

@MarijeSchillern the Work-Channel-Triage-Email.ProcessEmailInformation extension point does not exists

@AleMax225 apologies for that. My answer came from a GenAI source, and it had incorrectly included documentation from a the Smart Investigate Agentic Automation '24.2 product

Extension points

I want to note that while there is documentation on the email processing flow and HTML handling options, I did not find explicit documentation for the MapEmailToEmailTriageExtn extension point specifically.

If you need to read around the subject, below some documentation:

Extension Points for Email Processing

  • Email triage process - Information about the overall email triage flow and processing
  • Extension points - Contains information about the S.I. product ProcessEmailInformation extension point and its purpose in mapping information extracted from inbound emails

HTML Attachment vs. Inline HTML Handling

Community Discussions and Support Articles

@AleMax225 At the end we have solved the problem by exploiting the customizable data flow pyInteractionDF of our email channel by following this documentation: Interaction API components