首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如果twilio呼叫状态为无应答,如何将其路由到另一个号码?

如果twilio呼叫状态为无应答,如何将其路由到另一个号码?
EN

Stack Overflow用户
提问于 2020-06-16 04:52:43
回答 1查看 176关注 0票数 1
代码语言:javascript
复制
 if (OkToCall)
        {
            if (CallCount == 0)
            {
                voiceResponse.Say(sayMessage);
                voiceResponse.Dial(number: number1, timeout: 24, action: new Uri("/OnCall/?Location=" + Location + "&CallCount=1", UriKind.Relative));
            }
            else if (CallCount == 1)
            {
                sayMessage = "We're sorry. There was no answer. You are now being redirected to the on call manager. One moment. ";
                voiceResponse.Say(sayMessage);
                voiceResponse.Dial(number: number2, timeout: 24, action: new Uri("/OnCall/?Location=" + Location + "&CallCount=2", UriKind.Relative));
            }
            else
            {
                sayMessage = "We're sorry. We were unable to connect your call. Please try again later.";
                voiceResponse.Say(sayMessage);
                voiceResponse.Hangup();
            }
        }
        else
        {
            sayMessage = "We're sorry. An error occured while redirecting your call. Please try again later.";
            voiceResponse.Say(sayMessage);
            voiceResponse.Hangup();
        }

上面的过程工作得很好,除非被呼叫者在呼叫者挂断之前挂断,然后呼叫者被路由到下一个人。我想检查呼叫状态,看看是否需要路由。我该怎么做?

EN

回答 1

Stack Overflow用户

发布于 2020-06-16 06:11:33

这个Twilio函数涵盖了一般的逻辑。

Implement voicemail

代码语言:javascript
复制
/**
 *  Voicemail Action URL
 * 
 *  This Function is used in as the action URL in a Dial. If the call isn't answered or the line is busy, 
 *  the call is forwarded to a specified Voicemail URL.
 */

exports.handler = function(context, event, callback) {
  // set-up the variables 
  // generate the TwiML to tell Twilio how to forward this call
  let twiml = new Twilio.twiml.VoiceResponse();

  if (event.DialCallStatus === "completed") {
    twiml.hangup();
  }
  else {
    twiml.redirect('<URL-TO-VOICEMAIL-TWIML>');
  }

  // return the TwiML
  callback(null, twiml);
};
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62396823

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档