Different exit codes? Issue with caller ID

So I have multiple sip trunks set up in my pjsip.conf file. They all have the same outbound rules because I want to be able to call real phone numbers. This causes the caller ID to be the same for everyone I call, even though I have different DIDs set up. The person over at voip.ms told me that this could be because it doesn’t know which trunk to use when placing a call. Does anyone know a solution around this. He said I could use different exit codes but I’m not sure what those are.

Any help would be appreciated,

Thank you.

Hello, does anyone have any idea how to go about this?

I tried removing the first SIP Trunk I made, since it kept using the DID attached to that trunk even if I tried using another one. Now when I try placing an outbound call, it tells me that that SIP trunk endpoint was not found. Why does it not just try to use another trunk, I have many. Can anyone please help?

Are you using FreePBX, or are you using normal Asterisk? If normal Asterisk then it’s completely up to you to configure the dialplan to behave according to how you want including trying another trunk. I think what voip.ms meant is having a prefix for dialing that chooses the trunk, ie: *1 uses first trunk, *2 second, and so on.

I am using normal Asterisk, version 16. So for the prefix, does that mean before dialing I’d have to dial a certain number before to indicate the trunk I want to use? Is there a way to choose the trunk without that? I’m asking cause we’re trying to set up an automated call drop system. I already wrote all the code in java so that it does what it wants when we get a call drop request through our website. Is there anyway to link a certain trunk to a certain context? If a prefix is the only way then I would have to change my code to add a certain prefix given who is sending out the call drop, and I’d prefer a different way. However, if that is the only way then of course I’d have to take it. Thank you for your reply.

You can have separate contexts which each dial out a specific trunk. Which context to use and when, is up to you.

Yes I have already created seperate contexts for all of our clients, how would I go about linking those contexts to a specific trunk?

There is no “linking” really. You write dialplan instructions which dial out a specific trunk when a number is dialed in the context.

Sorry, that is what I meant. Is there a wiki page that’ll show me how to do that in the dialplan or anywhere that would direct me on how to do it?

Thank you!

The basics are on asteriskdocs.org[1]. The basic PBX sample also has an example[2]. If you’re already able to call out then your dialplan already has some too.

[1] Building an Interactive Dialplan
[2] asterisk/extensions.conf at master · asterisk/asterisk · GitHub

; Make sure to include inbound prior to outbound because the _NXXNXXXXXX handler will match the incoming call and create a loop
include => voipms-inbound-client
include => voipms-outbound-client

exten => _1NXXNXXXXXX,n,Dial(PJSIP/{EXTEN}@voipms,100,U(sub-announcement-client) exten => _1NXXNXXXXXX,n,Hangup() exten => _NXXNXXXXXX,n,Dial(PJSIP/{EXTEN}@voipms,100,U(sub-announcement-client))
exten => _NXXNXXXXXX,n,Hangup()
exten => _011.,1,Dial(PJSIP/{EXTEN}@voipms,100,U(sub-announcement-client)) exten => _011.,n,Hangup() exten => _00.,1,Dial(PJSIP/{EXTEN}@voipms,100,U(sub-announcement-client))
exten => _00.,n,Hangup()

;exten => 8003333222,1,Answer() ;your DID

exten => 4379718586,1,Answer()
same => n,Wait(1)
same => n,Playback(client)

exten = s,1,NoOp()
same = n,Wait(1)
same = n,Playback(client)
same = n,Return()

This is what all my contexts basically look like right now, with “client” replaced with the name of the client. Where in this would it decide the trunk to use?

The Dial application places an outgoing call. The endpoint is specified as part of the Dial string given to it.

Oh okay, so where it says @voipms, got it thank you! Now I am facing a different issue, so I changed it to @client, and now the CLI tells me that the extension i am calling does not exist in that context. Shouldn’t it accept any phone number given the way my context is written?

It would only accept international numbers. Your “_1NXXNXXXXXX” extension has no priority 1 which is required.

I would highly suggest spending time reading asteriskdocs.org dialplan stuff and fundamentals and experimenting, it is a core aspect of how Asterisk works and without a solid grasp of it you won’t know what is truly going on and if you want to make further changes you’ll be stuck again.

If other people would like to participate they may, but I’m taking a break from this thread for now.

Okay, thank you for all your help. It is very much appreciated. If anyone else would like to help, what I then don’t understand is, why does the first context I created call any number, even though it has the same configurtation as this one?

Okay! I got it, thanks for all your help, after you told me the part after @ in the dialplan was the one that chose the endpoint, when I changed stuff back I had just made a stupid mistake. It works now. I will look into going through the website you reccommended. Right now I am just trying to get this set up as soon as possible. I will certainly look into understanding everything better once that is done. Thank you.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.