# Event Routes

## `event_route[tm:branch-failure:id]`

Named branch failure routes can be defined to run when a failure response is received. This allows handling failures on individual branches, for example, retrying an alternative outbound flow.

The format of the event_route name is "tm:branch-failure:<id>" and is enabled with the t_on_branch_failure function. This event_route uses the BRANCH_FAILURE_ROUTE route type.

### `event_route[tm:branch-failure:id]` usage

    ...
    request_route {
        ...
        t_on_branch_failure("myroute");
        t_relay();
    }

    event_route[tm:branch-failure:myroute] {
        xlog("L_INFO", "Received $T_reply_code to $rm message\n");
    }
    ...

## `event_route[tm:local-request]`

Executed when the tm module generates a request, in other words, the request originates from &kamailio; and a transaction is created for it. The source of the requests can be tm itself or other modules that use tm internally (e.g., msilo, uac). The event route is executed if it is defined in the native &kamailio; config file. To execute the equivalent callback when using KEMI scripting, see the 'event_callback' module parameter.

The request can still be updated, i.e., changes are possible to R-URI ($ru), destination URI ($du) or the send socket ($fs).

### `event_route[tm:local-request]` usage

    ...
    event_route [tm:local-request] {
        xlog("L_INFO", "Routing locally generated $rm to $ru\n");
        t_set_fr(10000, 10000);
    }
    ...

## `event_route[tm:local-response]`

Executed after the tm module sent a local generated, transaction stateful response.

### `event_route[tm:local-response]` usage

    ...
    event_route[tm:local-response] {
        xlog("tm:local-response replied locally\n");
    }
    ...

## `event_route[tm:local-ack-sent]`

Executed after the tm module sent the ACK of the 200ok for a local generated INVITE. It is executed with the received 200ok response.

### `event_route[tm:local-ack-sent]` usage

    ...
    event_route[tm:local-ack-sent] {
        xlog("ACK for local INVITE was sent\n");
    }
    ...