Skip to content

Fix: Preserve ContactId and RelatedContactId in GetTranscript items#111

Open
trexnguyen28 wants to merge 1 commit intoamazon-connect:mainfrom
trexnguyen28:fix-preserve-contact-id-in-transcript
Open

Fix: Preserve ContactId and RelatedContactId in GetTranscript items#111
trexnguyen28 wants to merge 1 commit intoamazon-connect:mainfrom
trexnguyen28:fix-preserve-contact-id-in-transcript

Conversation

@trexnguyen28
Copy link
Copy Markdown

Description:

formatAndProcessTranscriptItems() in WebSocketManager.swift reconstructs messageContentDict from AWSConnectParticipantItem objects returned by the GetTranscript API, but omits contactId and relatedContactId — even though both properties are available on AWSConnectParticipantItem (from AWSConnectParticipantModel.h).

Real-time WebSocket messages retain ContactId in their JSON envelope and it flows through serializedContent to consumers. However, transcript items loaded via GetTranscript lose these fields during reconstruction, making it impossible for downstream consumers to identify which contact a historical transcript item belongs to.

This change adds "ContactId": item.contactId ?? "" and "RelatedContactId": item.relatedContactId ?? "" to the messageContentDict, so transcript items are consistent with live WebSocket messages.


Functional backward compatibility:

Does this change introduce backwards incompatible changes? NO

This is an additive-only change — two new keys are added to an existing JSON dictionary. Existing consumers that do not read these keys are unaffected.

Does this change introduce any new dependency? NO


Testing:

Is the code unit tested?

Yes — two new tests in WebSocketManagerTests.swift:

  • testFormatTranscriptItems_preservesContactId — verifies ContactId and RelatedContactId appear in processed transcript items' serializedContent
  • testFormatTranscriptItems_nilContactIdDefaultsToEmpty — verifies nil values default to empty strings (matching the ?? "" convention used by other fields)

Have you tested the changes with a sample UI?

Yes — tested with a custom host app that parses ContactId from serializedContent after GetTranscript. Confirmed transcript items now carry the correct ContactId after app kill and relaunch.

List manual testing steps:

  • Start a chat session and send a few messages
  • Close the application (without ending chat) → reopen the app → Start chat → Retrieve transcript
  • Verify transcript items in serializedContent contain ContactId matching the session's contact ID
  • Verify RelatedContactId is present (empty string if not a persistent chat scenario)
  • Initiating chat and connecting with an agent
  • Retrieving transcript
  • Disconnecting from chat
  • Sending a message to the agent
  • Close the application (Without ending chat) → open app again → Start chat → Should Retrieve transcript from a previous chat session

formatAndProcessTranscriptItems() reconstructs transcript items from AWSConnectParticipantItem but omits contactId and relatedContactId. Real-time WebSocket messages retain these fields in their JSON envelope, but historical items loaded via GetTranscript lose them during  reconstruction. This makes it impossible for consumers to identify which contact a transcript item belongs to after loading history. Add both fields to messageContentDict so they flow through serializedContent consistently with live WebSocket messages.
@trexnguyen28 trexnguyen28 requested a review from a team as a code owner April 8, 2026 05:24
@trexnguyen28 trexnguyen28 requested review from spenlep-amzn and xiajon and removed request for a team April 8, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant