接听 twilio 电话时收到通知
我正在构建一个 twilio 应用程序,并且希望在使用 twilio 拨打的电话被接听时收到通知。我正在使用 python api 进行调用,如下所示:
call = client.calls.create(to=number,
from_="15555555555",
url=twiml_url,
status_callback=status_url)
这一切都工作正常。当拨打电话时,我会收到通知,通过 POST 到 twiml_url,并在通话结束时通过 POST 到 status_url。在这两种情况下,我都传递了 CallStatus,第一个值为 'ringing',第二个 'completed'
现在,我已阅读 API 文档并知道他们说这是预期的行为。
我想知道的是,是否有任何方法可以为其他 CallStatus 更改获得类似的效果?根据 Twilio,以下所有值都是 CallStatus 的可能值:
排队、振铃、进行中、 已完成、失败、忙碌或无答案
拥有所有不同的似乎毫无意义CallStatus 尚未提供为他们回调。
最终,我想要实现的是检测何时接听电话。目前我能看到的唯一方法是定期轮询并手动检查 CallStatus 是否已更改 - 不太好。
I'm building a twilio app and would like to get notified when a call made using twilio is picked up. I'm using the python api to make the call, like so:
call = client.calls.create(to=number,
from_="15555555555",
url=twiml_url,
status_callback=status_url)
This all works fine. I get notified when the call is made, by a POST to twiml_url and a POST to status_url when the call ends. In both of these cases I get passed the CallStatus, in the first with the value 'ringing', in the second 'completed'
Now, I have read the API docs and know that they say that this is the expected behaviour.
What I'm wondering is, is if there is any way to get a similar kicks for the other CallStatus changes? According to Twilio, all of the following are possible values for CallStatus:
queued, ringing, in-progress, completed, failed, busy or no-answer
It seems kind of pointless to have all the different CallStatus's yet not provide callbacks for them.
Ultimately, what I'm trying to achieve is to detect when a call is picked up. The only way I can see of doing this currently is by polling periodically and manually checking if the CallStatus has changed - hardly great.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 Twilio 的 Ricky 在这里。我们在 API 中添加了一项新功能,我对此非常兴奋,名为 呼叫进度事件。它允许开发人员传递有关其呼叫的事件列表,例如响铃或完成,他们希望在呼叫时收到通知。我认为这可能对这个用例有所帮助,因为您可以使用以下代码告诉 API 在应答呼叫时通知您:
如果您不使用 Python,文档中的此示例将让您了解如何使用 PHP、C#、Ruby、 Node.js、Java 或者 - 如果你喜欢踢它的命令行样式 - 一个curl命令。
Ricky from Twilio here. We've added a rad new feature to our API that I'm pretty stoked about called Call Progress Events. It allows a developer to pass a list of events about their call, such as ringing or completed, that they want to be notified about with their call. I think it may help a bit with this use case because you could tell the API to just notify you when a call is answered by using this code:
If you're not using Python, this example in the docs will let you see how to use Call Progress Events with PHP, C#, Ruby, Node.js, Java or - if you like kicking it command line style - a curl command.