Skip to content

Commit

Permalink
Merge pull request #26 from realstorypro/remove-customer-contacts
Browse files Browse the repository at this point in the history
added ability to remove not engaged contacts
  • Loading branch information
Leonid Medovyy committed Mar 9, 2022
2 parents d1096de + 124b7ed commit f1c891d
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 30 deletions.
12 changes: 12 additions & 0 deletions lib/tasks/cleanup.rake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ namespace :cleanup do
end
end

desc "delete not engaged contacts in customer.io from leads marked as 'bad fit'"
task customer_io_contacts: :environment do
customerio = Customerio::Client.new(ENV['CUSTOMER_IO_SITE_ID'], ENV['CUSTOMER_IO_KEY'])

close_contacts = @close_api.search('bad_fit__not_engaged.json')
close_contacts.each do |contact|
found_contact = @close_api.find_contact(contact["id"])

customerio.delete(found_contact["emails"][0]["email"])
end
end

# we are using this to move opportunities from 'VIP' to 'Automated' pipelines
# NOTE: The VIP pipeline is gone, but I am leaving this here for a reference.
desc "Move oops between pipelines from 'VIP inbox' to the 'Automated inbox'"
Expand Down
70 changes: 70 additions & 0 deletions lib/tasks/search/bad_fit__not_engaged.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"limit": null,
"query": {
"negate": false,
"queries": [
{
"negate": false,
"object_type": "contact",
"type": "object_type"
},
{
"negate": false,
"queries": [
{
"negate": false,
"queries": [
{
"condition": {
"type": "term",
"values": [
"Yes"
]
},
"field": {
"custom_field_id": "cf_VImU7puejeNhbTrVKvyPx5QhS9wVawZ0uLFwDYZB35K",
"type": "custom_field"
},
"negate": false,
"type": "field_condition"
}
],
"type": "and"
},
{
"negate": false,
"related_object_type": "lead",
"related_query": {
"negate": false,
"queries": [
{
"condition": {
"object_ids": [
"stat_JemNT0UgRV1wWyw2mnAt7SdNb4zUCgv4ksbcv2Rr4l3"
],
"reference_type": "status.lead",
"type": "reference"
},
"field": {
"field_name": "status_id",
"object_type": "lead",
"type": "regular_field"
},
"negate": false,
"type": "field_condition"
}
],
"type": "and"
},
"this_object_type": "contact",
"type": "has_related"
}
],
"type": "and"
}
],
"type": "and"
},
"results_limit": null,
"sort": []
}
30 changes: 0 additions & 30 deletions lib/tasks/search/nurture.json

This file was deleted.

0 comments on commit f1c891d

Please sign in to comment.