Setup Guide
1
Create API authentication
Store Factr API key in Customer.io environment variables.
2
Set up event-triggered enrichment
Use Customer.io events to trigger Factr enrichment via webhooks.
3
Store enrichment in attributes
Map Factr response fields to Customer.io custom attributes.
4
Build journeys on enrichment data
Create dynamic journeys that branch based on enriched attributes.
Code Example
JavaScript / Node.js
// Customer.io webhook enrichment handler
app.post('/webhooks/customer-io', async (req, res) => {
const { data } = req.body;
const email = data.customer.email;
// Enrich via Factr
const factrRes = await fetch('https://factr.polsia.app/api/enrich', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email,
apiKey: process.env.FACTR_API_KEY
})
});
const enrichment = await factrRes.json();
// Update Customer.io attributes
const cioRes = await fetch('https://api.customer.io/v1/customers/' + data.customer.id, {
method: 'PUT',
headers: {
'Authorization': 'Bearer ' + process.env.CUSTOMER_IO_TOKEN,
'Content-Type': 'application/json'
},
body: JSON.stringify({
attributes: { enriched_fact: enrichment.fact }
})
});
res.json({ success: true });
});
Key Benefits
- Smart journey branching on enriched data
- Real-time personalization at scale
- Close the loop between intent and action
- Reduce churn with contextual messaging