Hello, we have two different phone numbers from two companies with local SIP providers in Turkey (NetGSM And Verimor) . We use Retell to forward these numbers. However, we’re having a problem. After calling number A and hanging up, when the user calls number B, the phone just rings and then hangs up with the unreachable error message provided by the provider. I think the problem might be caused by Retell, because it still states that the number calling has a call, even though it doesn’t. Could this be the reason?
We also use Python to retrieve information such as the agent-id of the phone number, the user’s name, and meeting information :
def transfer_to_retell(self):
"""Ana fonksiyon - aramayı Retell AI'ya yönlendirir"""
# Gelen arama bilgilerini al
caller_id = self.agi_env.get('agi_callerid', 'Unknown')
called_number = self.agi_env.get('agi_dnid', self.agi_env.get('agi_extension', self.default_phone))
self.log(f"Gelen arama: {caller_id} -> {called_number}")
# Retell AI'ya kaydol ve SIP URI al
sip_uri = self.register_call_with_retell(caller_id, called_number)
if sip_uri:
# Settings'den dial timeout'u al
settings = self.agent_config.get('settings', {}) if self.agent_config else {}
dial_timeout = settings.get('dial_timeout', 30)
# Retell'e yönlendir - Load balancing ile
endpoint = get_next_endpoint()
dial_string = f"PJSIP/{endpoint}/{sip_uri}"
self.log(f"Retell'e yonlendiriliyor: {dial_string} (Endpoint: {endpoint})")
# Aramayı yönlendir - AGI EXEC komutu kullan
result = self.agi_command(f'EXEC Dial "{dial_string},{dial_timeout},r"')
self.log(f"Dial sonucu: {result}")
else:
self.log("Retell SIP URI alinamadigi icin arama sonlandiriliyor")
self.agi_command('EXEC Playback "im-sorry"')
self.agi_command('EXEC Hangup')
extensions.conf :
[general]
static=yes
writeprotect=no
[from-netgsm]
; NetGSM 's' extension
exten => s,1,NoOp(Incoming call to s: ${CALLERID(all)})
exten => s,n,AGI(/usr/local/bin/retell_integration.py)
exten => s,n,Hangup()
; Ana numara
exten => TEL_NO_A,1,NoOp(Call to main number: ${CALLERID(all)})
exten => TEL_NO_A,n,AGI(/usr/local/bin/retell_integration.py)
exten => TEL_NO_A,n,Hangup()
; Diğer numaralar
exten => _X.,1,NoOp(Incoming call from NetGSM: ${CALLERID(all)} to ${EXTEN})
exten => _X.,n,AGI(/usr/local/bin/retell_integration.py)
exten => _X.,n,Hangup()
[from-verimor]
; Verimor gelen aramalar - 90TEL_NO_B
exten => s,1,NoOp(Verimor: ${CALLERID(all)})
exten => s,n,AGI(/usr/local/bin/retell_integration.py)
exten => s,n,Hangup()
exten => _X.,1,Goto(s,1)
exten => 90TEL_NO_B,1,Goto(s,1)
exten => TEL_NO_B,1,Goto(s,1)
[from-retell]
; Retell AI'dan gelen çağrılar için
exten => _X.,1,NoOp(Retell AI call: ${CALLERID(all)})
exten => _X.,n,Answer()
exten => _X.,n,Wait(1)
exten => _X.,n,Hangup()
[default]
; Test
exten => 100,1,Answer()
exten => 100,n,Playback(hello-world)
exten => 100,n,Hangup()
pjsip.conf - I tried the method of selecting multiple endpoints using the random module in Python and then registering the call, but I was unsuccessful. The result is still the same :
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
[netgsm]
type=endpoint
context=from-netgsm
disallow=all
allow=ulaw
allow=alaw
direct_media=no
[netgsm-identify]
type=identify
endpoint=netgsm
match=sip.netgsm.com.tr
; Verimor - Yeni
[verimor]
type=endpoint
context=from-verimor
disallow=all
allow=ulaw
allow=alaw
allow=g729
direct_media=no
[verimor-identify]
type=identify
endpoint=verimor
match=sip.verimor.com.tr
match=sip2.verimor.com.tr
; Retell AI Endpoints
[retell-generic-1]
type=endpoint
context=from-retell
disallow=all
allow=ulaw
allow=alaw
direct_media=no
[retell-generic-2]
type=endpoint
context=from-retell
disallow=all
allow=ulaw
allow=alaw
direct_media=no
[retell-generic-3]
type=endpoint
context=from-retell
disallow=all
allow=ulaw
allow=alaw
direct_media=no
[retell-generic-4]
type=endpoint
context=from-retell
disallow=all
allow=ulaw
allow=alaw
direct_media=no
[retell-generic-5]
type=endpoint
context=from-retell
disallow=all
allow=ulaw
allow=alaw
direct_media=no