Twilio开发者布道者。
这里有几个问题。首先
11205 error
是因为从呼叫到
/voice
端点。这里的问题是,使用
res
. 你可以打电话来解决这个问题
res.send('')
在该功能结束时。
然而
根本不需要执行您正在执行的重定向。您可以使用初始webhook响应将呼叫者放入会议并拨打另一方。您可以使用以下代码执行此操作:
app.post('/voice',(req,res)=>{
conferenceName="test conference room";
url='https://appname.herokuapp.com/addToConference?conferenceName=' + conferenceName;
client.calls.create({
from: YOUR_TWILIO_NUMBER,
to: THE_OTHER_PERSON,
url: url
});
const response=new VoiceResponse();
response.say("Now connecting you to conference "+conferenceName);
dial=response.dial();
dial.conference(conferenceName);
responseTwiml=response.toString();
res.set('Content-Type': 'text/xml');
res.send(responseTwiml);
});
为此,您仍然需要
/addToConference
端点,它只是将另一个调用者添加到会议中,如下所示:
app.get('/addToConference',(req,res)=>{
var conferenceName=req.query.conferenceName;
const response=new VoiceResponse();
response.say("Now connecting you to conference "+conferenceName);
dial=response.dial();
dial.conference(conferenceName);
responseTwiml=response.toString();
console.log("responseTwiml: "+responseTwiml);
res.send(responseTwiml);
});
您还可以按照您最初想要的方式重定向调用者,但是
modifying the call with the REST API
您可以使用
TwiML
<Redirect>
动词看起来是这样的:
app.post('/voice',(req,res)=>{
conferenceName="test conference room";
url='https://appname.herokuapp.com/addToConference?conferenceName=' + conferenceName;
client.calls.create({
from: YOUR_TWILIO_NUMBER,
to: THE_OTHER_PERSON,
url: url
});
const response=new VoiceResponse();
response.redirect(url);
responseTwiml=response.toString();
res.set('Content-Type': 'text/xml');
res.send(responseTwiml);
});
如果有帮助,请告诉我。