[英]How to make Twilio Queue Automation Forward
有人可以告訴我:如何接聽呼叫者,從排隊到撥號(轉發)。 在一個應用程序中,自動化這個???
我有類似的東西,它不會工作:
<Say>hello</Say>
<Enqueue waitUrl="https://brass-dragonfly-1957.twil.io/assets/poczekalnia.xml">support</Enqueue>
<Dial url="/ivr/agent/screencall">
+000000000
<Queue>support</Queue>
</Dial>
<Redirect>/ivr/welcome/</Redirect>
</Response>
在 python 看起來像這樣:
twiml_response.say('hello')
twiml_response.enqueue('support', wait_url='https://brass-dragonfly-1957.twil.io/assets/poczekalnia.xml')
twiml_response.dial('+000000000', url=reverse('ivr:agents_screencall')).queue('support')
看起來您正試圖在一個 TwiML 響應中為您的呼叫者和代理執行操作,但這是行不通的。
當您<Enqueue>
調用者時,在您使用<Leave>
使調用者出隊之前,不會執行任何后續 TwiML。
看起來您想撥打座席,讓他們篩選呼叫,然后將他們連接到隊列中的呼叫者。 為此,您首先要使用 REST API 創建對代理的調用。 通過該調用,您將提供一個 URL,當該代理連接時將請求該 URL。 在對 URL 的響應中,您應該向他們說出消息,然后是<Dial>
<Queue>
。 像這樣的東西:
import os
from twilio.rest import Client
account_sid = os.environ['TWILIO_ACCOUNT_SID']
auth_token = os.environ['TWILIO_AUTH_TOKEN']
client = Client(account_sid, auth_token)
def call(request):
twiml_response = VoiceResponse()
twiml_response.say('hello')
twiml_response.enqueue('support', wait_url='https://brass-dragonfly-1957.twil.io/assets/poczekalnia.xml')
call = client.calls.create(
url = '/agent'.
to = agent_phone_number,
from = your_twilio_number
)
return HttpResponse(twiml_response, content_type='text/xml')
然后,作為對/agent
端點的 webhook 的響應,您應該返回您的響應以進行篩選,可能如下所示:
def agent(request):
twiml_response = VoiceResponse()
gather = Gather(action='/agent_queue', method='POST', numDigits=1)
gather.say('You are receiving an incoming call, press 1 to accept')
twiml_response.append(gather)
return HttpResponse(twiml_response, content_type='text/xml')
最后在/agent_queue
中確定篩選呼叫的結果,如果代理接受,則將它們連接到隊列。
def agent_queue(request):
twiml_response = VoiceResponse()
digits = request.POST.get("Digits", "")
if digits == "1":
dial = Dial()
dial.queue('support')
twiml_response.append(dial)
else:
twiml_response.hangup()
return HttpResponse(twiml_response, content_type='text/xml')
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.