Capture X-Header Incoming Call and run Script

I’m trying to capture a “X-Header” from a incoming SIP INVITE (from an extension) to my VitalPBX, and then call to a external script (a php script), and pass the captured header?
Is possible to do this in VitalPBX?.
I was tryingto figure it first how to capture the X-Header and then in which part of the daialplan call to the external script with the parameter x_Header…


You can use the custom context to capture the header and then redirect the call to the desired destination!

Thanks for the tip.
Indeed i was looking this module.
Could you help me a little bit more in depth on how to achieve what i’m looking for?.
As i have researched… first i need to create a new conf file inside /etc/asterisk/vitalpbx/
like this : “extensions__90-custom.conf”
I have created somthing like this:

exten => s,1,Noop(Entering x-location-header-extract)
exten => s,n,Goto(${ARG1},${ARG2},${ARG3})

Then what else do i need to set in order to run this macro for all INCOMING calls from my extensions?


Do you have the custom context add-on installed? You’ll need to create a custom context object that points to this context.

Thanks for the help.
I finally figure it out…these are the steps i follow in order to have what i want… maybe is userful for other users.
I installed the module “Custom Context”. (on the webgui go to addons)
Then i created in /etc/asterisk/vitalpbx/ a file called “extensions__90-custom.conf”
Like this:

exten => s,1,Noop(Entering x-location-header-extract)
same => n,Set(xlocation=${PJSIP_HEADER(read,X-Location)})
same => n,Set(gps=${CUT(xlocation,:,2)})
same => n,Set(gps=${CUT(gps,\;,1)})
same => n,Set(origen=${CALLERID(num)})
same => n,System(/usr/bin/php /var/lib/asterisk/agi-bin/capture.php ${gps} ${origen})
same => n,Verbose(${gps})
same => n,Goto(${ARG1},${ARG2},${ARG3})

Then i have created a “Custom Application” like this:

Finally i have created a Custom Context Like this:

So whenever an extension calls to “9224053XXX”… match the “Custom App” then… is redirected to the “Custom Context”… and finally sent to the Outbound Route : LOCAL.

Then in the “capture.php” i extract the x-location header as needed…
Is there any recommendation here to have in mind???
I was thinking something to match exactly the called number? i need to set something else in the “Extension” field?


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