Events filtration

There are two more parameters that you can use for events filtration: "value_before" and "value_after".

The following values are available for the filter by before/after values at the moment:

  • leads_statuses – filter by the lead stage, available for the lead_status_changed event
  • responsible_user_id – filter by the responsible user, available for the entity_responsible_changed event
  • custom_field_values – filter by the enum field value,
    available for the custom_field_{FIELD_ID}_value_changed event, no more than 1 event type should be passed
  • value – filter by the exact value, available for the
    nps_rate_added, sale_field_changed, name_field_changed, ltv_field_changed, custom_field_value_changed events

leads_statuses

This filter allows to pass stage and pipeline IDs to get only required lead stage change events.

This is what the request could look like:

filter[value_after][leads_statuses][0][pipeline_id]=12345&filter[value_after][leads_statuses][0][status_id]=99999999

In the example we’ll get all lead stage change events where the lead was moved to the stage 99999999 of the pipeline 12345.

responsible_user_id

This filter allows to pass user IDs separated with commas to get only the required responsible user change events.

This is what the request could look like:

filter[value_after][responsible_user_id]=5555555

Here we’ll get all responsible user change events for the user ID 5555555.

custom_field_values

Filter by the enum field value, available for the custom_field_{FIELD_ID}_value_changed event, no more than 1 event type should be passed.

This filter allows to pass enum field values to get only required field values change events.

This is what the request could look like:

filter[value_after][custom_field_values]=145&filter[type]=custom_field_777777_value_changed

In the following example we’ll get all field value change events for the field ID 777777 with enum ID 145.

value

This filter allows to pass before/after values. It is only available for the following event types: nps_rate_added,
sale_field_changed, name_field_changed, ltv_field_changed, custom_field_value_changed.

This is what the request could look like:

filter[value_after][value]=155&filter[type]=sale_field_changed&filter[entity]=lead

Here we’ll get all lead sale change events where lead sale became equal to 155.


Data structure of value_after/before

If you want to write your own scripts to filter events list, keep in mind the data structure of value_after and value_before fields depends on the event type and can have different values.

  • Event types: lead_deleted, lead_restored, contact_deleted, contact_restored, company_deleted, company_restored, entity_merged, task_added, task_deleted, task_completed
ParameterDescriptionType
value_after|value_beforeEmpty arrayarray
{
    "value_after": [],
    "value_before": []
}
  • Event type: task_text_changed
ParameterTypeDescription
value_after|value_beforearrayArray of event changes (this event type always has one change in the array)
value_after|value_before[0][task]objСhanged task data object
value_after|value_before[0][task][text]stringTask text
{
    "value_after": [
          {
            "task": {
              "text": "new task text"
            }
          }
        ],
    "value_before": [
          {
            "task": {
              "text": "old task text"
            }
          }
        ]
}
  • Event types: robot_replied and intent_identified
ParameterTypeDescription
value_afterarrayArray of event changes (this event type always has one change in the array)
value_after[0][helpbot]objTriggered intent data object
value_after[0][helpbot][text]stringTask text
{
    "value_after": [
          {
            "helpbot": {
              "id": 145
            }
          }
        ]
}
  • Event type: transaction_added
ParameterTypeDescription
value_afterarrayArray of event changes (this event type always has one change in the array)
value_after[0][transaction]objTransaction data object
value_after[0][transaction][id]intTransaction ID
{
    "value_after": [
          {
            "transaction": {
              "id": 33675
            }
          }
        ]
}

  • Event types: lead_added, contact_added, company_added, common_note_added, common_note_deleted, attachment_note_added, targeting_in_note_added, targeting_out_note_added, geo_note_added, service_note_added, site_visit_note_added, message_to_cashier_note_added, incoming_call, outgoing_call, incoming_sms, outgoing_sms, link_followed, task_result_added
ParameterTypeDescription
value_afterarrayArray of event changes (this event type always has one change in the array)
value_after[0][note]objNote data object
value_after[0][note][id]intNote ID
{
    "value_after": [
          {
            "note": {
              "id": 7422564
            }
          }
        ]
}
  • Event type: nps_rate_added
ParameterTypeDescription
value_afterarrayArray of event changes (this event type always has one change in the array)
value_after[0][nps]objNPS rate data object
value_after[0][nps][rate]intRate from 1 to 10
{
    "value_after": [
          {
            "nps": {
              "rate": 7
            }
          }
        ]
}
  • Event types: incoming_chat_message and outgoing_chat_message
