0

I am working on my first Twilio project.

The target:

Using just phones (without any kind of UI for agents), I would like to perform this flow into a conference:

  1. Customer calls and (after a selection menu) a conference is started.
  2. Agent1 joins the conference and chats with Customer to get some basic info (Agent1 is called by Twilio; it is an outbound call).
  3. Agent1 makes something to join Agent2 to the conference.
  4. A 3-party conference is performed (customer, agent1 and agent2).

The issue:

Remind that I am not using any UI and, AFAIK, DTMF doesn't work into a conference. So, in order to get an input from conference, I am trying to use hangupOnStar as I read in multiple answers here in SO (like this one).

However, it works just for the initial caller (which seems to be the moderator by default), not for Agent1. I want Agent1 to moderate the conference, just to be able to join Agent2 (probably another outbound call) to the conference.

The question

Is it possible to set Agent1 as moderator into this conference? How?

Thanks in advance for your answers!

oz19
  • 1,616
  • 1
  • 17
  • 22

1 Answers1

0

Finally, I found a solution! I share it below. I hope this to be helpful for somebody... It's not that intuitive, but it works. I followed these steps:

  1. Create a CONFERENCE and join Customer (set startConferenceOnEnter and EndConferenceOnExit to false).
  2. Create a CALL and hook it to a URL. In that webhook create a TwiML to join Agent1 to conference, allowing hangupOnStar to later join Agent2 (in another webhook), and setting endConferenceOnExit to false, to avoid hanging up Customer's call.
  3. Create another webhook to re-join Agent1 after clicking star (*) and let Agent2 join the conference.

I am using Python with Flask framework. Here is the code:

@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)
oz19
  • 1,616
  • 1
  • 17
  • 22