Diversion Header - Call Forward No Answer/Unavailable


I have problems with “Call Forward No Answer/Unavailable” feature on SIP phones with FreePBX-2.8.1( / Asterisk PBX I can receive incoming (external) calls via SIP trunk without any problems. I can also place outgoing calls via SIP trunk without any problems. I have problem with redirecting (forward) calls to an external phone number (mobile number) if the called internal extension is not picking up (Call Forward No Answer / Unavailable).

My SIP provider requires Diversion Header for “Call Forward No Answer/Unavailable” feature (security reason).

So far I’ve setup Diversion Header in extensions_custom.conf:
exten => s,1,NoOp(Adding P-Asserted-Identity for Trunk Pilot User)
exten => s,n,SipAddHeader(Diversion: sip:[email protected];reason=unconditional)
exten => s,n(done),MacroExit()

This Diversion header is far from optimal, but it’s a start. I have two issues with this Header:

a) when incoming call is forwarded with “Call Forward No Answer/Unavailable” to external number (ex. mobile number) then PBX places two calls to external number. First call lasts just 2 seconds - mobile phone rings once. Then PBX disconects the call and places new one tothe external number.
I don’t understand why this is happening.

b) all outgoing calls have Outgoing CallerID from Trunk CID. (Trunk Outbound Caller ID and Route CID are not overiding extension Caller ID).
I want that all Outgoing call have Extension Caller ID.

If I disable this macro [macro-dialout-trunk-predial-hook] - then all outgoing calls shows extension CallerID - which is OK.
And also calls are not forwarded to external number - “Call Forward No Answer/Unavailable” feature.

Can somebody help me with this Diversion Header?