OpenFn/gife

Get campaign members & add or update members and tags

Closed this issue · 0 comments

mtuchi commented

Background, context, and business value

See readme

The specific request, in as few words as possible

Every 30 minutes:

Job 1- Get Campaign Members

Get Campaign members in Salesforce created since the last job run OR the Campaign Member’s Contact updated since the last job run.
Adaptor: Salesforce
Object: Campaign Members,
Primary key (field): email,
Query:

SELECT Id, name, firstname, lastname, email, CreatedDate, Contact.AccountId, Contact.LastModifiedDate, Contact.CreatedDate, Campaign.Name, campaign.Nome_da_Tag__c FROM CampaignMember WHERE Campaign.RecordType.Name = 'Grupos, RTs ou Áreas Temáticas' and  Campaign.IsActive = true and ( (Contact.LastModifiedDate > {LastSyncTime} or CreatedDate > {LastSyncTime})

Documentation:

Job 2 - Add or update members and tags

POST /lists/{list_id}
Adaptor: MailChimp
API endpoint: Batch subscribe or unsubscribe list members
Path parameters: list_id = “43fead6cd7”
Body parameters: members see mapping Specs (An array of objects, each representing an email address and the subscription status for a specific list. Up to 500 members may be added or updated with each API call.)

The job will has a loop to divide the records in two batches:

  • Add member on contactsToUpdate batch;
    • without "status" field in “member[ ]”;
  • Add member on contactsToCreate batch;
    • with "status" field setted to “subscribed” in “member[ ]”

Documentation:

Expected data volumes

It is expected that each Campaign in Salesforce will return a maximum of 1000 records (Campaign Members). In rare exceptions, this number can reach 15,000 records.

In Salesforce, when a SOQL query is executed, up to 2,000 records can be returned at a time in a synchronous request.

Mailchimp API limits: https://mailchimp.com/developer/marketing/docs/fundamentals/#api-limits
For the batch subscribe or unsubscribe list members in Mailchimp, up to 500 members may be added or updated with each API call.

state.json