ParameterTypeDescription
value_afterarrayArray of event changes (this event type always has one change in the array)
value_after[0][message]objMessage data object
value_after[0][message][id]stringMessage ID
{
    "value_after": [
          {
            "message": {
              "id": "1508b51c-aab0-428e-9322-611d847ae747"
            }
          }
        ]
}
  • Event types: entity_tag_added and entity_tag_deleted
ParameterTypeDescription
value_after|value_beforearrayArray of event changes
value_after|value_before[0][tag]objTag data object
value_after|value_before[0][tag][name]stringTag name
{
    "value_after": [
          {
            "tag": {
              "name": "tag 1"
            }
          }
        ],
    "value_before": [
          {
            "tag": {
              "name": "tag2"
            }
          },
          {
            "tag": {
              "name": "tag2"
            }
          }
        ]
}
  • Event type: lead_status_changed
ParameterTypeDescription
value_after|value_beforearrayArray of event changes
value_after|value_before[0][lead_status]objStatus data object
value_after|value_before[0][lead_status][id]intStatus ID
value_after|value_before[0][lead_status][pipeline_id]intPipeline ID
{
    "value_after": [
          {
            "lead_status": {
              "id": 5233224,
              "pipeline_id": 437642,
            }
          }
        ],
    "value_before": [
          {
            "lead_status": {
              "id": 5233224,
              "pipeline_id": 437642,
            }
          }
        ]
}
  • Event types: company_linked, company_unlinked, contact_linked, contact_unlinked, lead_linked, lead_unlinked, entity_linked, entity_unlinked
ParameterTypeDescription
value_after|value_beforearrayArray of event changes (this event type always has one change in the array)
value_after|value_before[0][link][entity][type]stringEntity type
value_after|value_before[0][link][entity][id]intEntity ID
value_after|value_before[0][unlink][entity][type]stringEntity type
value_after|value_before[0][unlink][entity][id]intEntity ID
{
    "value_after": [
          {
            "link": {
              "entity": {
                "type": "lead",
                "id": 6232965
              }
            }
          }
        ],
    "value_before": []
}
  • Event type: entity_responsible_changed
ParameterTypeDescription
value_after|value_beforearrayArray of event changes
value_after|value_before[0][responsible_user]objUser data object
value_after|value_before[0][responsible_user][id]intUser ID
{
    "value_after": [
          {
            "responsible_user": {
              "id": 504329
            }
          }
        ],
    "value_before": [
          {
            "responsible_user": {
              "id": 37268
            }
          }
        ]
}
  • Event type: task_deadline_changed
ParameterTypeDescription
value_after|value_beforearrayArray of event changes
value_after|value_before[0][task_deadline]objTask deadline data object
value_after|value_before[0][task_deadline][timestamp]intDeadline timestamp
{
    "value_after": [
          {
            "task_deadline": {
              "timestamp": 1573595900
            }
          }
        ],
    "value_before": [
          {
            "task_deadline": {
              "timestamp": 1573578700
            }
          }
        ]
}
  • Event type: task_type_changed
ParameterTypeDescription
value_after|value_beforearrayArray of event changes
value_after|value_before[0][task_type]objTask type data object
value_after|value_before[0][task_type][id]intTask type ID
{
    "value_after": [
          {
            "task_type": {
              "id": 504329
            }
          }
        ],
    "value_before": [
          {
            "task_type": {
              "id": 37268
            }
          }
        ]
}
  • Event type: custom_field_value_changed
ParameterTypeDescription
value_after|value_beforearrayArray of event changes
value_after|value_before[0][custom_field_value][field_id]intField ID
value_after|value_before[0][custom_field_value][field_type]intTask type ID
value_after|value_before[0][custom_field_value][enum_id]int|nullEnum value ID or null if the field doesn’t have enum values
value_after|value_before[0][custom_field_value][text]stringField value text
{
  "value_after": [
    {
      "custom_field_value": {
        "field_id": 53728,
        "field_type": 8,
        "enum_id": 2352876,
        "text": "[email protected]"
      }
    },
    {
      "custom_field_value": {
        "field_id": 53728,
        "field_type": 8,
        "enum_id": 2352876,
        "text": "[email protected]"
      }
    }
  ],
  "value_before": [
    {
      "custom_field_value": {
        "field_id": 53728,
        "field_type": 8,
        "enum_id": 193200,
        "text": "[email protected]"
      }
    }
  ]
}