Twilio会议连接延迟

时间:2019-02-04 20:38:28

标签: node.js twilio twilio-api

我正在使用Twilio设置入站呼叫中心。我使用SIP软电话作为端点。我几乎可以按照自己的方式进行所有工作,但是在尝试对我的一个sip端点进行“会议”时存在一个主要问题。

服务代表要等到通话大约7秒钟后才能听到呼叫者的话。入站呼叫者可以很好地听到服务响应。这只是“会议”的问题。下面的代码还说明了通过拨打分机的直接连接,而该连接根本不会发生连接延迟。

// Inbound Call to Twilio Number
routes.post('/twilio/phone/inbound', (req, res) => {
  const twilioVoice = new VoiceResponse();
  const gather = twilioVoice.gather({
    action: '/twilio/phone/enqueue',
    numDigits: 3,
    timeout: 2
  });
  gather.say('For general inquiries, press 1. If you know the extension of the person you are trying to reach, please enter it now.', {
    loop: 5
  });
  twilioVoice.say('Sorry, I did not get a response. Good bye.');
  twilioVoice.hangup();
  res.type('text/xml');
  res.send(twilioVoice.toString());
});

// Second endpoint to process response from above
routes.post('/twilio/phone/enqueue', (req, res) => {
  var pressedKeys = req.body.Digits;
  var twilioVoice = new VoiceResponse();
  if (pressedKeys.length === 3) {
    console.log("Direct call via extension.")
    twilioVoice.say(`Please hold while we attempt to connect you to extension`);
    twilioVoice.dial().sip('sip:employee@businessname.sip.us1.twilio.com');
    // Once connected, both parties can hear each other immediately.
    res.send(twilioVoice.toString());
  } else {
    twilioVoice.enqueue({
      workflowSid: process.env.WORKFLOW_SID,
    });
    res.type('text/xml');
    res.send(twilioVoice.toString());
  }
});


// Workflow AssignmentCallbackUrl
routes.post('/twilio/phone/assignworker', (req, res) => {
  res.type('application/json');
  // The service rep does not hear the callers words until about 7 seconds into the call
  res.send({
    instruction: "conference",
    to: "sip:employee@businessname.sip.us1.twilio.com"
  });
});

0 个答案:

没有答案