我的程序計劃:有人打電話給Twilio號碼,然後我的手機就會打電話。只要我不接受電話,來電者應該聽到音樂或類似的東西,如果我拿起,應該開始會議。如何用twilio開始會議?
目前: 有人正在撥打電話號碼,然後排隊等候音樂,然後我的手機就會被叫醒。聽起來不錯,但是當我拿起時,我們沒有連接。
所以我想我沒有得到妥如何Twilio會議的作品,你可能會有一些建議如何一步一步完成這個。
我的程序計劃:有人打電話給Twilio號碼,然後我的手機就會打電話。只要我不接受電話,來電者應該聽到音樂或類似的東西,如果我拿起,應該開始會議。如何用twilio開始會議?
目前: 有人正在撥打電話號碼,然後排隊等候音樂,然後我的手機就會被叫醒。聽起來不錯,但是當我拿起時,我們沒有連接。
所以我想我沒有得到妥如何Twilio會議的作品,你可能會有一些建議如何一步一步完成這個。
Twilio開發商傳道這裏自動啓動。
好的,您正在構建Node.js,我知道我已經在其他問題中看到過您的代碼,但我將從頭開始創建這個代碼。
隨着Twilio你描述的流程應該看起來像這樣。
讓我們看看我們如何能做到這一點提供的網址在Node.js Express應用程序中:
您需要兩條路由,一條將接收初始請求,另一條將響應接聽電話時發出的請求。查看下面的代碼和評論。
var express = require("express");
var bodyParser = require("body-parser");
var twilio = require("twilio");
var app = express();
app.use(bodyParser.urlencoded({ extended: true }));
var client = twilio(YOUR_ACCOUNT_SID, YOUR_AUTH_TOKEN);
// This is the endpoint your Twilio number's Voice Request URL should point at
app.post('/calls', function(req, res, next) {
// conference name will be a random number between 0 and 10000
var conferenceName = Math.floor(Math.random() * 10000).toString();
// Create a call to your mobile and add the conference name as a parameter to
// the URL.
client.calls.create({
from: YOUR_TWILIO_NUMBER,
to: YOUR_MOBILE_NUMBER,
url: "/join_conference?id=" + conferenceName
});
// Now return TwiML to the caller to put them in the conference, using the
// same name.
var twiml = new twilio.TwimlResponse();
twiml.dial(function(node) {
node.conference(conferenceName, {
waitUrl: "http://twimlets.com/holdmusic?Bucket=com.twilio.music.rock",
startConferenceOnEnter: false
});
});
res.set('Content-Type', 'text/xml');
res.send(twiml.toString());
});
// This is the endpoint that Twilio will call when you answer the phone
app.post("/join_conference", function(req, res, next) {
var conferenceName = req.query.id;
// We return TwiML to enter the same conference
var twiml = new twilio.TwimlResponse();
twiml.dial(function(node) {
node.conference(conferenceName, {
startConferenceOnEnter: true
});
});
res.set('Content-Type', 'text/xml');
res.send(twiml.toString());
});
讓我知道這是否有幫助。
我解決了這個問題由我自己,你需要回答與會議兩個參與者,它會當對方接受呼叫
例
resp.say({voice:'woman'}, 'Welcome to our hotline. This could take a moment, please wait.')
.dial({},function(err){
this.conference('example');
});
是啊謝謝! – nova