Custom Inbound Route

My goal is:

  • Caller calls my inbound route
  • Call has a Diversion header added
  • Call is diverted to an 888 number

I made a custom destination that I point my inbound route to:

exten => s,1,Set(PJSIP_HEADER(add,Diversion)=sip:${FROM_DID}@mydomain:5060)
exten => s,n,Dial(PJSIP/8888888888@mydomain:5060)
129445	[2024-02-15 17:42:19] ERROR[4515] chan_pjsip.c: Unable to create PJSIP channel - endpoint 'mydomain:5060' was not found	
129446	[2024-02-15 17:42:19] NOTICE[31165][C-0000079c] app_dial.c: Unable to create channel of type 'PJSIP' (cause 3 - No route to destination)

Questions:

  1. I know I have the @ wrong on my dial what do I need to change it to so it will go to my outbound routes?
  2. Maybe @david55 will know but how can I amend my set diversion header to include: reason=unconditional;privacy=off

Thanks for the guidance.

Not only is the dial string wrong, unlike chan_sip, you need to add that header on the outgoing channel. Doing it how you have puts the header on the current channel. You need to use the b option (pre-dial) in the dial string to hit a gosub to add the header to the newly created channel.

Your dial string should be PJSIP/endpoint/sip:[email protected]:5060

Chan_pjsip requires an endpoint to do SIP URIs like that. Dialing PJSIP Channels - Asterisk Documentation

So a custom context that goes to DiversionRoute,s,1?

In extensions_custom.conf

[DiversionRoute]
exten => addheader,1,Set(PJSIP_HEADER(add,Diversion)=sip:${FROM_DID}@mydomain:5060)
exten => addheader,n,Return

exten => s,1,Dial(PJSIP/8888888888@mytrunk,b(outgoing-call^addheader^1))

  • Does that look right?

Questions:

  • How do I declare the trunk name that’s in FreePBX? Is it the trunk name in the GUI or is it the name of the context?
  • Is there a way to just use the outbound routes generically, so I don’t have to declare a trunk?
  • How do I include: reason=unconditional;privacy=off

You’re still missing an endpoint. Chan_pjsip requires two things that chan_sip does not in regards to “default trunking”. If you want to accept anonymous calling in chan_pjsip, you need a special anonymous endpoint. If you want to do pure SIP URI outbound dialing, there is a default outbound endpoint you can enable in the [global] section or you can use an existing endpoint to go through.

From the [global] section, not enabled by default. You can even set the endpoint to use.
;default_outbound_endpoint=default_outbound_endpoint

This:
exten => s,1,Dial(PJSIP/8888888888@mytrunk,b(outgoing-call^addheader^1))

Needs to be this, where *endpoint* is the name of the trunk endpoint to send calls out over.
exten => s,1,Dial(PJSIP/*endpoint*/sip:[email protected]:5060,300,b(outgoing-call^addheader^1))

You call on it by the name, which it the name you give it in the GUI. If you do asterisk -rx "pjsip show endpoints" you’ll see it listed there too with the endpoint name.

This is seeming to work when I change mytrunk to the actual trunk name in the GUI.

Where I am stuck now is the Diversion header

Looks like:
Diversion: sip:FROMDID@mydomain:5060

Need it to be:
Diversion: <sip:FROMDID@mydomain:5060>;privacy-off; screen-no;reason-unconditional;counter-1

Any guidance here?

Got it you need to delimit with a \ to add the options.

After all that it still doesn’t work.

Does anyone have any ideas on how to do what I am looking to do:

I have a DID, lets say 555.555.5555

When people call that DID, I dont want to take the call, instead I want to divert it to an 800 number I own, lets say 888.888.8888, using the FROM_DID as the calling party.

  1. 111.111.1111 calls my pbx at 555.555.5555
  2. The call is immediately diverted to 888.888.8888 looking like its coming from 555.555.5555
  3. 111.111.1111 is connected to 888.888.8888 to complete the call transaction, but 888.888.8888 behaves as though the call has come from 555.555.5555

What’s the best way to do that?

I suggest that you start out by doing “nothing special”, sending the Inbound Route to a Misc Destination that dials your toll free number, and setting in Advanced Settings, Generate Diversion Headers to Yes.

With luck, this might be adequate. If it’s not, make a copy of [sub-diversion-header] from /etc/asterisk/extensions_additional.conf, edit it as desired and put it in /etc/asterisk/extensions_override_freepbx.conf
then do
fwconsole reload
and test.

If the caller ID is wrong (other than 111.111.1111), that’s a separate issue unrelated to Diversion (trunk settings, provider requirements / restrictions, etc.)

1 Like

This looks way better than what I have been getting, I am getting unauthorized. So it might be a permissions issue with my carrier to use that ID. Thanks again!

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