GetTranscripts

Overview

Step 4 of the pipeline (call path). Fetches the best available transcript for each segment ID produced by GetCallSegments. Only Available transcripts are returned — segments with Pending, Failed, or NotApplicable status are silently excluded.

Enforces a layered permission model:

  • Call access gate — requires any call access permission set (CallCore_TX_HandledCallsAccess or CallCore_TX_ViewAllCalls); throws CallCoreUnauthorizedException if the running user has none.
  • Summarysummary is populated if the user has CallCore_TX_ViewAllCallSummaries, or if the call was handled by the running user and they have CallCore_TX_HandledCallsAccess. Otherwise null.
  • Transcript texttranscriptText is populated if the user has CallCore_TX_ViewAllCallTranscripts, or if the call was handled by the running user and they have CallCore_TX_HandledCallsAccess. Otherwise null.

bypassRunningUserPermissions() skips all three layers — the call access gate is not checked and all fields are returned unredacted. The caller takes explicit responsibility for access control. Source scoping applied at the GetCallSegments step is not affected.

Segment IDs can be narrowed before fetching using excluding() — for example, to skip segments the caller has already loaded transcripts for.

Request

Obtain the Request via GetCallSegments.Response.toGetTranscriptsRequest().

GetTranscripts.IHandler handler = GetTranscripts.construct();
GetTranscripts.Response txResult =
    handler.execute(
        callResult.toGetTranscriptsRequest()
    );
Method Description
excluding(Id segmentId) Removes a single segment ID — its transcript will not be fetched. Fluent.
excluding(Set<Id> segmentIds) Removes multiple segment IDs in one call. Fluent.
bypassRunningUserPermissions() Skips all permission checks and field redaction. All fields are returned unredacted regardless of the running user's permissions. Does not affect source scoping from the GetCallSegments step. Fluent.

No SharingRule is passed to construct() — transcripts are call-domain data and always fetched without sharing.

Response

Member Type Description
transcripts List<PhoneCallTranscript> One entry per segment ID for which an Available transcript was found.
toSegmentIds() Set<Id> The segment IDs for which a transcript was returned. Useful to determine which input segments had no available transcript.

PhoneCallTranscript fields:

Field Type Description
transcriptId Id The transcript record ID.
segmentId Id The call segment record ID this transcript belongs to.
summary String The AI-generated call summary. null if the transcript has no summary, or the running user cannot view it (see permission model in Overview).
transcriptText String The full transcript text. null if not present, or the running user cannot view it (see permission model in Overview).

Testing

MockGetTranscripts is a package-provided test double. Call use() to install it for the current test transaction, then returning() with the transcripts it should return. The mock returns the same list regardless of which segment IDs are in the request.

@isTest
static void myTest() {
    PhoneCallTranscript transcript = new PhoneCallTranscript();
    transcript.transcriptId   = someTranscriptId;   // from test setup
    transcript.segmentId      = someSegmentId;       // from test setup
    transcript.summary        = 'Customer enquired about their policy renewal.';
    transcript.transcriptText = 'Agent: Hello, how can I help?...';

    MockGetTranscripts.use()
        .returning(new List<PhoneCallTranscript>{ transcript });

    MyService.run(someRecordId);
}
Method Description
use() Installs this instance as the handler for the current test transaction. Returns the instance for chaining.
returning(List<PhoneCallTranscript> transcripts) Configures the transcripts returned by execute(). Passing null is equivalent to an empty list.