I'm trying to connect two personal numbers (two-way calling) through nodejs + express. Not even the current scenario is:
export const ligar = async(
config: {idConta: string, token: string, idServico: string},
originPhone: string,
telefoneDestino: string) => {
const client = new Twilio(config.idConta, config.token);
const twilioPhone = "13347693216";
try {
const call = await client.calls.create({
from: `+${twilioPhone}`,
to: `+${originPhone}`,
url: `${process.env.AVAIABLE_ORIGIN}:${process.env.PORT}/voz?destino=${telefoneDestino}`,
});
console.log('Start call');
console.log(call);
return {sid: call.sid, duracao: 0};
} catch (error) {
throw new TwilioError(`Ocorreu um problema ao iniciar a ligação: ${error}`);
}
}
app.post('/voz', (req, res) => {
var numeroDestino = req.query.destino as string;
if(!numeroDestino) throw new TwilioError(`Número de destino ${numeroDestino} não foi recebido.`);
const response = new VoiceResponse();
const dial = response.dial();
dial.number(numeroDestino);
console.log(`Conectando com: ${numeroDestino}`);
res.type('text/xml');
res.send(response.toString());
});
Am I missing something?
I've already tested other scenarios, with Conference, for example. Also without success. Following the voice trace of the calls, the first one doesn't seem to end correctly. Does the number need to have something specific enabled? Does it need to be on and have a signal, for example?
In the scenario as it is here, the second party connects and the first doesn't.