// ============= Snoop Channel ========================
const snoopChannel = await channel.snoopChannelWithId({
snoopId: `${channel.id}-snoop`,
spy: 'both',
// whisper: 'out',
app: process.env.APP_ASTERISK,
});
// ====================================================
const { fileName } = generateAudioFileName(`${ccPhoneNumber}_${userPhoneNumber}`);
await bridgeRecorder.record({
name: fileName,
format: 'wav',
}).catch(err => {
err.message = `ERROR RECORDING FULL: ${err.message}`;
logger.error(err);
});
await bridgeIn.record({
name: fileName + '_in',
format: 'wav',
}).catch(err => {
err.message = `ERROR RECORDING FULL: ${err.message}`;
logger.error(err);
});
const cdr = await buildCdrInRedis({
account,
userPhoneNumber,
ccPhoneNumber,
startedAt,
bridgeId,
channelId: channel.id,
botId: bot._id,
externalId: externalChannel.id,
fullAudio: `${fileName}.wav`,
});
await bridgeIn.addChannel({
channel: channel.id,
});
await bridgeRecorder.addChannel({
channel: snoopChannel.id,
});
await channel.answer();