# Just the reply, not the thread under it

Every email that reaches AI Inbx is cut into what the sender wrote, what they quoted and their signature. stripped\_text is the part that is new, answers typed inside the quote included.

[Get started](/signup)
[Documentation](https://docs.aiinbx.com/guides/receiving#what-was-written)

Example: Priya replies from Outlook to a support email asking three questions. Outlook quotes the whole message under a From/Sent/To/Subject header block with no > markers, and she types her three answers (Edge; only ranges over 90 days; about 40,000 rows) under the questions inside the quote. segments cuts the reply into written, signature and quoted runs in order: her opening, her signature, the header block and Sam's message, and her three answers between his questions. stripped\_text is her opening and the three answers, each under the question it answers, with the quote and her already-seen signature removed.

Outlook

## Outlook marks nothing. Her answers still come through.

Outlook quotes under a header block with no > on any line, so answers typed inside look like quote. When the message she answers is on the thread, they still come back in stripped\_text as hers, each under the line it answers.

[Outlook](https://docs.aiinbx.com/guides/receiving#what-was-written)

Signatures

## A signature once, not on every reply

The first time a sender signs on a thread, the signature stays in stripped\_text: it is where their name, role and number are. Once a mail of theirs that this one answers carries it, it is dropped.

[Signatures](https://docs.aiinbx.com/guides/receiving#what-was-written)

Forwards

## A forward keeps what it forwards

A forward, or a reply to mail sent before the inbox was connected, brings a quote the thread has never seen. That quote is the content, so stripped\_text keeps it and segments still marks it as quoted.

[Forwards](/features/mailboxes)

Clients

## The quote starts differently in every client

Attribution lines in English, German, French, Spanish, Italian, Dutch, Portuguese and more, wrapped or not. Outlook’s header block, forward separators, and the quote markup of Gmail, Outlook, Apple Mail, Yahoo and Thunderbird.

[Clients](https://docs.aiinbx.com/guides/receiving#what-was-written)

Compared

## How replies usually get stripped

Most parsers guess where the quote begins. That works for the reply typed above the quote, which is most of them. It breaks on the reply people send to a list of questions.

| Approach | What it reads | Where it stops |
| --- | --- | --- |
| A regex | The text part, down to the first “On … wrote:” or “>”. | Everything under that line goes, answers included. Every client and language needs a pattern of its own. |
| email\_reply\_parser | GitHub’s Ruby plain-text parser and its Python, Node, Go and PHP ports: quote markers, “On … wrote:” (English only in the original), signature lines. | Priya’s Outlook reply comes back as her opening and signature, the three answers gone. Answers between “>” lines survive without their questions. |
| talon | Mailgun’s Python library: plain text or HTML for quotes, and rules or a trained classifier for signatures. | The same Outlook reply loses the same three answers. A reply answered between “>” lines comes back whole, quote and all. |
| Postmark StrippedTextReply | The plain-text part of replies that carry In-Reply-To or References. | Documented as English only, and not filled from an HTML-only reply. |
| Mailgun stripped-text | The text part with quoted parts and the signature block removed, with stripped-html and stripped-signature beside it. | The fields are left out of the payload when the parse fails. |
| AI Inbx | The whole reply, text or HTML, from any client and in most languages. | With nothing it answers on the thread — a forward, a reply to mail from before the inbox was connected — it keeps the quote rather than guess. It reads mail that reaches AI Inbx, not a body you post to it. |

Set up

## Three fields on every email

Step 1, email.received: the reply, as a comment on the ticket.

```
if (event.type === "email.received" && event.data.category === "human") {
  const email =
    event.data.email ?? (await aiinbx.emails.retrieve(event.data.email_id))
  await tickets.comment(event.data.thread_id, email.stripped_text)
}
```

Step 2, segments: the whole message, quote folded.

```
for (const segment of email.segments) {
  if (segment.kind === "quoted") view.fold(segment.text)
  else view.show(segment.text)
}
```

Step 3, stripped\_html: the same cut, with its formatting.

```
// null when there is no HTML part, or its markup could not be cut
render(email.stripped_html ?? email.html)
```

## Questions

### How do I extract only the latest reply from an email thread?

Read stripped\_text on the email. It is the part the sender wrote in this message: the conversation their client quoted underneath is removed, and so is a signature the thread already has. If you want the quote too, segments returns the whole body cut into written, quoted and signature parts, in order.

### Why does my regex miss replies from Outlook?

Outlook puts no > in front of quoted lines. It writes a From, Sent, To and Subject block and pastes the earlier message under it, so a parser cutting at that block also cuts any answer typed below it. When the message being answered is on the thread, AI Inbx keeps those answers, each under the line it answers, and drops the rest of the quote.

### What happens to answers typed between the quoted lines?

They stay in stripped\_text, in the order they were typed, each introduced by the quoted question or sentence above it, so it still reads as an answer. The rest of the quote is removed. In segments they are written parts sitting between quoted ones.

### How do I remove the signature from an email?

stripped\_text leaves it out once the thread already has it from that sender. The first signature a sender uses on a thread is kept, because that is where their name, role and phone number are; segments marks it as signature either way.

### Does it work for replies written in other languages?

Yes. Attribution lines such as Am … schrieb, Le … a écrit and El … escribió are recognised along with the English one, and so are translated Outlook headers like Von and Gesendet. Answers typed into an unmarked quote are found too, in most languages.

### Can I post an email body and get the reply back?

No. There is no standalone parse call: the cut is made on mail that reaches AI Inbx, received on your domain or in a connected Gmail or Outlook mailbox, and on mail you send through it. Every email read in full, from GET /emails/{id} or a full webhook payload, then carries text, html, stripped\_text, stripped\_html and segments.

### What if the message being answered was never on file?

Then the quote stays in stripped\_text: in a forward, or a reply to mail sent before the mailbox was connected, the quoted part is the content. segments still marks it as quoted, so you can fold it yourself.

Keep reading

## More on building with email

-   [Inbound email APIReceive email in your app over an API. Point an MX record at AI Inbx or connect Gmail and Outlook, and every message arrives as a signed, parsed JSON webhook.ThreadingAttachmentsMailboxesWildcard domains](/solutions/inbound-email-api)
-   [Auto-reply detectionTell an out-of-office, a ticket acknowledgement or a bounce from a real reply. Every inbound email arrives with a category, even when no header gives it away.MailboxesSuppressions](/solutions/auto-reply-detection)
-   [Send email APISend email from your domain or your users' own Gmail and Outlook with one API call. Opt-outs and pacing are checked first, and replies land on the thread.ThreadingMailboxesPacingSuppressions](/solutions/send-email-api)

-   [ThreadingOne conversation, however it comes back.](/features/threading)
-   [MailboxesGmail and Outlook, same everything.](/features/mailboxes)

[All solutions](/solutions)

## Give your product an inbox. The hard parts are already handled.

[Get started](/signup)
