一天中特定时间的 Twilio 呼叫转移 [英] Twilio call forwarding for specific time of day

查看:34
本文介绍了一天中特定时间的 Twilio 呼叫转移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过 Twilio 实现一项服务,在一天中的特定时间将入站呼叫发送到录音.

With Twilio I'd like to implement a service that sends inbound calls to a voice recording during specific times of day.

Twilio 可以提供这种行为吗?

Can Twilio provide this behavior?

推荐答案

Twilio 开发人员布道者在这里.你绝对可以做到!我不确定您使用的是哪种语言或框架,但这里有一个关于您如何实现这一点的想法.

Twilio developer evangelist here. You can absolutely do that! I'm not sure what language or framework you're using, but here's an idea of how you'd accomplish this.

当 Twilio 收到有关 Twilio 号码的呼叫时,它会向您的服务器发出 Webhook 请求以进行响应并告诉它如何处理该呼叫.这些说明是用 XML 构建的(TwiML).因此,要执行基于时间的操作,您可能想要执行以下操作(我的示例是在 Ruby 中使用 Sinatra 作为 Web 框架):

When Twilio receives a call on a Twilio number it makes a webhook request to your server to respond and tell it what to do with the call. The instructions are built in XML (TwiML). So, to do time based stuff you probably want to do something like this (my example is in Ruby using Sinatra as a web framework):

post '/call' do
  time = Time.now
  content_type 'text/xml'
  response = "<Response>"
  if out_of_hours?(time)
    response = "<Say>Please leave a message</Say><Record />"
  else
    response = "<Dial><Number>YOUR_PHONE_NUMBER</Number></Dial>"
  end
  response = "</Response>"
  response
end

然后您可以定义 out_of_hours? 以遵循您想要的规则.

You can then define out_of_hours? to follow the rules you want.

希望对您有所帮助,如果您有任何其他问题,请告诉我.

I hope this help, please let me know if you have any other questions.

这篇关于一天中特定时间的 Twilio 呼叫转移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