Points Updates

Real-time Point Update Notifications

In this tutorial, let's set up Braze to receive loyalty notifications from Open Loyalty and use them to trigger an email campaign. This way, we can inform customers immediately when their points balance changes (earning or spending).

Because the schema of Open Loyalty's webhook requests doesn't match the schema of Braze's API endpoints, we can't send requests to Braze directly. Instead, we rely on Braze's Data Transformation feature to transform the Open Loyalty payload into valid Braze API calls.

Open Loyalty Requirements

  • You are an admin user.

  • You have a Tenant.

  • You have at least one Member profile in Tenant. This profile should also exist in Braze (identified by their e.g. loyaltyCardNumber).

  • You have configured a Wallet and Points system to allow for balance changes.

Braze Requirements

  • You are an account or workspace admin.

  • Access to the "Data Settings" tab in Braze to configure webhook listeners.


Setting up the integration

1

Generate the Webhook URL

First, we must generate a webhook URL to which Open Loyalty can send the notification requests. Braze automatically generates a webhook URL when you create a data transformation.

  1. In Braze, open Data Settings > Data Transformation.

  2. Click Create transformation and configure the following parameters:

    1. Transformation name: Type a name (e.g., "Open Loyalty Points Update").

    2. Editing experience: Select Start from scratch.

    3. Select destination: Select POST: Track users. (This is the endpoint used to trigger user events).

  3. Click Create Transformation.

  4. Next to Webhook URL, click Copy.

circle-exclamation
2

Create the Webhook Subscription

You must configure Open Loyalty to send data to the Braze URL you just generated whenever a member's points balance changes. We will use the AvailablePointsAmountChanged event.

  1. Log in to your Open Loyalty Admin Panel.

  2. Navigate to General > Webhooks.

  3. Click Add new webhook and configure the subscription:

    1. eventName: Set this to AvailablePointsAmountChanged. This event triggers whenever the number of available units on a member's account changes.

    2. url: Paste the Braze webhook URL you copied in Step 1.

    3. Add the following headers:

      1. Content-Type: application/json

      2. User-Agent: partner-OpenLoyalty

  4. Save the webhook subscription.

3

Configure the Data Transformation

Now that Open Loyalty is linked to Braze, you must write the JavaScript logic in Braze to translate the Open Loyalty payload into a Braze User Track event.

  • In Braze, open the data transformation you created in Step 1.

  • Trigger a points change in Open Loyalty (e.g., add points to a test member) to generate a sample payload under Webhook details.

circle-info

The Open Loyalty payload contains a data object with amountChange, amountChangeType, and customer details.

  • Under Transformation code, enter the following JavaScript. This maps Open Loyalty data to Braze properties:

let brazecall = {
  "events": [
    {
      // Map the Open Loyalty loyaltyCardNumber to the Braze External ID
      "external_id": payload.data.customer.loyaltyCardNumber, 
      "name": "Loyalty points changed",
      "time": new Date().toISOString(),
      "properties": {
        // The amount added or subtracted
        "points_amount": payload.data.amountChange,
        // The new total balance
        "current_balance": payload.data.amount,
        // The type of change (e.g., "add" or "spend")
        "operation": payload.data.amountChangeType
      }
    }
  ]
};

return brazecall;
  • Click Validate to ensure the code runs against your sample payload.

  • Click Activate.

4

Trigger the Email Campaign

You can now use the custom Braze event (Loyalty points changed) to trigger an email.

  1. In Braze, click Messaging > Campaigns > Create campaign > Email.

  2. In Campaign Name, type a name for your campaign.

  3. In Email Variants, select HTML Editor and click Blank Template.

  4. Click Edit Sending Info and enter a subject line.

  5. Click the Body tab and insert the following HTML code. This uses Liquid logic to display dynamic text based on whether points were added or spent:

<p>Hello! We have an update on your loyalty points:</p>


{% if event_properties.${operation} == "add" %}
  <p>You have earned {{event_properties.${points_amount}}} points.</p>
{% elsif event_properties.${operation} == "spend" %}
  <p>You have spent {{event_properties.${points_amount}}}  points.</p>
{% endif %}


<p>Your new balance is {{event_properties.${current_balance}}}.</p>
<p>Have a great day!</p>
  1. Click Done.

  2. In the Schedule Delivery tab, select Action-Based as the delivery type.

  3. In New Trigger Action, select Perform Custom Event and click Add Trigger.

  4. In Choose a custom event, select Loyalty points changed.

  5. Ensure your Target Audience includes the users you are testing with.

  6. Click Launch Campaign.

5

Testing the Setup

To test the setup, manually change a member's points balance in Open Loyalty (e.g., via the Admin Panel)

  1. This triggers the AvailablePointsAmountChanged webhook.

  2. Braze receives the data, transforms it using your JavaScript, and records the Loyalty points changed event.

  3. The email campaign is triggered, sending the user an update with their earnings and new balance.

Last updated

Was this helpful?