feat: webhook field fixes, Force Ready endpoint, improved error logging

- Fix Call record field names (recording, callerNumber, durationSec)
- Add POST /api/ozonetel/agent-ready using logout+login for Force Ready
- Add callerNumber to kookoo callback
- Better error logging with response body

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-20 20:22:47 +05:30
parent 8c6cd2c156
commit 58225b7943
4 changed files with 49 additions and 22 deletions

View File

@@ -105,8 +105,9 @@ export class MissedCallWebhookController {
}
return { received: true, processed: true, callId, leadId: lead?.id ?? null };
} catch (err) {
this.logger.error(`Webhook processing failed: ${err}`);
} catch (err: any) {
const responseData = err?.response?.data ? JSON.stringify(err.response.data) : '';
this.logger.error(`Webhook processing failed: ${err.message} ${responseData}`);
return { received: true, processed: false, error: String(err) };
}
}
@@ -123,21 +124,24 @@ export class MissedCallWebhookController {
disposition: string | null;
ucid: string | null;
}, authHeader: string): Promise<string> {
const callData: Record<string, any> = {
name: `${data.direction === 'INBOUND' ? 'Inbound' : 'Outbound'}${data.callerPhone}`,
direction: data.direction,
callStatus: data.callStatus,
callerNumber: { primaryPhoneNumber: `+91${data.callerPhone}` },
agentName: data.agentName,
startedAt: data.startTime ? new Date(data.startTime).toISOString() : null,
endedAt: data.endTime ? new Date(data.endTime).toISOString() : null,
durationSec: data.duration,
disposition: this.mapDisposition(data.disposition),
};
if (data.recordingUrl) {
callData.recording = { primaryLinkUrl: data.recordingUrl, primaryLinkLabel: 'Recording' };
}
const result = await this.platform.queryWithAuth<any>(
`mutation($data: CallCreateInput!) { createCall(data: $data) { id } }`,
{
data: {
name: `${data.direction === 'INBOUND' ? 'Inbound' : 'Outbound'}${data.callerPhone}`,
direction: data.direction,
callStatus: data.callStatus,
agentName: data.agentName,
startedAt: data.startTime ? new Date(data.startTime).toISOString() : null,
endedAt: data.endTime ? new Date(data.endTime).toISOString() : null,
durationSec: data.duration,
disposition: this.mapDisposition(data.disposition),
recordingUrl: data.recordingUrl ? { primaryLinkUrl: data.recordingUrl, primaryLinkLabel: 'Recording' } : undefined,
},
},
{ data: callData },
authHeader,
);
return result.createCall.id;
@@ -185,7 +189,7 @@ export class MissedCallWebhookController {
occurredAt: new Date().toISOString(),
performedBy: data.performedBy,
channel: data.channel,
durationSeconds: data.durationSeconds,
durationSec: data.durationSeconds,
outcome: data.outcome,
leadId: data.leadId,
},