To extract the call-id, I did not find any example, but the call parameter is:
sip_call_id
So it should be simple to extract. See Routing Script Parameter Mapping - TB Wiki
If needed, TelcoBridges can do a script like this with professional services.