hello, i planning to create Ai that classify if the email receive is a new endorsement of case or an existing file,
but i don’t want my ai to read the whole email thread, and i also don’t want to instruct my ai to read only 5 emails on the thread.
do you guys have any idea, how to cut an email thread to 5 email exchanges only before it even reaches my ai.
hope you guys understand my query and be able to help.
thank you so much.
before sending the email to your AI, just split the thread into individual messages using common reply separators like From or on wrote then keep only the latest 5.
that way your AI never even sees the full thread. If you are using Gmail or Outlook aPIs, you can directly fetch the last few messages from the conversation instead of parsing raw text
Just develop a RPA workflow or API Workflow with JavaScript function to take top five conversations and then pass that conversations as a string to Agent Input argument.
As this step of taking top 5 conversation is a rule based, you should be using RPA workflow or API workflow.
If you are talking about IXP (communications mining), all conversation emails will be part of your platform and get ingested as soon as they are received. So when you have a new conversation on top, only the latest email will be ingested, and consumption will be considered based on the email Internet message ID.
If you are referring to the external AI system, you might not be able to get the first five conversations directly.
Email threads usually contain separators like:
From:
On <date> wrote:
-----Original Message-----
So, you can use the split method on emailBody=mailMessage.Body and take the first five parts:
parts = System.Text.RegularExpressions.Regex.Split(
emailBody,
"(?=From:|On\s.+wrote:|-----Original Message-----)"
)
latestFive = parts.Take(5).ToArray
You can use a Regex split to look for common markers like From or On wrote and then just keep the first 5 elements of that list This way you’re only feeding the top of the conversation into your AI without manually counting messages