I managed to make it work by using $dlg(callid) and $dlg(from_tag) as dialog identifier:

event_route[dialog:start] {
        evapi_relay("{'callid': '$dlg(callid)', 'from_tag': '$dlg(from_tag)', 'event': 'answered'}");
}
event_route[dialog:end] {
        evapi_relay("{'callid': '$dlg(callid)', 'from_tag': '$dlg(from_tag)', 'event': 'ended'}");
}

event_route[dialog:failed] {
        evapi_relay("{'callid': '$dlg(callid)', 'from_tag': '$dlg(from_tag)', 'event': 'failed'}");
}

Regards,
Minh


2016-05-27 18:25 GMT+02:00 Minh Phan <mphan@wengo.com>:
Hi List,

I'm trying to have an external application to write CDR to a database by doing this:

event_route[dialog:start] {
        evapi_relay("{'cdr_id': $dlg_var(cdr_id), 'event': 'answered'}");
}
event_route[dialog:end] {
        evapi_relay("{'cdr_id': $dlg_var(cdr_id), 'event': 'ended'}");
}

event_route[dialog:failed] {
        evapi_relay("{'cdr_id': $dlg_var(cdr_id), 'event': 'failed'}");
}

$dlg_var(cdr_id) is set inside a request route. However, in these event routes, its value is always null. Its seems that $dlg_var variables are not available in those event routes.

What are the variables available in dialog event route? Any suggestion on how to achieve what I'm trying to do?

Best regards,
Minh