Skip to content

Commit

Permalink
Merge pull request #755 from techmatters/gian_CHI-2963
Browse files Browse the repository at this point in the history
fix: Generalized Search - regression transcripts not being included when indexing contacts [CHI-2963]
  • Loading branch information
GPaoloni authored Oct 8, 2024
2 parents bfe61e4 + 08b87f4 commit 5b95098
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 15 deletions.
23 changes: 13 additions & 10 deletions hrm-domain/lambdas/contact-retrieve-transcript/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { exportTranscript } from './exportTranscript';

import type { SQSBatchResponse, SQSEvent, SQSRecord } from 'aws-lambda';
import type { CompletedContactJobBody } from '@tech-matters/types';
import { ExportTranscriptDocument } from '@tech-matters/hrm-types';

const completedQueueUrl = process.env.completed_sqs_queue_url as string;
const hrmEnv = process.env.NODE_ENV;
Expand Down Expand Up @@ -78,19 +79,21 @@ const processRetrieveTranscriptRecord = async (
serviceSid,
});

const document: ExportTranscriptDocument = {
transcript,
accountSid,
hrmAccountId,
contactId,
taskId,
twilioWorkerId,
serviceSid,
channelSid,
};

await putS3Object({
bucket: docsBucketName,
key: message.filePath,
body: JSON.stringify({
transcript,
accountSid,
hrmAccountId,
contactId,
taskId,
twilioWorkerId,
serviceSid,
channelSid,
}),
body: JSON.stringify(document),
});

const completedJob: CompletedRetrieveContactTranscript = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
type IndexCaseMessage,
} from '@tech-matters/hrm-search-config';
import { assertExhaustive, type HrmAccountId } from '@tech-matters/types';
import { ExportTranscript, isS3StoredTranscript } from '@tech-matters/hrm-types';
import { ExportTranscriptDocument, isS3StoredTranscript } from '@tech-matters/hrm-types';
import type { MessageWithMeta, MessagesByAccountSid } from './messages';

/**
Expand Down Expand Up @@ -68,8 +68,10 @@ const contactIndexingInputData = async (
const { bucket, key } = location || {};
if (bucket && key) {
const transcriptString = await getS3Object({ bucket, key });
const parsedTranscript: ExportTranscript = JSON.parse(transcriptString);
transcript = parsedTranscript.messages.map(({ body }) => body).join('\n');
const parsedTranscript: ExportTranscriptDocument = JSON.parse(transcriptString);
transcript = parsedTranscript.transcript.messages
.map(({ body }) => body)
.join('\n');
}
}
} catch (err) {
Expand Down
15 changes: 13 additions & 2 deletions hrm-domain/packages/hrm-types/ConversationMedia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* along with this program. If not, see https://www.gnu.org/licenses/.
*/

import { HrmAccountId } from '@tech-matters/types';
import { AccountSID, HrmAccountId } from '@tech-matters/types';

type ConversationMediaCommons = {
id: number;
Expand Down Expand Up @@ -107,9 +107,20 @@ export type ExportTranscriptMessage = {
};

export type ExportTranscript = {
accountSid: HrmAccountId;
accountSid: string;
serviceSid: string;
channelSid: string;
messages: ExportTranscriptMessage[];
participants: ExportTranscripParticipants;
};

export type ExportTranscriptDocument = {
accountSid: AccountSID;
hrmAccountId: HrmAccountId;
contactId: number;
taskId: string;
twilioWorkerId: string;
serviceSid: string;
channelSid: string;
transcript: ExportTranscript;
};

0 comments on commit 5b95098

Please sign in to comment.