sipvoipopensips

openSIPS setup an onreply route if the call is picked up


I'm wondering if is it possible to set a condition for call answered/picked up in an onreply_route

something like this

onreply_route {
 if(call picked up) {
  xlog("ON AIR");
 }
}

Solution

  • There are quite a few ways in which you can achieve this. For your case, I would use the tm module's t_check_status() function:

    onreply_route {
        if (t_check_status("2[0-9][0-9]")) {
            xlog("ON AIR");
        }
    }
    

    However, note that this will not work if your SIP proxy is stateless (i.e. if you don't use tm at all)! In this case, we would need to access the information in a more low-level way, by reading it straight off the received message using the $rs variable (SIP reply status):

    onreply_route {
        if ($rs == 200) { # or ($rs =~ "2[0-9][0-9]")
            xlog("ON AIR");
        }
    }