Наконец-то я нашел решение!Я делюсь этим ниже.Я надеюсь, что это будет полезно для кого-то ... Это не так интуитивно понятно, но это работает.Я выполнил следующие действия:
- Создайте КОНФЕРЕНЦИЮ и присоединитесь к Клиенту (установите startConferenceOnEnter и EndConferenceOnExit в в значение ).
- Создайте CALL и подключите его к URL.В этом веб-крюке создайте TwiML, чтобы присоединить Agent1 к конференции, что позволит hangupOnStar позднее присоединиться к Agent2 (в другом веб-крюке) и установит endConferenceOnExit в false , чтобы избежатьзавершение вызова клиента.
- Создайте еще один веб-крюк, чтобы повторно присоединиться к Agent1 после нажатия звездочки (*) и позволить 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)