Twilio - 启动出站会议,但在呼叫者之前将收件人添加到会议

时间:2015-08-10 18:33:50

标签: ruby twilio

我试图使用Twilio发起从客户端到出站号码的呼叫。我想要发生的是:

人员A使用客户端拨打人员B.当B人员接听时,他们会被引导到会议中。一旦B人在会议中,我想将A人引导到同一个会议中。

这是我到目前为止使用的Twiml和twilio-ruby助手库:

def dial 
  default_number = "+1234567890"
  caller_id = params[:OutgoingNumber].nil? ? default_number : params[:OutgoingNumber]
  outbound_number = params[:PhoneNumber].gsub(/\D/, '')
  conference_name = "call_#{outbound_number}"

  response = Twilio::TwiML::Response.new do |r|
    r.Dial :callerId => caller_id do |d|
      d.Number outbound_number, :url => "/twilio-connect?name=#{conference_name}&recipient=true"
    end
  end

  render_twiml response
end

def outgoing_connect #"/twilio-connect"
  conference_name = params["name"]
  record = params["record"]
  init_call_id = params[:ParentCallSid]

  response = Twilio::TwiML::Response.new do |r|
    r.Dial do |d|
      if recipient == "false"
        d.Conference conference_name, :record => "record-from-start"
      else 
        d.Conference conference_name
      end
    end
  end

  if recipient == "true"
    client = Twilio::REST::Client.new Rails.application.config.secrets["twilio_sid"], Rails.application.config.secrets["twilio_token"]
    call = client.account.calls.get(init_call_id)
    call.update(:url => "https://www.example.com/twilio-connect?name=#{conference_name}&record=true", :method => "POST")
  end

  render_twiml response
end

我没有成功更新/重定向人员A进入会议。一旦B人出席会议,Persona A对话的一方就会停止响铃。

0 个答案:

没有答案