如何从 Twilio 电话会议自动呼叫(浏览器)客户端?

How to automatically call a (browser) Client from a Twilio Conference Call?

场景如下:

假设我们有一个能够允许来电的客户端,名为 "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

现在我们希望罗杰在他的浏览器上接听来电,但我们希望电话是电话会议,而不是 phone-to-browser 电话(不确定是否有技术名称) .如何在电话会议中将 James 连接到 Roger?

这里是 Twilio 开发人员布道者。

遗憾的是,这不像单个 TwiML 响应那么简单。您需要做的是让 James 加入电话会议,同时向 Roger 的客户发起呼叫,接听后他也会加入电话会议。

代码(pseudo-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

如果有帮助请告诉我!