下面是一些我想完成的步驟:我怎樣才能改變通話這是正在進行的與Twilio和的NodeJS
- 呼叫,並最終文本,我的Twilio號
- 集聚了一批以呼叫。
- 創建我的當前呼叫並將其移至電話會議中。
- 調用收集的號碼。
- 將被叫號碼加入與我的會議。
目前我可以撥打我的Twilio號碼,收集一個號碼,創建一個電話會議 - 但是我迷路的是呼叫收集的號碼以及將它們添加到我創建的會議中。
app.post('/call', function(req, res) {
var twiml = new twilio.TwimlResponse();
res.type('text/xml');
if (req.body.From === '+15555555555) {
twiml.gather({
action: '/call/initiate',
finishOnKey: '#',
numDigits: '10',
timeout: '5'
}, function() {
this.say('Enter your number', {
voice: 'man'
});
});
}
else {
twiml.redirect(VOICEMAIL_TWIMLET_OF_CHOICE);
}
res.send(twiml.toString());
});
// Initiate a call from text
app.post('/call/initiate', function(req, res) {
// Create new Twiml response
var twiml = new twilio.TwimlResponse();
// Phone number to call and add to conference
var to = req.body.Digits;
// Create random conference name
var conferenceName = Math.floor(Math.random() * 10000).toString();
// Add myself to the conference call
twiml.dial((node) => {
node.conference(conferenceName, {
startConferenceOnEnter: true,
record: true,
beep: 'true'
});
});
// Redirect twiml to a new url
// Send conferenceName & Number
twiml.redirect('/join_conference?id=' + conferenceName + '&number=' + to);
res.set('Content-Type', 'text/xml');
res.send(twiml.toString());
});
// Call and add caller to conference
app.post('/join_conference', (req, res) => {
var conferenceName = req.query.id;
var to = '+1' + req.query.number;
// Create new Twiml response
var twiml = new twilio.TwimlResponse();
// Call and add user to conference call
twiml.dial(to, (node) => {
node.conference(conferenceName, {
startConferenceOnEnter: true,
});
});
console.log('call called');
res.set('Content-Type', 'text/xml');
res.send(twiml.toString());
});
後,我進入了數字和打finishOnKey
我聽到自動等待音樂。然而,在這一點上 - 應用程序只是掛起,並沒有放置電話。
我試過這些更改沒有成功。這個過程仍然掛在'/ call/initiate'上。似乎根本沒有打電話給第二方,從日誌中我可以看到它從來沒有擊中'join_conference'端點。 – JorgeEstaAqui
我編輯了我的答案。我會嘗試從呼叫生成中捕獲任何錯誤,這可能會顯示正在發生的事情。 – philnash
謝謝 - 我應該知道這樣做。我更新了代碼以包含錯誤處理。現在我發現我的網址無效。 (https://www.twilio.com/docs/api/errors/21205)。我瀏覽了我的Twilio儀表板,並沒有看到需要爲這種類型的請求設置處理的位置。 – JorgeEstaAqui