Integrating Custom SIP trunking
# support
j
Hello there, I am trying to implement calls from my asterisk provider PBX to Vapi I have a (Free Vapi SIP) URI defined with an assistant, my PBX calls sip:{my-assistant}@sip.vapi.ai:5060 and I am currently getting this response (not using PJSIP). I have whitelisted VAPI IP's and maybe I am facing this issue because I created and deleted the (phone-number) multiple times to debug. https://cdn.discordapp.com/attachments/1374738312610451486/1374738313101054023/Untitled1.png?ex=682f2453&is=682dd2d3&hm=c6dd3898766d452d3ad5eeb983a06dca0b13e7f6960d32d335ee02b09bedad47&
This error was happening because I didn't had an assistant assigned to it and after assigning it this is what happens (sending screenshot)
v
Suggestion: Create a new, unique SIP phone number in Vapi and assign your assistant to it. Then, update your PBX to call the new SIP URI. For example:
Copy code
json
{
  "provider": "vapi",
  "sipUri": "sip:your_unique_username@sip.vapi.ai",
  "assistantId": "your_assistant_id"
}
Update your PBX to use
sip:your_unique_username@sip.vapi.ai:5060
as the destination. This should avoid conflicts from previously deleted numbers and resolve the 503 error. If the issue persists, contact Vapi support to clear any stale registrations. Source: - [Vapi SIP Integration Documentation](https://docs.vapi.ai/advanced/sip)
It looks like the "503 Service Unavailable" error with the reason "Multiple accounts are attempting to default route this carrier" may be due to multiple Vapi accounts or phone numbers being associated with the same SIP trunk or carrier, especially after creating and deleting phone numbers multiple times. To help narrow down the issue: Can you confirm that the current phone number and SIP trunk credential you are using are uniquely associated with your account, and that no other Vapi accounts or deleted numbers are still linked to the same carrier? This will help determine if there are any lingering associations causing the routing conflict. If needed, you may want to review your active phone numbers and credentials in the Vapi dashboard and ensure there are no duplicates or overlaps. Let me know what you find! Sources: - [Vapi SIP Trunking Documentation](https://docs.vapi.ai/advanced/sip/sip-trunk) - [Vapi API Reference: Phone Numbers](https://docs.vapi.ai/api-reference/phone-numbers/list)
Suggestion: Create a new, unique SIP phone number in Vapi and assign your assistant to it. Then, update your PBX to call the new SIP URI. For example:
Copy code
json
{
  "provider": "vapi",
  "sipUri": "sip:your_unique_username@sip.vapi.ai",
  "assistantId": "your_assistant_id"
}
Update your PBX to use
sip:your_unique_username@sip.vapi.ai:5060
as the destination. This should avoid conflicts from previously deleted numbers and resolve the 503 error. If the issue persists, contact Vapi support to clear any stale registrations. Source: - [Vapi SIP Integration Documentation](https://docs.vapi.ai/advanced/sip)
It looks like the "503 Service Unavailable" error with the reason "Multiple accounts are attempting to default route this carrier" may be due to multiple Vapi accounts or phone numbers being associated with the same SIP trunk or carrier, especially after creating and deleting phone numbers multiple times. To help narrow down the issue: Can you confirm that the current phone number and SIP trunk credential you are using are uniquely associated with your account, and that no other Vapi accounts or deleted numbers are still linked to the same carrier? This will help determine if there are any lingering associations causing the routing conflict. If needed, you may want to review your active phone numbers and credentials in the Vapi dashboard and ensure there are no duplicates or overlaps. Let me know what you find! Sources: - [Vapi SIP Trunking Documentation](https://docs.vapi.ai/advanced/sip/sip-trunk) - [Vapi API Reference: Phone Numbers](https://docs.vapi.ai/api-reference/phone-numbers/list)
Suggestion: To resolve the "503 Service Unavailable" with the reason "Multiple accounts are attempting to default route this carrier," ensure that the SIP URI or phone number you are using is not associated with multiple Vapi accounts or resources. - Action: Delete any duplicate or unused phone numbers/SIP URIs from all Vapi accounts, then create a new, unique phone number in your intended account and update your PBX to use the new SIP URI. If the issue persists, wait a short period before reusing the same SIP URI, or contact Vapi support for cleanup assistance. [Reference: Vapi SIP documentation](https://docs.vapi.ai/advanced/sip) Sources: - [Vapi SIP documentation](https://docs.vapi.ai/advanced/sip) - [Vapi SIP trunking guide](https://docs.vapi.ai/advanced/sip/sip-trunk)
Suggestion: To resolve the "503 Service Unavailable" with the reason "Multiple accounts are attempting to default route this carrier," ensure that the SIP URI or phone number you are using is not associated with multiple Vapi accounts or resources. - Action: Delete any duplicate or unused phone numbers/SIP URIs from all Vapi accounts, then create a new, unique phone number in your intended account and update your PBX to use the new SIP URI. If the issue persists, wait a short period before reusing the same SIP URI, or contact Vapi support for cleanup assistance. [Reference: Vapi SIP documentation](https://docs.vapi.ai/advanced/sip) Sources: - [Vapi SIP documentation](https://docs.vapi.ai/advanced/sip) - [Vapi SIP trunking guide](https://docs.vapi.ai/advanced/sip/sip-trunk)
j
It got fixed by doing what you said, I had the route in my account for testing and maybe that was causing the issue however now there's a locution saying Callnumber not found https://cdn.discordapp.com/attachments/1374738312610451486/1374745054517792879/image1.png?ex=682f2a9a&is=682dd91a&hm=b8930b50d7040ea9367220b4f24e8608f7897590f66ad4d12ab4bcc192f131e8&
v
Message marked as helpful by @Jonirulah! 🎉
Message marked as helpful by @Jonirulah! 🎉
Message marked as helpful by @Jonirulah! 🎉
Message marked as helpful by @Jonirulah! 🎉
Message marked as helpful by @Jonirulah! 🎉
j
This is the INVITE to VAPI SIP, here's when the "Call number not found" locution starts playing, Im contacting it with inbound sip uri (sip:{myidentifier}@sip.vapi.ai) https://cdn.discordapp.com/attachments/1374738312610451486/1374753993380860016/image3.png?ex=682f32ed&is=682de16d&hm=adea865160ef7b5f5fa8775f8466e695525fc16b09cf464f315e7a093a0864b3&
@Vapi Support Bot any idea?
v
Suggestion: Please verify that the SIP URI you are dialing (e.g.,
sip:your_unique_user_name@sip.vapi.ai
) exactly matches the
sipUri
of an active SIP phone number in your Vapi dashboard, and that it is assigned to an assistant. For example, your phone number resource should look like:
Copy code
json
{
  "provider": "vapi",
  "sipUri": "sip:your_unique_user_name@sip.vapi.ai",
  "assistantId": "your_assistant_id"
}
If the SIP URI or identifier does not match, or the number is not active, you will get the "Call number not found" message. Update your PBX to use the correct SIP URI and try again. [Reference: Vapi SIP documentation](https://docs.vapi.ai/advanced/sip) Source: - [Vapi SIP documentation](https://docs.vapi.ai/advanced/sip)
To help resolve the "Call number not found" issue: Can you confirm the exact SIP URI you are dialing, and verify that this SIP URI matches an active SIP phone number resource in your Vapi dashboard (including the username before
@sip.vapi.ai
)? This will help determine if the call is being routed to a valid endpoint as required by the [Vapi SIP documentation](https://docs.vapi.ai/advanced/sip). Source: - [Vapi SIP documentation](https://docs.vapi.ai/advanced/sip)
j
it's sip:ocm-salroc-pruebas-ocm@sip.vapi.ai @Vapi Support Bot
v
Action: Please double-check in your Vapi dashboard that you have a SIP phone number resource with:
Copy code
json
{
  "provider": "vapi",
  "sipUri": "sip:ocm-salroc-pruebas-ocm@sip.vapi.ai",
  "assistantId": "your_assistant_id"
}
Make sure the
sipUri
matches exactly and the number is active and assigned to an assistant. If not, update or recreate the phone number as needed. [See Vapi SIP documentation for details.](https://docs.vapi.ai/advanced/sip) Source: - [Vapi SIP documentation](https://docs.vapi.ai/advanced/sip)
Action: Please double-check that your SIP phone number resource in Vapi matches the following format, with your exact SIP URI and an assigned assistant:
Copy code
json
{
  "provider": "vapi",
  "sipUri": "sip:ocm-salroc-pruebas-ocm@sip.vapi.ai",
  "assistantId": "your_assistant_id"
}
If the SIP URI or assistant assignment does not match, you will get the "Call number not found" message. Update your Vapi dashboard and PBX config as needed, then try again. [Reference: Vapi SIP documentation](https://docs.vapi.ai/advanced/sip) Source: - [Vapi SIP documentation](https://docs.vapi.ai/advanced/sip)
j
having a CNAME in the domain will affect this @Vapi Support Bot ?
s
Hi @Jonirulah can you share the PCAP file and your phone number ID?
j
Hi @Shubham Bajaj thanks for answering, I think i have figured out what was happening on my end, I will be able to test it tomorrow since I've got some information but seems like it was our fault, our PBX provider had issues resolving sip.vapi.ai so I decided to do a CNAME from our domain to sip.vapi.ai in order for them to be able to connect to the SIP, and with those changes they have been able to connect to the SIP server, however it seems like it's interfering with the URI and the system is not detecting the phoneId, however I've tried with sip.vapi.ai on my test server and it seems that's the issue, however i'll be able to confirm it tomorrow 🙂
Even tho I have no audio on my test server and the call automatically ends atleast I see callIds on the dashboard which I wasn't seeing before
p
sg.
j
@Vapi Support Bot the sip server is returning 401 unauthorized however i added the SIP trunk in the SIP Trunk Credentials, any idea? https://cdn.discordapp.com/attachments/1374738312610451486/1375194151695421612/unnamed-1.png?ex=6830ccdb&is=682f7b5b&hm=3de7ab8a88a520a4ec123bc52bbc84560c514d8c0b384d48cb0e0e125bbf471f&
v
Thanks for the detailed info! To help pinpoint the 401 Unauthorized issue: Can you confirm that the SIP username and password configured in your PBX exactly match the credentials set in your Vapi SIP Trunk (and that you are using
sip.vapi.ai
as the domain, not your CNAME)? This will help rule out credential mismatches or domain-related authentication problems. [Reference: Vapi SIP Trunk documentation](https://docs.vapi.ai/advanced/sip/sip-trunk) Source: - [Vapi SIP documentation](https://docs.vapi.ai/advanced/sip/sip-trunk)
A "401 Unauthorized" error usually means your PBX is sending SIP credentials that don't match what Vapi expects. Please double-check that the SIP username and password in your PBX trunk settings exactly match the
authUsername
and
authPassword
you entered when creating your Vapi SIP trunk credential. For example, your PBX config should look like:
Copy code
ini
username=YOUR_SIP_USERNAME
password=YOUR_SIP_PASSWORD
Update these values to match your Vapi dashboard, then try the call again. [See Vapi SIP trunking docs for details.](https://docs.vapi.ai/advanced/sip/sip-trunk) Source: - [Vapi SIP trunking documentation](https://docs.vapi.ai/advanced/sip/sip-trunk)
j
@Vapi Support Bot im using sip.vapi.ai as the domain yes, here's a pcap, in this case is from my own dev server where it auto-retries infinitely and after the first try there's a success https://cdn.discordapp.com/attachments/1374738312610451486/1375195112065470524/sip_salroc.pcap?ex=6830cdc0&is=682f7c40&hm=99621abc600006a67940e0e3f407961a00be89accf885b67e6d8cfffd2205830&
looks like when there's the first forbidden there's another retry with the Authorization Digest added Authorization: Digest username="anon", realm="sip.vapi.ai", nonce="174794329948500", uri="sip:ocm-salroc-pruebas-ocm@sip.vapi.ai;transport=udp", 19:48:19.549413 │ 100 Trying │ │ response="f8e7e907188775b3632edfc19a2ef6af", cnonce="4b11ac7709c10f1a", qop=auth, nc=00000001
that's on my dev server, looks like the PBX doesn't do the auto-retry and then the calls ends after the first forbidden
@Vapi Support Bot do you have any asterisk configuration sample?
s
@Vapi Support Bot do you have any asterisk configuration sample?
j
Solved, thanks (had to put a dummy user)
p
sg.