There's a problem with the default simulring twimlet in that it'll connect the first call that's answered, even if it's answered by a machine or a phone in airplane mode. This will then hang up on the other outgoing calls.
Because of this, I'm building my own version, but I'm having trouble connecting it all together. I currently have these steps (assume these are handlers for an Express server, and that I'm replacing some callbacks with cb):
POST /twilio/receive
var room_id = 1;
var twiml = new twilio.TwimlResponse();
twiml.dial({}, function(node){
node.conference('room ' + room_id, {waitUrl: '/twilio/' + room_id + '/connecting'});
return;
});
return twiml.toString();
POST /twilio/:room_id/connecting
var room_id = req.params.room_id;
var users = getUsers();
var client = require('twilio')(SID, TOKEN);
var twiml = new twilio.TwimlResponse();
twiml.say('Calling other users');
//Place outgoing calls with REST client
for(var i = 0, j = users.length; i < j; i++){
var user = users[i];
var url = '/twilio/' + room_id + '/join/' + user.id;
client.makeCall({
from: TWILIO_ACCOUNT,
to: user.phone,
url: url
}, cb);
}
//Talk to the original caller
return twiml.toString();
POST /twilio/:room_id/join/:user_id
NOTE!! This handler is never reached
var room_id = req.params.room_id;
var user = getUser(req.params.user_id);
var twiml = new twilio.TwimlResponse();
//Put this user in the conference
twiml.say('Joining room ' + room_id);
twiml.dial({}, function(node){
node.conference('room ' + room_id, {});
return;
});
return twiml.toString();
Instead of the expected behavior, here's what happens:
- App answers the incoming call
- App places outgoing call to my cell phone
- I answer outgoing call and hear, "
Press 1 to start the call or 2 to decline." - If I press
1, it immediately hangs up.
The most outlandish possibility I can imagine is that there's a problem because I'm placing the incoming call via Google Voice and receiving the outgoing call using the Burner app on my cell phone. I imagine the Burner app uses Twilio, and my cell phone uses my Google Voice number, so maybe there's something crazy going on there. Otherwise, I'm stumped.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire