try {
    var result = { tags: {} },
        params = JSON.parse(value),
        req = new CurlHttpRequest(),
        resp = '';

    if (typeof params.HTTPProxy === 'string' && params.HTTPProxy.trim() !== '') {
        req.SetProxy(params.HTTPProxy);
    }
    var alertSourceKey = params['.ILERT.ALERT.SOURCE.KEY'];
    if (!alertSourceKey || (typeof alertSourceKey === 'string' && alertSourceKey.trim() === '')) {
        throw 'incorrect value for variable "ILERT.ALERT.SOURCE.KEY". The value must be a non-empty string.';
    }
    delete params['.ILERT.ALERT.SOURCE.KEY'];
    
    var ilertApiBaseURL = "https://api.ilert.com";
    var reqURL = encodeURI(ilertApiBaseURL + "/api/v1/events/zabbix-mt/" + alertSourceKey)

    var incidentKey = "zabbix-" + params['EVENT.ID'];
    var incidentViewURL = ilertApiBaseURL + "/api/v1/incidents/resolve-ik/" + alertSourceKey + "/" + incidentKey;

    req.AddHeader('Accept: application/json');
    req.AddHeader('Content-Type: application/json');

    Zabbix.Log(4, '[iLert Webhook] Sending request:' + JSON.stringify(params));
    resp = req.Post(reqURL, JSON.stringify(params));
    Zabbix.Log(4, '[iLert Webhook] Receiving response:' + resp);

    try {
        resp = JSON.parse(resp);
    }
    catch (error) {
        throw 'incorrect response. iLert returned a non-JSON object.';
    }

    if (req.Status() == 200) {
        result.tags.__ilert_incident_url = incidentViewURL;
        return JSON.stringify(result);
    }

    if (req.Status() == 400 && typeof resp === 'object' && typeof resp.code === 'string') {
        if (resp.code === 'NO_OPEN_INCIDENT_WITH_KEY') {
          return JSON.stringify(result);
        }
        if (resp.code === 'INCIDENT_ALREADY_ACCEPTED') {
          result.tags.__ilert_incident_url = incidentViewURL;
          return JSON.stringify(result);
        }
    }

    if (typeof resp === 'object' && typeof resp.message === 'string') {
        throw resp.message;
    }
    else {
        throw 'Unknown error.';
    }
}
catch (error) {
    Zabbix.Log(3, '[iLert Webhook] Notification failed : ' + error);
    throw 'iLert notification failed : ' + error;
}