Skip to content

Add an option to only send the last email to the AI #12945

@0-wHiTeHand-0

Description

@0-wHiTeHand-0

Is your feature request related to a problem? Please describe.

Hi team,
It would be great to have an option (like a toggle button or something like that) to only send the last email to the AI for the "Thread summary" feature. The reason is that normally the other emails are already included in the body of the last email, so it's a waste of tokens and time sending/processing the same information a lot of times (once per email in the thread).

Describe the solution you'd like

Add a button in Mail's configuration that enables code like:

Instead of the $messagesBodies in

$messagesBodies = array_map(function ($message) use ($client, $account, $currentUserId) {

Have only the body of the last one:

$lastMessage = $messages[array_key_last($messages)];
$mailbox = $this->mailManager->getMailbox($currentUserId, $lastMessage->getMailboxId());
$imapMessage = $this->mailManager->getImapMessage(
    $client,
    $account,
    $mailbox,
    $lastMessage->getUid(), true
);
$messagesBodies = [$imapMessage->getPlainBody()];

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

No fields configured for Enhancement.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions