Skip to content

The open alternative to Salesforce, designed for AI.

Call recorder: resume bot-less recordings when the event payload carries an empty bot id (#26272)

nitin60fe5a720380
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/__tests__/schedule-recall-bot-on-call-recording-update.test.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/__tests__/schedule-recall-bot-on-call-recording-update.test.ts
index e705c3e54c0..bdad0f7790f 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/__tests__/schedule-recall-bot-on-call-recording-update.test.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/__tests__/schedule-recall-bot-on-call-recording-update.test.ts
@@ -58,7 +58,9 @@ const buildUpdateEvent = (overrides: Partial<HandlerEvent> = {}): HandlerEvent =
...overrides,
}) as HandlerEvent;
-const stubPendingCallRecordingQueries = () => {
+const stubPendingCallRecordingQueries = ({
+ externalBotId = null,
+}: { externalBotId?: string | null } = {}) => {
queryMock.mockImplementation(async (query: any) => {
if (query.callRecordings !== undefined) {
return {
@@ -68,7 +70,7 @@ const stubPendingCallRecordingQueries = () => {
status: 'SCHEDULED',
recordingRequestStatus: 'REQUESTED',
calendarEventId: 'calendar-event-1',
- externalBotId: null,
+ externalBotId,
botScheduleAttemptedAt: null,
},
]),
@@ -165,6 +167,61 @@ describe('scheduleRecallBotOnCallRecordingUpdateHandler', () => {
);
});
+ it('schedules a bot when the platform serializes the missing bot id as an empty string', async () => {
+ stubPendingCallRecordingQueries({ externalBotId: '' });
+
+ const result = await scheduleRecallBotOnCallRecordingUpdateHandler(
+ buildUpdateEvent({
+ properties: {
+ updatedFields: ['title', 'status', 'callRecorderFailureReason'],
+ before: {
+ id: 'call-recording-1',
+ status: 'FAILED',
+ recordingRequestStatus: 'REQUESTED',
+ externalBotId: '',
+ },
+ after: {
+ id: 'call-recording-1',
+ status: 'SCHEDULED',
+ recordingRequestStatus: 'REQUESTED',
+ externalBotId: '',
+ },
+ },
+ } as unknown as HandlerEvent),
+ );
+
+ expect(result).toEqual({
+ callRecordingId: 'call-recording-1',
+ result: { status: 'scheduled' },
+ });
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ expect(fetchMock).toHaveBeenCalledWith(
+ RECALL_CREATE_BOT_URL,
+ expect.objectContaining({ method: 'POST' }),
+ );
+ });
+
+ it('schedules a bot when a slim payload diff clears the bot id to an empty string', async () => {
+ stubPendingCallRecordingQueries({ externalBotId: '' });
+
+ const result = await scheduleRecallBotOnCallRecordingUpdateHandler(
+ buildUpdateEvent({
+ properties: {
+ updatedFields: ['externalBotId'],
+ diff: {
+ externalBotId: { before: 'recall-bot-vanished', after: '' },
+ },
+ },
+ } as unknown as HandlerEvent),
+ );
+
+ expect(result).toEqual({
+ callRecordingId: 'call-recording-1',
+ result: { status: 'scheduled' },
+ });
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ });
+
it('skips events that are not call recording updates', async () => {
const result = await scheduleRecallBotOnCallRecordingUpdateHandler(
buildUpdateEvent({ name: 'callRecording.created' } as HandlerEvent),
diff --git a/packages/twenty-apps/public/call-recorder/src/logic-functions/schedule-recall-bot-on-call-recording-update.ts b/packages/twenty-apps/public/call-recorder/src/logic-functions/schedule-recall-bot-on-call-recording-update.ts
index f25729fe34c..68fa1492a46 100644
--- a/packages/twenty-apps/public/call-recorder/src/logic-functions/schedule-recall-bot-on-call-recording-update.ts
+++ b/packages/twenty-apps/public/call-recorder/src/logic-functions/schedule-recall-bot-on-call-recording-update.ts
@@ -13,6 +13,7 @@ import {
resumePendingCallRecording,
type ResumePendingCallRecordingResult,
} from 'src/logic-functions/flows/resume-pending-call-recording.util';
+import { isNonEmptyString } from 'src/logic-functions/utils/is-non-empty-string.util';
const CALL_RECORDING_OBJECT_NAME = 'callRecording';
@@ -94,8 +95,8 @@ const contradictsPendingCallRecording = (
CallRecordingRequestStatus.REQUESTED) ||
(!isUndefined(knownValues.status) &&
knownValues.status !== CallRecordingStatus.SCHEDULED) ||
- (!isUndefined(knownValues.externalBotId) &&
- knownValues.externalBotId !== null)
+ // Event payloads serialize a NULL text column as an empty string.
+ isNonEmptyString(knownValues.externalBotId)
);
};