以下是该方案:
假设我们有一个能够允许来电的客户,名为" Roger"。
詹姆斯称我们的Twilio号码
conferenceName = "conftest"
caller_id = "+15555555555"
response = Twilio::TwiML::Response.new do |r|
r.Dial :callerId => caller_id do |d|
d.Client 'Roger'
end
end
现在我们希望Roger在他的浏览器上接听来电,但我们希望电话是电话会议,而不是电话到浏览器的呼叫(不确定是否有技术名称)。如何在电话会议中将詹姆斯连接到罗杰?
答案 0 :(得分:1)
Twilio开发者传道者在这里。
可悲的是,这并不像单个TwiML响应那么简单。您需要做的就是将詹姆斯召集到电话会议中,同时向罗杰的客户发起一个电话,该电话会在接听电话时将他带入电话会议。
使用代码(伪sinatra格式),如下所示:
conference_name = "conftest"
caller_id = "+15555555555"
# Set the Twilio number endpoint URL to /dial, this will drop James into
# the conference and initiate the call to Roger.
post '/dial' do
response = Twilio::TwiML::Response.new do |r|
r.Dial do |d|
d.Conference conference_name
end
end
# create a REST API client with your Account SID and Auth token
client = Twilio::REST::Client.new "AC123...", "XYZ456..."
client.calls.create from: caller_id, to: "Roger", url: "/client_dial"
response.to_xml
end
# This endpoint is the one that Twilio will hit when Roger answers the
# client incoming call. All we need to do is drop him into the same
# conference call.
post "/client_dial" do
response = Twilio::TwiML::Response.new do |r|
r.Dial do |d|
d.Conference conference_name
end
end
response.to_xml
end
请告诉我这是否有帮助!