python - Sipgate 如何处理传入的 VOIP 呼叫 Python
问题描述
我一直在想,我们如何使用 python 处理带有 sipgate https://api.sipgate.com/v2 API 的来电。我能够发起呼叫,但我不知道如何处理来电,我什至无法在 api doc 上找到任何内容。
在做了一些研究之后我才知道,我们可以通过 sipgate.io 处理来电。如果有人有任何以前的经验,请帮助我开始来电。
这就是我在我的应用程序中寻找的内容:
- 处理来电
- 处理 dtmf(当用户在通话期间输入数字时,如选项 1-9)
- 在选择的基础上,Python脚本需要执行一些动作
解决方案
To get DTMF data, you need to use the Push-API from sipgate.io. Your server needs to supply a URL, which can then be setup in the sipgate web interface. Every time you get an incoming call, you will get an incoming Webhook (HTTP) request, which supplies you with information about the call, like its call-id.
The call-id can then be used in the REST-API.
After receiving the Webhook, send a Gather
-Follow Up XML-response to get DTMF data.
Here is the example Response you can send to play a sound file and receive follow up events for DTMF data:
<?xml version="1.0" encoding="UTF-8"?>
<Response>
<Gather onData="http://localhost:3000/dtmf" maxDigits="3" timeout="10000">
<Play>
<Url>https://example.com/example.wav</Url>
</Play>
</Gather>
</Response>
Afterwards you will receive onData
-events.
In case node.js is an option for you, you could consider using the sipgate.io node-library. There also exists an example for your use-case utilising the library.
To use the Push API, you have to book the sipgate.io package, that includes 100 free API Calls per Month.
推荐阅读
- sql - 通过多列和条件分组
- excel - 我将如何为允许用户选择可以添加或删除哪些行和/或列信息的用户窗体编写代码
- mysql - 将 nvarchar(max) (MSSQL) 迁移到文本 (MySQL) 时出现问题
- python - Django 站点不会同时加载通过表单/模型提交的 http 和 https 链接
- python - dataframe.empty 给出“真”结果,这应该是“假”imo
- google-apps-script - 使用 Google App Script 更改辅助排序列
- python - 基于多列的计算列
- java - apache HttpClient中每条路由的最大连接数和最大连接数有什么区别?
- cmd - 使用命令提示符根据文件名移动文件
- c# - 如何在 Linq 中使用 2 个表编写此子查询?