Integrations
Outgoing integrations from RaffleX
N8N Automations
RaffleX provides a native integration with N8N to trigger workflows based on platform events. This guide covers how to configure the integration within your Tenant panel and details the webhook payloads you will receive.
Familiarity to n8n will help with this integration we are currently not providing support for this integration as it is self serve.
Configuration
To set up the N8N integration, navigate to your Tenant Admin Panel:
Go to Settings > Integrations.
Locate the N8N Integration section.
Fill in the following fields:
N8N Webhook URL: The URL of your N8N webhook node (e.g.,
https://n8n.yourdomain.com/webhook/...).N8N Webhook Secret: (Optional) A secret string used to verify the request authenticity. If provided, it will be sent in the
X-Webhook-Secretheader.
Enable the events you wish to subscribe to:
Send Order Completed: Triggers when an order is successfully paid and completed.
Send User Created: Triggers when a new customer account is registered.
Send Marketing Subscribe/Unsubscribe Events: Triggers when a customer subscribes to or unsubscribes from marketing (
marketing.subscribedandmarketing.unsubscribed).
Click Save Settings.
Each toggle is independent. If a toggle is off, or the webhook URL is empty, nothing is sent for that event.
Webhook Structure
All webhooks sent to N8N follow a standard envelope structure:
Headers
Requests from RaffleX will include the following headers:
Content-Type:application/jsonX-Webhook-Event: The event type (e.g.,order.completed,user.created)X-Webhook-Secret: Your configured secret (if set)
Event Reference
There are four events in total. Each one is listed below with a full example of the data object you will receive.
order.completed
A customer completes a purchase
user.created
A customer registers an account on your site
marketing.subscribed
A customer opts in to marketing
marketing.unsubscribed
A customer is unsubscribed from marketing
1. Order Completed (order.completed)
Triggered when a customer completes a purchase. This fires for every completed order, whatever the payment method used (card, PayPal, wallet credit, free entry, or partial payment). The payment_gateway field in the payload tells you which method was used.
Data Payload:
2. User Created (user.created)
Triggered when a customer registers an account on your site. It does not fire for accounts you create yourself from the admin panel, or for accounts brought in by an import.
The consent block reflects the state at the moment they registered. If they ticked the marketing opt in box during sign up, marketing_opted_in_at will already be set, as below. If they did not, both fields will be null.
Data Payload:
3. Marketing Subscribed (marketing.subscribed)
Triggered when a customer opts in to your marketing. This happens when they tick the consent box at checkout, tick the opt in box while registering an account, or enter their email into a newsletter sign up block on your site.
Opting in clears any previous unsubscribe, so marketing_unsubscribed_at is always null on this event.
Data Payload:
4. Marketing Unsubscribed (marketing.unsubscribed)
Triggered when a customer is unsubscribed from your marketing. This happens when they unsubscribe themselves in My Account, when you unsubscribe them from the Users area of your admin panel, or when they self exclude, whether they do that themselves or you lock their account for them.
Note that marketing_opted_in_at keeps its original value here. It is the date they last opted in, and unsubscribing does not erase it. See How consent is represented below, because this catches people out.
Data Payload:
How consent is represented
Every event that carries a customer includes a consent block, so you never have to guess at their marketing status. It holds two timestamps:
marketing_opted_in_at
When the customer last opted in, or null if they never have
marketing_unsubscribed_at
When the customer last unsubscribed, or null if they have not
Read marketing_unsubscribed_at first. This is the bit that catches people out. Opting in and unsubscribing are recorded separately, and unsubscribing does not erase the earlier opt in date. So a customer who opted in during March and unsubscribed in April arrives with both fields set. If you only check marketing_opted_in_at, you will treat an unsubscribed customer as subscribed, and email someone who asked you not to.
The rule to apply is:
If
marketing_unsubscribed_atis set, the customer is unsubscribed, whatevermarketing_opted_in_atsays.Otherwise, if
marketing_opted_in_atis set, the customer is subscribed.If both are
null, the customer has never opted in.
Opting in again clears marketing_unsubscribed_at back to null, so a customer who returns is correctly subscribed once more.
The event field in the envelope (and the matching X-Webhook-Event header) still tells you what just happened, which is handy for routing. The consent block tells you where the customer now stands. Use the event name to decide which branch to run, and the consent block to decide what the customer's state actually is.
Here is a complete marketing.unsubscribed request, envelope included:
In n8n, add a Switch node straight after your Webhook node and branch on {{ $json.event }} to route each event type. Use data.user.email as the key to match the customer in whatever system you are updating, and read data.consent to set their status there.
Delivery and retries
Requests are sent with a 30 second timeout. If your endpoint is unreachable or returns an error, RaffleX retries a small number of times with an increasing gap between attempts before giving up.
This means your workflow can occasionally receive the same event more than once, so build it to cope with repeats. For order.completed, use the order.id to spot an order you have already handled. For the marketing events, use the customer's email address.
Last updated