One of our SIP trunk providers handles breakout of the tenant billing by use of a sip header on all outbound calls over a trunk.
I need to set X-Tenant to a value that matches a tenant id at the carrier.
A closed source, PBX I have used simply has that built in when you choose this SIP trunking provider in their system.
FreePBX has a hook in their dialplan that you can use like this.
[macro-dialout-trunk-predial-hook]
; Set x_tenant = to test.stl by default.
exten => s,n,Set(x_tenant=test.stl)
; Change it if the call is on a Cape, Jeff City, or Quincy outbound route.
exten => s,n,ExecIf($["${OUTBOUND_ROUTE_NAME:0:4}"=="Cape"]?Set(x_tenant=test.cape))
exten => s,n,ExecIf($["${OUTBOUND_ROUTE_NAME:0:9}"=="Jeff City"]?Set(x_tenant=test.jeffcity))
exten => s,n,ExecIf($["${OUTBOUND_ROUTE_NAME:0:6}"=="Quincy"]?Set(x_tenant=test.quincy))
exten => s,n,NoOp(Based on the outbound route name of ${OUTBOUND_ROUTE_NAME}, the X-Tenant is being set to ${x_tenant}.)
exten => s,n,GoSub(func-set-sipheader,s,1(X-Tenant,${x_tenant}))
exten => s,n(exit_macro),MacroExit()
With Thirdlane, I would like to make use of the "tag" field in the Tenant settings. It is also available on a per extension basis if I need a specific override it seems. My question is where in the dial plan is there a spot I can hook in to outbound calls and what is the syntax to add a sip header?
I looked through /etc/asterisk/scripts_db.include and did not see any obvious example of a place I could call in a customer include.
Adding a value in the trunk…
Adding a value in the trunk is not useful when I need the value to be different per tenant. Nothing in the guide shows how a variable could be used either.
I looked at the idea of a duplicate of the dial 1 trunk script, but could not determine how that would be useful to be used in the trunk setting.
If I clone this script, it…
If I clone this script, it there something I can add that would be visible once it gets to the trunk?Can the trunk header section even take a variable?
Hello Jared,
You can add SIP headers to outbound requests in the trunk configuration: https://www.thirdlane.com/docs/platform/trunks#trunk-dialing
Complex features can be accomplished by a custom dial scripts.