Skip to content

Email conversion/formatting in HubSpot

When to use this guide: Use this guide when configuring or validating CRM integration behavior.

This article explains how OutboundSync processes and formats email replies before syncing them into HubSpot. The goal of our approach is to maximize data retention and reliability, even if that sometimes comes at the expense of perfect readability.

When syncing email data into HubSpot, OutboundSync intentionally errs on the side of preserving as much original data as possible.

As a guiding principle:

The problem is the myriad of characters that can create issues, break the API call, and result in data loss. We have erred on the side of getting the data into HubSpot.

Because of this, our formatting and cleanup logic is conservative. We avoid aggressive sanitization or transformations that could result in truncated payloads, failed API calls, or lost message content.

Source Payload (example shown: Smartlead – EMAIL_REPLY)

Section titled “Source Payload (example shown: Smartlead – EMAIL_REPLY)”

OutboundSync consumes the EMAIL_REPLY event payload from the sequencer. The relevant structure includes both html and text representations of the message:

{ event_type: 'EMAIL_REPLY';
subject: string;
to_name: string;
to_email: string;
from_email: string;
campaign_name: string;
campaign_id: string;
sl_email_lead_id: string;
client_id: string;
message_id: string;
sent_message: {
text: string;
html: string;
message_id: string;
};
reply_message: {
html: string;
text: string;
message_id: string;
};
sequence_number: string;
stats_id: string;
event_timestamp: string;
}
  • OutboundSync formats and syncs the reply_message.html field when creating Email Reply records in HubSpot.
  • This field is regenerated/formatted each time to ensure consistency.
  • We no longer rely on reply_message.text as the primary source of truth.
  • Earlier implementations used this field, but it was found to be unreliable.

Why we stopped using reply_message.text****:

  • In some cases, the payload would be cut off or truncated.
  • This resulted in partial email replies being synced, which is worse than reduced legibility.

To prevent this, we now prefer HTML-based syncing whenever possible.

While reply_message.html is our preferred field, the payload does not always populate it.

  • The EMAIL_REPLY payload includes both html and text fields.

  • In some cases:

  • reply_message.html is empty

  • reply_message.text contains the full message

When this happens:

  • OutboundSync detects the empty html field
  • We fall back to using reply_message.text
  • The text content is used to ensure the reply is still fully captured and synced

This logic ensures we do not drop replies simply because HTML content is missing.

Why Formatting May Look “Messy” in HubSpot

Section titled “Why Formatting May Look “Messy” in HubSpot”

Some email replies in HubSpot may contain:

  • Extra line breaks
  • Inline styles or raw HTML
  • Unescaped or unusual characters

This is expected behavior.

We intentionally avoid aggressive cleanup because:

  • Certain characters can break HubSpot API calls
  • Over-sanitization increases the risk of data loss
  • Retaining the full message is more valuable than perfect presentation
  • OutboundSync prioritizes data completeness and reliability over visual polish
  • reply_message.html is the primary field used for Email Reply formatting
  • reply_message.text is only used as a fallback when HTML is missing
  • Conservative formatting helps prevent truncation, API failures, and lost email content

If you see formatting artifacts in HubSpot, it is usually a sign that OutboundSync successfully preserved the full reply rather than risking partial data.