In my project I am using sip.js to connect to asterisk via websocket and asterisk is configured to use chan_pjsip driver. The goal is to create a call log entry when the user accepts an invitation and update the call log entry with the help of a dialplan hook at the end of the call.
The problem I am currently facing is that the Call-ID received by the sip.js client does not match the Call-ID that I read using PJSIP_HEADER(read,Call-ID)
is there any solution to send a unique id to the sip.js client that can be accessed at the end of the call on the asterisk side ?
I know that is a FreePBX dialplan macro from perusing the FreePBX forum when I’m categorizing things and passing through there.
You don’t choose the channel at the end of the call. That hook is presumably setting it on the outgoing channel, if it follows the Asterisk meaning of what pre-dial is, so when the outgoing channel hangs up the logic would be executed.
If you want it to occur on the incoming channel then the hangup_handler_push would need to be executed on the incoming channel instead.
What you can do - e.g. if you want to do correlation - is to read the CallId value of the caller and set that into an X-Header on the outgoing call leg. We do that to enable correlation in HOMER between incoming and outgoing call legs. The best place to do that would be in a pre-dial handler.