How to Add SIP Diversion Header Into Outbound Calls

I have my server runs FreePBX version 16 with Asterisk version 18.20.2
I need to add sip Diversion header when an extension call forward is turned on. I have set the “Generate Diversion Headers” under Advanced Settings but I still don’t see the PBX include the diversion header in the sip invite. I have checked the “extensions_additional.conf” config file and confirmed that the below settings exist for the diversion header, but still the server doesn’t add diversion header. I read all the related topics for adding diversion headers but none of them help in my case, would you please direct me how to do this? Thanks.

[sub-diversion-header]
include =>; sub-diversion-header-custom
exten =>; s,1,Set(DIVERSION_REASON=${IF($[${LEN(${DIVERSION_REASON})}=0]?no-answer:${DIVERSION_REASON})})
exten =>; s,n,Gosub(func-set-sipheader,s,1(Diversion,<tel:${FROM_DID}>;;reason=${DIVERSION_REASON};screen=no;privacy=off))
exten =>; s,n,Return()
exten =>; s,n,Set(DIVERSION_REASON=${IF($[${LEN(${DIVERSION_REASON})}=0]?no-answer:${DIVERSION_REASON})})
exten =>; s,n,Gosub(func-set-sipheader,s,1(Diversion,<tel:${FROM_DID}>;;reason=${DIVERSION_REASON};screen=no;privacy=off))
exten =>; s,n,Return()

;–== end of [sub-diversion-header] ==–;

Thanks,
Robert

Please mark up logs as preformatted text:

[sub-diversion-header]
include =>; sub-diversion-header-custom
exten =>; s,1,Set(DIVERSION_REASON=${IF($[${LEN(${DIVERSION_REASON})}=0]?no-answer:${DIVERSION_REASON})})
exten =>; s,n,Gosub(func-set-sipheader,s,1(Diversion,&lt;tel:${FROM_DID}>;\;reason=${DIVERSION_REASON}\;screen=no\;privacy=off))
exten =>; s,n,Return()
exten =>; s,n,Set(DIVERSION_REASON=${IF($[${LEN(${DIVERSION_REASON})}=0]?no-answer:${DIVERSION_REASON})})
exten =>; s,n,Gosub(func-set-sipheader,s,1(Diversion,&lt;tel:${FROM_DID}>;\;reason=${DIVERSION_REASON}\;screen=no\;privacy=off))
exten =>; s,n,Return()

;--== end of [sub-diversion-header] ==--;

Can you please tell me how?

Select the text and click on </>.

Or precede and follow a block of text with three back ticks.

Or surround inline text with single back ticks.

The menu option just adds one of the other two.

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