Twilio - 如何在会议中设置主持人?

Twilio - How can I set a moderator in a Conference?

我正在处理我的第一个 Twilio 项目。

目标:

只使用电话(没有任何类型的 UI 代理),我想在会议中执行此流程:

  1. 客户打电话,(在选择菜单后)会议开始。
  2. Agent1 加入会议并与Customer 聊天以获取一些基本信息(Agent1 由Twilio 呼叫;这是一个外呼)。
  3. Agent1 制作东西 以将 Agent2 加入会议。
  4. 进行3方会议(客户、座席1和座席2)。

问题:

请注意,我没有使用任何 UI,据我所知,DTMF 不适用于会议。因此,为了从会议中获得意见,我正在尝试使用 hangupOnStar,因为我在 SO 中阅读了多个答案(例如 )。

但是,它仅适用于初始呼叫者(默认情况下似乎是主持人),不适用于 Agent1。我希望 Agent1 主持会议,以便能够将 Agent2(可能是另一个出站呼叫)加入会议。

问题

是否可以将Agent1设置为会议主持人?怎么样?

提前感谢您的回答!

终于找到解决办法了!我在下面分享。我希望这对某些人有所帮助......它不是那么直观,但它确实有效。我遵循了这些步骤:

  1. 创建会议并加入客户(将 startConferenceOnEnterEndConferenceOnExit 设置为 false)。
  2. 创建一个 CALL 并将其连接到 URL。在该 webhook 中创建一个 TwiML 以将 Agent1 加入会议,允许 hangupOnStar 稍后加入 Agent2(在另一个 webhook 中),并将 endConferenceOnExit 设置为 false,避免挂断客户电话。
  3. 点击星标 (*) 后创建另一个到 re-join Agent1 的 webhook,让 Agent2 加入会议。

我正在使用 Python 和 Flask 框架。这是代码:

@app.route('/start_conference.html', methods=['GET', 'POST'])
def start_conference():
    agent1 = '+XXXXXXXXXXX' # Agent1's phone number
    agent2 = '+XXXXXXXXXXX' # Agent2's phone number
    confName = 'YourConferenceName'

    resp = VoiceResponse()
    dial = Dial()

    # Create a conference and join Customer
    dial.conference(
        confName,
        start_conference_on_enter=False,
        end_conference_on_exit=False,
        max_participants = 3 # Limits participants to 3
    )

    # Call to Agent1 and setup a webhook for this call with a TwiML 
to join to the conference as Moderator
    client.calls.create(
        from_=twilioPhoneNumber,
        to=agent1,
        url=ROOT_URL+'agent1_to_conference.html' # ROOT_URL is the url where app is being executed
    )
    resp.append(dial)

    return str(resp)


@app.route('/agent1_to_conference.html', methods=['GET', 'POST'])
def agent1_to_conference():
    resp = VoiceResponse()

    # Join Agent1 to the conference, allowing hangupOnStar 
functionality to join Agent2 later
    dial = Dial(
        action='join_agent2.html',
        method='POST',
        hangup_on_star=True,
    )
    dial.conference(
        confName,
        start_conference_on_enter=True,
        end_conference_on_exit=False # False, to avoid hanging up to Customer
    )
    resp.append(dial)
    return str(resp)


@app.route('/join_agent2.html', methods=['GET', 'POST'])
def join_agent2():
    resp = VoiceResponse()
    dial = Dial()

    # Re-join Agent1 (after clicking *)
    dial.conference(
        confName,
        start_conference_on_enter=True,
        end_conference_on_exit=True
    )
    resp.append(dial)

    # Join Agent2
    client.conferences(confName).participants.create(
        from_=twilioPhoneNumber,
        to=agent2
    )

    return str(resp)