通过会议参与者 REST API 向多个客户端发送呼叫

发布于 2025-01-12 06:19:37 字数 1045 浏览 1 评论 0原文

我正在尝试将旧的呼叫流程切换到会议,并且我已将大部分功能移植到会议。我正在尝试处理传入呼叫,以防我必须向多个代理拨打电话并在其中一位代理之后断开呼叫。

现在我正在做一些事情::

Cutomer Calls :: call is sent to webhook ->获取所有活动座席的列表并发送 twiml


<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <Dial>
     <Client>
        <Identity>jane</Identity>
        <Parameter name="FirstName" value ="Jane"/>
        <Parameter name="LastName" value ="Doe" />
      </Client>
     <Client>
        <IdentityHarry</Identity>
        <Parameter name="FirstName" value ="Jane"/>
        <Parameter name="LastName" value ="Doe" />
      </Client>
    </Dial>
</Response>

这样我就可以呼叫两个(或多个)客户端,并在第一个座席应答后挂断电话。

我如何通过会议实现这样的目标? 我想要的是::->

Customer calls:: call is captured into webhook =>
 customer is dropped into the conference call with some music.
- Dial to clients :: (harry, jane) and connect them to the call.

有没有办法通过休息 api 到会议参与者 api 来做到这一点?

I am trying to switch our old call flow to the conference and I have ported most of the features to the conference. I am trying to handle incoming calls in cases where I have to ring to multiple agents and disconnect the call after one of them.

Right now I am doing something along the lines of::

Cutomer calls :: call is sent to webhook -> Get list of all active agents and send the twiml


<?xml version="1.0" encoding="UTF-8"?>
<Response>
   <Dial>
     <Client>
        <Identity>jane</Identity>
        <Parameter name="FirstName" value ="Jane"/>
        <Parameter name="LastName" value ="Doe" />
      </Client>
     <Client>
        <IdentityHarry</Identity>
        <Parameter name="FirstName" value ="Jane"/>
        <Parameter name="LastName" value ="Doe" />
      </Client>
    </Dial>
</Response>

This way I can ring both ( or more) clients and call drops after the first agent answers.

How I achieve something like this with conference?
What I want is:: ->

Customer calls:: call is captured into webhook =>
 customer is dropped into the conference call with some music.
- Dial to clients :: (harry, jane) and connect them to the call.

Is there a way I can do this with via rest api to conference participants api?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失与倦" 2025-01-19 06:19:37

是的,您可以使用 REST API 来完成此操作。您的 webhook 应响应:

<Response>
  <Dial>
    <Conference waitUrl="YOUR_HOLDING_MUSIC">YOUR_ROOM_NAME</Conference>
  </Dial>
</Response>

使用 REST API 的唯一问题是它的执行方式与多个 元素不同。也就是说,当有人接听电话时,您必须取消所有其他呼叫。为此,您需要存储调用 API 时创建的呼叫 SID,使用状态回调来了解参与者何时连接,然后在收到第一个状态回调时取消其他调用。因此,类似这样的操作可以拨打电话并获取呼叫 sid:

def call_conference(client_name):
    client = Client(account_sid, auth_token)
    participant = client.conferences('YOUR_ROOM_NAME') \
                    .participants \
                    .create(
                         status_callback='https://myapp.com/events',
                         status_callback_event=['answered'],
                         from_='YOUR_TWILIO_NUMBER',
                         to='client:' + client_name
                     )
    return participant.sid

clients = ["jane", "harry"]
participants = map(call_conference, clients)

然后,当状态回调事件触发时,从您拥有的 sids 列表中过滤呼叫 sid,并且 取消其他呼叫

Yes, you can do this with the REST API. Your webhook should respond with:

<Response>
  <Dial>
    <Conference waitUrl="YOUR_HOLDING_MUSIC">YOUR_ROOM_NAME</Conference>
  </Dial>
</Response>

The only thing about using the REST API is that it doesn't perform the same as multiple <Client> elements. That is, when someone answers the phone, you have to cancel all the other calls. To do this, you will need to store the call SIDs that are created when you call the API, use status callbacks to know when a participant has connected, and then when you get the first status callback, cancel the other calls. So, something like this to make the calls and get the call sids:

def call_conference(client_name):
    client = Client(account_sid, auth_token)
    participant = client.conferences('YOUR_ROOM_NAME') \
                    .participants \
                    .create(
                         status_callback='https://myapp.com/events',
                         status_callback_event=['answered'],
                         from_='YOUR_TWILIO_NUMBER',
                         to='client:' + client_name
                     )
    return participant.sid

clients = ["jane", "harry"]
participants = map(call_conference, clients)

Then, when that status callback event fires, filter the call sid from the list of sids you have and cancel the other calls.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文