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 thelead_status_changed event
responsible_user_id
– filter by the responsible user, available for theentity_responsible_changed event
custom_field_values
– filter by the enum field value,
available for thecustom_field_{FIELD_ID}_value_changed
event, no more than 1 event type should be passedvalue
– 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
Parameter | Description | Type |
---|---|---|
value_after|value_before | Empty array | array |
{
"value_after": [],
"value_before": []
}
- Event type:
task_text_changed
Parameter | Type | Description |
---|---|---|
value_after|value_before | array | Array 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] | string | Task text |
{
"value_after": [
{
"task": {
"text": "new task text"
}
}
],
"value_before": [
{
"task": {
"text": "old task text"
}
}
]
}
- Event types:
robot_replied
andintent_identified
Parameter | Type | Description |
---|---|---|
value_after | array | Array of event changes (this event type always has one change in the array) |
value_after[0][helpbot] | obj | Triggered intent data object |
value_after[0][helpbot][text] | string | Task text |
{
"value_after": [
{
"helpbot": {
"id": 145
}
}
]
}
- Event type:
transaction_added
Parameter | Type | Description |
---|---|---|
value_after | array | Array of event changes (this event type always has one change in the array) |
value_after[0][transaction] | obj | Transaction data object |
value_after[0][transaction][id] | int | Transaction 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
Parameter | Type | Description |
---|---|---|
value_after | array | Array of event changes (this event type always has one change in the array) |
value_after[0][note] | obj | Note data object |
value_after[0][note][id] | int | Note ID |
{
"value_after": [
{
"note": {
"id": 7422564
}
}
]
}
- Event type:
nps_rate_added
Parameter | Type | Description |
---|---|---|
value_after | array | Array of event changes (this event type always has one change in the array) |
value_after[0][nps] | obj | NPS rate data object |
value_after[0][nps][rate] | int | Rate from 1 to 10 |
{
"value_after": [
{
"nps": {
"rate": 7
}
}
]
}
- Event types:
incoming_chat_message
andoutgoing_chat_message
Parameter | Type | Description |
---|---|---|
value_after | array | Array of event changes (this event type always has one change in the array) |
value_after[0][message] | obj | Message data object |
value_after[0][message][id] | string | Message ID |
{
"value_after": [
{
"message": {
"id": "1508b51c-aab0-428e-9322-611d847ae747"
}
}
]
}
- Event types:
entity_tag_added
andentity_tag_deleted
Parameter | Type | Description |
---|---|---|
value_after|value_before | array | Array of event changes |
value_after|value_before[0][tag] | obj | Tag data object |
value_after|value_before[0][tag][name] | string | Tag name |
{
"value_after": [
{
"tag": {
"name": "tag 1"
}
}
],
"value_before": [
{
"tag": {
"name": "tag2"
}
},
{
"tag": {
"name": "tag2"
}
}
]
}
- Event type:
lead_status_changed
Parameter | Type | Description |
---|---|---|
value_after|value_before | array | Array of event changes |
value_after|value_before[0][lead_status] | obj | Status data object |
value_after|value_before[0][lead_status][id] | int | Status ID |
value_after|value_before[0][lead_status][pipeline_id] | int | Pipeline 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
Parameter | Type | Description |
---|---|---|
value_after|value_before | array | Array of event changes (this event type always has one change in the array) |
value_after|value_before[0][link][entity][type] | string | Entity type |
value_after|value_before[0][link][entity][id] | int | Entity ID |
value_after|value_before[0][unlink][entity][type] | string | Entity type |
value_after|value_before[0][unlink][entity][id] | int | Entity ID |
{
"value_after": [
{
"link": {
"entity": {
"type": "lead",
"id": 6232965
}
}
}
],
"value_before": []
}
- Event type:
entity_responsible_changed
Parameter | Type | Description |
---|---|---|
value_after|value_before | array | Array of event changes |
value_after|value_before[0][responsible_user] | obj | User data object |
value_after|value_before[0][responsible_user][id] | int | User ID |
{
"value_after": [
{
"responsible_user": {
"id": 504329
}
}
],
"value_before": [
{
"responsible_user": {
"id": 37268
}
}
]
}
- Event type:
task_deadline_changed
Parameter | Type | Description |
---|---|---|
value_after|value_before | array | Array of event changes |
value_after|value_before[0][task_deadline] | obj | Task deadline data object |
value_after|value_before[0][task_deadline][timestamp] | int | Deadline timestamp |
{
"value_after": [
{
"task_deadline": {
"timestamp": 1573595900
}
}
],
"value_before": [
{
"task_deadline": {
"timestamp": 1573578700
}
}
]
}
- Event type:
task_type_changed
Parameter | Type | Description |
---|---|---|
value_after|value_before | array | Array of event changes |
value_after|value_before[0][task_type] | obj | Task type data object |
value_after|value_before[0][task_type][id] | int | Task type ID |
{
"value_after": [
{
"task_type": {
"id": 504329
}
}
],
"value_before": [
{
"task_type": {
"id": 37268
}
}
]
}
- Event type:
custom_field_value_changed
Parameter | Type | Description |
---|---|---|
value_after|value_before | array | Array of event changes |
value_after|value_before[0][custom_field_value][field_id] | int | Field ID |
value_after|value_before[0][custom_field_value][field_type] | int | Task type ID |
value_after|value_before[0][custom_field_value][enum_id] | int|null | Enum value ID or null if the field doesn’t have enum values |
value_after|value_before[0][custom_field_value][text] | string | Field 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]"
}
}
]
}