首页 > 解决方案 > Sipgate 如何处理传入的 VOIP 呼叫 Python

问题描述

我一直在想,我们如何使用 python 处理带有 sipgate https://api.sipgate.com/v2 API 的来电。我能够发起呼叫,但我不知道如何处理来电,我什至无法在 api doc 上找到任何内容。

在做了一些研究之后我才知道,我们可以通过 sipgate.io 处理来电。如果有人有任何以前的经验,请帮助我开始来电。

这就是我在我的应用程序中寻找的内容:

  1. 处理来电
  2. 处理 dtmf(当用户在通话期间输入数字时,如选项 1-9)
  3. 在选择的基础上,Python脚本需要执行一些动作

标签: pythonsipvoip

解决方案


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.


推荐阅读