fix: camelCase field names + dial uses per-agent config

Defect 5: Worklist, missed-call-webhook, missed-queue, ai-chat, and
rules-engine all used legacy lowercase field names (callbackstatus,
callsourcenumber, missedcallcount, callbackattemptedat) from the old
VPS schema. Fixed to camelCase (callbackStatus, callSourceNumber,
missedCallCount, callbackAttemptedAt) matching the current SDK sync.

Defect 6: Dial endpoint used global defaults (OZONETEL_AGENT_ID env
var) instead of the logged-in agent's config. Now accepts agentId
and campaignName from the frontend request body. Falls back to
telephony config → DID-derived campaign name → explicit error.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 14:29:19 +05:30
parent 7717536622
commit 898ff65951
6 changed files with 38 additions and 29 deletions

View File

@@ -157,7 +157,7 @@ export class OzonetelAgentController {
if (newStatus) {
try {
await this.platform.query<any>(
`mutation { updateCall(id: "${body.missedCallId}", data: { callbackstatus: ${newStatus} }) { id } }`,
`mutation { updateCall(id: "${body.missedCallId}", data: { callbackStatus: ${newStatus} }) { id } }`,
);
} catch (err) {
this.logger.warn(`Failed to update missed call status: ${err}`);
@@ -191,19 +191,28 @@ export class OzonetelAgentController {
@Post('dial')
async dial(
@Body() body: { phoneNumber: string; campaignName?: string; leadId?: string },
@Body() body: { phoneNumber: string; agentId?: string; campaignName?: string; leadId?: string },
) {
if (!body.phoneNumber) {
throw new HttpException('phoneNumber required', 400);
}
const campaignName = body.campaignName ?? this.telephony.getConfig().ozonetel.campaignName ?? 'Inbound_918041763265';
const agentId = body.agentId ?? this.defaultAgentId;
const campaignName = body.campaignName
?? this.telephony.getConfig().ozonetel.campaignName
?? this.telephony.getConfig().ozonetel.did
? `Inbound_${this.telephony.getConfig().ozonetel.did}`
: '';
this.logger.log(`[DIAL] phone=${body.phoneNumber} campaign=${campaignName} agentId=${this.defaultAgentId} lead=${body.leadId ?? 'none'}`);
if (!campaignName) {
throw new HttpException('Campaign name not configured — set in Telephony settings or pass campaignName', 400);
}
this.logger.log(`[DIAL] phone=${body.phoneNumber} campaign=${campaignName} agentId=${agentId} lead=${body.leadId ?? 'none'}`);
try {
const result = await this.ozonetelAgent.manualDial({
agentId: this.defaultAgentId,
agentId,
campaignName,
customerNumber: body.phoneNumber,
});