diff --git a/src/ozonetel/ozonetel-agent.controller.ts b/src/ozonetel/ozonetel-agent.controller.ts index e574056..8aabd3b 100644 --- a/src/ozonetel/ozonetel-agent.controller.ts +++ b/src/ozonetel/ozonetel-agent.controller.ts @@ -112,6 +112,7 @@ export class OzonetelAgentController { @Body() body: { ucid: string; disposition: string; + agentId?: string; callerPhone?: string; direction?: string; durationSec?: number; @@ -124,16 +125,17 @@ export class OzonetelAgentController { throw new HttpException('ucid and disposition required', 400); } + const agentId = body.agentId ?? this.defaultAgentId; const ozonetelDisposition = this.mapToOzonetelDisposition(body.disposition); // Cancel the ACW auto-dispose timer — the frontend submitted disposition - this.supervisor.cancelAcwTimer(this.defaultAgentId); + this.supervisor.cancelAcwTimer(agentId); - this.logger.log(`[DISPOSE] ucid=${body.ucid} disposition=${body.disposition} → ozonetel="${ozonetelDisposition}" agentId=${this.defaultAgentId} callerPhone=${body.callerPhone ?? 'none'} direction=${body.direction ?? 'unknown'} leadId=${body.leadId ?? 'none'}`); + this.logger.log(`[DISPOSE] ucid=${body.ucid} disposition=${body.disposition} → ozonetel="${ozonetelDisposition}" agentId=${agentId} callerPhone=${body.callerPhone ?? 'none'} direction=${body.direction ?? 'unknown'} leadId=${body.leadId ?? 'none'}`); try { const result = await this.ozonetelAgent.setDisposition({ - agentId: this.defaultAgentId, + agentId, ucid: body.ucid, disposition: ozonetelDisposition, }); @@ -198,11 +200,10 @@ export class OzonetelAgentController { } const agentId = body.agentId ?? this.defaultAgentId; + const did = this.telephony.getConfig().ozonetel.did; const campaignName = body.campaignName - ?? this.telephony.getConfig().ozonetel.campaignName - ?? this.telephony.getConfig().ozonetel.did - ? `Inbound_${this.telephony.getConfig().ozonetel.did}` - : ''; + || this.telephony.getConfig().ozonetel.campaignName + || (did ? `Inbound_${did}` : ''); if (!campaignName) { throw new HttpException('Campaign name not configured — set in Telephony settings or pass campaignName', 400);