Twilio Studio > Function > Voicemail Issue

£可爱£侵袭症+ 提交于 2019-12-11 06:55:10

问题


We are currently using Twilio Studio to accept incoming calls. These calls are then handed off to a function, which is a modified version of https://github.com/philnash/useful-twilio-functions/tree/master/hunt, which attempts to reach the agent on their cellphone using whisper (which Studio doesn't support natively). This is the main function:

exports.handler = function(context, event, callback) {
  const numbers = context.AGENT1_NUMBERS.split(',').map(number => number.trim());
  const response = new Twilio.twiml.VoiceResponse();
  if (event.DialCallStatus === 'complete') {
    // Call was answered and completed
    response.hangup();
  } else if (event.finished === 'true') {
    if (context.AGENT1_FINAL_URL) {
      response.redirect(context.AGENT1_FINAL_URL);
    } else {
      response.hangup();
    }
  } else {
    const numberToDial = event.nextNumber ? event.nextNumber : numbers[0];
    const currentNumberIndex = numbers.indexOf(numberToDial);
    let url;
    if (currentNumberIndex + 1 === numbers.length) {
      // No more numbers to call after this.
      url = 'https://redacted.twil.io/agent1?finished=true';
    } else {
      const nextNumber = numbers[currentNumberIndex + 1];
      url = 'https://redacted.twil.io/agent1?nextNumber=' + encodeURIComponent(nextNumber);
    }
    const dial = response.dial({ action: url });
    dial.number({ url: 'https://URL_TO_WHISPER_TWIML' }, numberToDial);
  }
  callback(null, response);
};

This is the TwiML Bin for whisper.

<?xml version="1.0" encoding="UTF-8"?>
<Response>
  <Gather action="URL_TO_FUNCTION" numDigits="1">
   <Say>You are receiving a call, please dial 1 to accept or anything else to reject</Say>
  </Gather>
</Response>

This is the next function which connects the call.

exports.handler = function(context, event, callback) {
  const response = new Twilio.twiml.VoiceResponse();
  if (event.Digits === '1') {
    response.say('Connecting');
  } else {
    response.hangup();
  }
  callback(null, response);
}

Now, the issue here is that the AGENT1_FINAL_URL points to a TwiML bin that handles voicemail. This process occurs just fine if the call is answered by the agent and disconnected without pressing 1. The caller is sent to the Twilio voicemail. If, however, the agent just misses the call or rejects the call, the call continues to ring on the caller's end until I suspect it's times out, after which the caller is connected anyway and will hear a cut off version of the agents personal voicemail on their cellphone. Any idea why this is happening?

来源:https://stackoverflow.com/questions/51845132/twilio-studio-function-voicemail-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!