Often you want to automate things in your CRM systems like Hubspot or Salesforce when a user in Hull is in a given segment, however there is no way to update only this one particular field based on this condition. But there is the Processor which can help you achieve exactly this. Wondering how, just read on...
How to implement it?
The implementation of this snippet is pretty straightforward, we will use the utility function isInSegment which the processor exposes to check whether the user is in a given segment and set an attribute to true or false depending on this condition.
Line 4 initializes the user attribute object which you might be familiar from other processor examples. It will hold all attributes we want to change on the user.
Line 9 contains the actual logic, in this example we will set the attribute is_customer in the group unified_data to true or false based on whether the user is in the segment called "Customers".
Lines 15-17 perform the actual call to the Hull API and this might also look familiar from other examples.
That's all, not that complex? Now you can go ahead and change the settings in your CRM connector which can now rely on this attribute.
And yes of course, you can repeat line 9 as often as needed to set other attributes as well.