fix: add replyTo and X-Formsg-Submission-ID headers to MRF outcome emails#9570
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates multi-respondent form (MRF) outcome emails (workflow completion + approval/rejection) to include the same integration-critical headers as storage-mode admin emails, by wiring through Reply-To and X-Formsg-Submission-ID.
Changes:
- Added an MRF utility to extract all email-field answers from a
FieldResponsesV3map for use as aReply-Tovalue. - Updated MRF outcome email send paths to pass
replyToandsubmissionIdinto the mail template sender, enablingReply-ToandX-Formsg-Submission-IDheaders. - Normalised
formIdpassed into these MRF outcome mail calls to a string.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apps/backend/src/app/services/mail/mail.service.ts | Extends MRF outcome email methods to accept/forward replyTo and submissionId into the templated mail sender (enabling Reply-To + X-Formsg-Submission-ID). |
| apps/backend/src/app/modules/submission/multirespondent-submission/multirespondent-submission.utils.ts | Adds extractEmailAnswersFromResponses to collect email answers from MRF response maps. |
| apps/backend/src/app/modules/submission/multirespondent-submission/multirespondent-submission.service.ts | Passes extracted email answers as replyTo and wires submissionId into MRF outcome email sends. |
Comment on lines
+112
to
+116
| export const extractEmailAnswersFromResponses = ( | ||
| responses: FieldResponsesV3, | ||
| ): string[] => { | ||
| if (!responses) return [] | ||
| return Object.values(responses) |
Comment on lines
1217
to
+1221
| attachments, | ||
| emailType: EmailType.WorkflowCompletion, | ||
| actionName: 'sendMrfWorkflowCompletionEmail', | ||
| submissionId, | ||
| replyTo, |
Comment on lines
1265
to
+1269
| attachments, | ||
| emailType: EmailType.WorkflowApproval, | ||
| actionName: 'sendMrfApprovalEmail', | ||
| submissionId, | ||
| replyTo, |
eliotlim
approved these changes
Jun 9, 2026
eliotlim
left a comment
Contributor
There was a problem hiding this comment.
thanks for fixing this, @scottheng96!
- tested on stg-alt, no issues -- even if a subsequent step clears the email field used for Reply-To
- we should follow up with the formId / submissionId for other email types too in a separate PR.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
MRF workflow completion and approval emails were missing two email headers that storage mode admin emails include:
Reply-To— without this, Zendesk automation cannot automatically assign the respondent's email as the ticket requester, requiring manual triage.X-Formsg-Submission-ID— without this, email-based integrations (e.g. Zendesk, filtering rules) cannot correlate incoming emails back to a specific FormSG submission.Solution
Added a
extractEmailAnswersFromResponsesutility tomultirespondent-submission.utils.tsthat collects all email field answers from aFieldResponsesV3response map (mirroringextractEmailAnswersused for storage mode). This is then joined and passed asreplyToto bothsendMrfWorkflowCompletionEmailandsendMrfApprovalEmail.Both mail service functions now also accept and forward a
submissionIdparameter, which#sendEmailWithTemplateuses to conditionally set theX-Formsg-Submission-IDheader (the conditional was already in place — it just wasn't being passed).Breaking Changes
Tests
TC1: Workflow completion email includes correct headers
Reply-Toheader is present and contains all email field answers from all steps, comma-separatedX-Formsg-Submission-IDheader is present and matches the submission IDTC2: No email fields — headers degrade gracefully
Reply-Toheader (no empty header)X-Formsg-Submission-IDheader is still present