You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem
Workflow reply steps were not threading correctly:
Gmail: threadId was never passed to the Gmail send API, so replies always created a new thread.
Office365: createReply was called with the RFC internetMessageId instead of the Microsoft Graph message id, causing an immediate 404 on every reply attempt. Additionally, stored Graph ids were mutable and would become invalid once a message moved from Drafts to Sent Items.
Changes
Adds a params.replyTo object ({ emailMessageId, serviceThreadId/serviceMessageId, references }) as the preferred reply target for both providers. Existing flat params (inReplyTo, threadId) remain as fallbacks — no breaking changes.
Gmail: populates In-Reply-To, References, and threadId from replyTo.
Office365: routes createReply to replyTo.serviceMessageId (the Graph id). Adds Prefer: IdType="ImmutableId" to draft creation and reply draft calls so stored ids survive the Drafts → Sent Items move.
Adds options.returnMetadata to both providers: returns { email_message_id, service_message_id, service_thread_id } instead of a plain string, letting the Server store provider ids immediately without waiting for sent webhooks.
Medium Risk
Touches outbound send/reply paths for both providers (thread ids, Graph createReply, and id stability); behavior is backward compatible but errors in reply targeting would affect production email workflows.
Overview
Fixes workflow reply threading for Gmail and Office365 by introducing a preferred params.replyTo object while keeping legacy inReplyTo, references, and threadId as fallbacks.
Gmail now maps replyTo into RFC In-Reply-To / References, passes replyTo.serviceThreadId (or legacy threadId) on send, and supports options.returnMetadata so callers get { email_message_id, service_message_id, service_thread_id } (including partial ids when post-send getMessage fails).
Office365 routes replies through replyTo.serviceMessageId for createReply (instead of treating RFC ids as Graph ids), tightens legacy inReplyTo so it is not used when replyTo is present, sends Prefer: IdType="ImmutableId" on draft create/reply PATCH so stored message ids survive Drafts → Sent Items, and mirrors the same returnMetadata callback shape on send and reply paths.
Reviewed by Cursor Bugbot for commit 905e707. Bugbot is set up for automated code reviews on this repo. Configure here.
RazvanMitrica
changed the title
Fixes email reply threading for Gmail and Office365. #11897 #11898
Fixes email reply threading for Gmail and Office365
May 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Workflow reply steps were not threading correctly:
Gmail: threadId was never passed to the Gmail send API, so replies always created a new thread.
Office365: createReply was called with the RFC internetMessageId instead of the Microsoft Graph message id, causing an immediate 404 on every reply attempt. Additionally, stored Graph ids were mutable and would become invalid once a message moved from Drafts to Sent Items.
Changes
Adds a params.replyTo object ({ emailMessageId, serviceThreadId/serviceMessageId, references }) as the preferred reply target for both providers. Existing flat params (inReplyTo, threadId) remain as fallbacks — no breaking changes.
Gmail: populates In-Reply-To, References, and threadId from replyTo.
Office365: routes createReply to replyTo.serviceMessageId (the Graph id). Adds Prefer: IdType="ImmutableId" to draft creation and reply draft calls so stored ids survive the Drafts → Sent Items move.
Adds options.returnMetadata to both providers: returns { email_message_id, service_message_id, service_thread_id } instead of a plain string, letting the Server store provider ids immediately without waiting for sent webhooks.