mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage-server
synced 2026-04-11 18:08:16 +00:00
feat: Kookoo IVR endpoint — outbound calls now bridge to agent SIP
When customer answers outbound call, Kookoo hits /kookoo/ivr which returns <dial record="true">523590</dial> to bridge the call to the agent's SIP extension. Agent's browser rings, both connect. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
49
src/ozonetel/kookoo-ivr.controller.ts
Normal file
49
src/ozonetel/kookoo-ivr.controller.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import { Controller, Get, Query, Logger, Header } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
|
||||
@Controller('kookoo')
|
||||
export class KookooIvrController {
|
||||
private readonly logger = new Logger(KookooIvrController.name);
|
||||
private readonly sipId: string;
|
||||
|
||||
constructor(private config: ConfigService) {
|
||||
this.sipId = process.env.OZONETEL_SIP_ID ?? '523590';
|
||||
}
|
||||
|
||||
@Get('ivr')
|
||||
@Header('Content-Type', 'application/xml')
|
||||
handleIvr(@Query() query: Record<string, any>): string {
|
||||
const event = query.event ?? '';
|
||||
const sid = query.sid ?? '';
|
||||
const cid = query.cid ?? '';
|
||||
const data = query.data ?? '';
|
||||
const status = query.status ?? '';
|
||||
|
||||
this.logger.log(`Kookoo IVR: event=${event} sid=${sid} cid=${cid} status=${status}`);
|
||||
|
||||
// New outbound call — customer answered, connect to agent's SIP
|
||||
if (event === 'NewCall') {
|
||||
this.logger.log(`Connecting customer ${cid} to agent SIP ${this.sipId}`);
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<response>
|
||||
<dial record="true" timeout="30" moh="ring">${this.sipId}</dial>
|
||||
</response>`;
|
||||
}
|
||||
|
||||
// Dial event — call to agent finished
|
||||
if (event === 'Dial') {
|
||||
this.logger.log(`Dial completed: status=${status} data=${data}`);
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<response>
|
||||
<hangup/>
|
||||
</response>`;
|
||||
}
|
||||
|
||||
// Hangup or any other event
|
||||
this.logger.log(`Call ended: event=${event}`);
|
||||
return `<?xml version="1.0" encoding="UTF-8"?>
|
||||
<response>
|
||||
<hangup/>
|
||||
</response>`;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user