Twilio出站呼叫-向现有呼叫添加更多人
我正在尝试创建一个web应用程序,其中:Twilio出站呼叫-向现有呼叫添加更多人,twilio,twilio-twiml,twilio-conference,Twilio,Twilio Twiml,Twilio Conference,我正在尝试创建一个web应用程序,其中: 我通过twilio从浏览器应用程序拨出电话号码。我正在使用Twilio客户端(js)V1.10.1作为浏览器应用程序。 后端webhook是使用Twilio的拨号和数字动词用Java编写的。我能够用twilio的可编程语音来实现它 伪代码如下所示 前端代码 let device = require('twilio-client').Device; let outboundCall = ''; const twilioInit = () => { /
let device = require('twilio-client').Device;
let outboundCall = '';
const twilioInit = () => {
// twilio client initialization logic goes here
}
// on phone icon click i am calling the below method
const makeOutboundCall = () => {
outboundCall = device.connect({
To: TO_NUMBER // The first to number
});
}
后端代码-服务器端(webhook)
@RequestMapping(value = "/callMobile", produces = "text/xml")
public String callByBrowserToMobile(@RequestParam String ApplicationSid, @RequestParam String ApiVersion,
@RequestParam String Called, @RequestParam String Caller, @RequestParam String CallStatus,
@RequestParam String To, @RequestParam String From, @RequestParam String CallSid,
@RequestParam String Direction, @RequestParam String AccountSid) {
LOG.info("Call by browser to mobile");
String voiceCallBackUri = new StringBuilder(
env.getProperty("twilio.exposed.uri").concat("/conferenceCallBack")).toString();
String joinConferenceUri = new StringBuilder(
env.getProperty("twilio.exposed.uri").concat("/joinConference")).toString();
String fromNumber = "+xxxxxxxxx35"; // Bought Twilio Number
Call call = Call.creator(
new com.twilio.type.PhoneNumber("+"+To),
new com.twilio.type.PhoneNumber(fromNumber),
URI.create(joinConferenceUri))
.setMethod(HttpMethod.GET)
.setStatusCallback(URI.create(voiceCallBackUri))
.setStatusCallbackMethod(HttpMethod.POST)
.create();
Conference.Builder conferenceBuilder = new Conference.Builder("My Conference");
Dial dial = new Dial.Builder().conference(conferenceBuilder.build()).build();
VoiceResponse twiml = new VoiceResponse.Builder().dial(dial).build();
return twiml.toXml();
}
@RequestMapping("/joinConference")
public String joinConference() {
LOG.info("joinConference");
Conference.Builder conferenceBuilder = new Conference.Builder("My Conference");
Dial dial = new Dial.Builder().conference(conferenceBuilder.build()).build();
VoiceResponse twiml = new VoiceResponse.Builder().dial(dial).build();
return twiml.toXml();
}
@RequestMapping("/conferenceCallBack")
public void conferenceCallBack(@RequestParam String Called, @RequestParam String ToState,
@RequestParam String CallerCountry, @RequestParam String Timestamp, @RequestParam String Direction,
@RequestParam String CallbackSource, @RequestParam String SipResponseCode, @RequestParam String CallerState,
@RequestParam String ToZip, @RequestParam String SequenceNumber, @RequestParam String To,
@RequestParam String CallSid, @RequestParam String ToCountry, @RequestParam String CallerZip,
@RequestParam String ApiVersion, @RequestParam String CalledZip,@RequestParam String CallStatus,
@RequestParam String CalledCity, @RequestParam String Duration, @RequestParam String From,
@RequestParam String CallDuration, @RequestParam String AccountSid, @RequestParam String CalledCountry,
@RequestParam String CallerCity, @RequestParam String Caller, @RequestParam String FromCountry,
@RequestParam String ToCity, @RequestParam String FromCity, @RequestParam String CalledState,
@RequestParam String FromZip, @RequestParam String FromState) {
LOG.info("conferenceCallBack");
}
使用上述会议代码时,呼叫者(浏览器应用程序)会听到等待会议通话的音乐,被呼叫者会接到电话,但当被选中时,只会听到会议名称,被呼叫者的电话会断开。请提供查找问题的指南。您可以使用代理会议。 下面是示例代码和如何工作的高级图片
这里是Twilio开发者福音传道者 您没有将
/joinConference
路由作为text/xml
提供服务,因此Twilio将其作为text/plain
阅读,并将其视为
我认为您需要将products='text/xml'
添加到RequestMapping
,如下所示:
@RequestMapping("/joinConference", produces = "text/xml")
让我知道这是否有帮助。我尝试了上述链接中提到的方法。当发出初始出站呼叫时,浏览器应用程序会收到音乐等待音,接收者会收到呼叫。当接受者接听电话时,只需说出会议名称并退出即可。请引导。听起来好像呼叫者不在会议中根据我的理解,呼叫者(浏览器应用程序)在会议中,而被呼叫者不在会议中,因为对于呼叫者,呼叫将继续使用默认的会议通话保持音乐,而对于被呼叫者,在听到会议名称后,呼叫将中断。我将很快分享代码。请帮忙。您好@A-Developer-Has-No-Name,我已经编辑了这个问题,添加了用于电话会议的代码。谢谢@philnash,我会尽力让您知道的。
@RequestMapping("/joinConference", produces = "text/xml")