The call flow is:

External Number -> internal extension -> Forwarding to external number.

When I use loopback channel, the outbound CDR leg is generated with 2 second call as it is known. I can do a post call processing in database and

Check if is_loopback=1, match inbound leg by bridge_uuid and calculate the total call length.

I’m trying to avoid post call processing…

For that, I tried using sip_looped_call in public context. Works well if you change the deflect data to ${sip_to_uri} from the default ${destination_number}. However, all custom variables are lost and first leg is written with BLIND_TRANSFER hangup cause. Billsec is 0 which make sense. If I need to bill on inbound leg, what should I do in this case?

Any suggestions are appreciated.