mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-04-11 18:08:16 +00:00
feat: Ozonetel V3 dial endpoint, worklist query fixes
- Switch outbound dial to /CAServicesV3/mdlConnection.php (tbManualDial) - Use both Apikey + Basic Auth headers matching Ozonetel toolbar pattern - Auto-login agent before dial attempt - Dial controller returns 502 (not 401) for Ozonetel errors to prevent session logout - Fix worklist: remove non-existent callId from followUp query - Fix worklist: use unquoted MISSED enum, remove callerNumber subfield issue - Worklist controller resolves agent name from platform currentUser API Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,11 +1,23 @@
|
||||
import { Controller, Post, Body, Logger, HttpException } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { OzonetelAgentService } from './ozonetel-agent.service';
|
||||
|
||||
@Controller('api/ozonetel')
|
||||
export class OzonetelAgentController {
|
||||
private readonly logger = new Logger(OzonetelAgentController.name);
|
||||
private readonly defaultAgentId: string;
|
||||
private readonly defaultAgentPassword: string;
|
||||
|
||||
constructor(private readonly ozonetelAgent: OzonetelAgentService) {}
|
||||
private readonly defaultSipId: string;
|
||||
|
||||
constructor(
|
||||
private readonly ozonetelAgent: OzonetelAgentService,
|
||||
private readonly config: ConfigService,
|
||||
) {
|
||||
this.defaultAgentId = config.get<string>('OZONETEL_AGENT_ID') ?? 'agent3';
|
||||
this.defaultAgentPassword = config.get<string>('OZONETEL_AGENT_PASSWORD') ?? '';
|
||||
this.defaultSipId = config.get<string>('OZONETEL_SIP_ID') ?? '521814';
|
||||
}
|
||||
|
||||
@Post('agent-login')
|
||||
async agentLogin(
|
||||
@@ -40,4 +52,34 @@ export class OzonetelAgentController {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Post('dial')
|
||||
async dial(
|
||||
@Body() body: { phoneNumber: string; leadId?: string },
|
||||
) {
|
||||
if (!body.phoneNumber) {
|
||||
throw new HttpException('phoneNumber required', 400);
|
||||
}
|
||||
|
||||
this.logger.log(`Dial request: ${body.phoneNumber} (lead: ${body.leadId ?? 'none'})`);
|
||||
|
||||
try {
|
||||
// Ensure agent is logged in before dialing
|
||||
await this.ozonetelAgent.loginAgent({
|
||||
agentId: this.defaultAgentId,
|
||||
password: this.defaultAgentPassword,
|
||||
phoneNumber: this.defaultSipId,
|
||||
mode: 'blended',
|
||||
});
|
||||
|
||||
const result = await this.ozonetelAgent.dialCustomer({
|
||||
agentId: this.defaultAgentId,
|
||||
customerNumber: body.phoneNumber,
|
||||
});
|
||||
return result;
|
||||
} catch (error: any) {
|
||||
const message = error.response?.data?.message ?? error.message ?? 'Dial failed';
|
||||
throw new HttpException(message, 502);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user