Use functions to reshape webhook payloads before Hightouch writes them to your warehouse or sends them to destinations.
These webhooks usually contain event data that are helpful for building a full profile of your users. For example, Shopify has webhooks for when users check out, and Iterable has webhooks for when users open emails.
To set this up, create a webhook source and add it to the tool that emits events. You can then process the raw webhook data using functions.
For example, your code might look something like:
async function transformEvents(events) {
return events.map((event) => ({
...event,
type: "track",
event: event.event,
messageId: event.messageId,
properties: {
...event.properties.body.dataFields,
email: event.properties.body.email,
},
anonymousId: event.properties.body.userId
? null
: event.properties.body.email,
userId: event.properties.body.userId,
}));
}