Using notifications with Braze
In this tutorial, let's set up Braze to receive loyalty notifications from Talon.One and use them to trigger an email campaign. This way, we can inform customers when they earn or redeem loyalty points.
Because the schema of Talon.One's notification requests doesn't match the schema of Braze's API endpoints, we can't send our requests to Braze directly. Instead, we rely on Braze's Data Transformation feature to transform the requests into valid Braze API calls.
Talon.One requirements
- You are an Admin user.
- You have set up an Application.
- You have at least one customer profile in your Application. This profile also exists in Braze, and contains a valid email address.
- You have set up a card-based or profile-based loyalty program.
Braze requirements
- You are an account or workspace admin.
Setting up the integration
Generate the webhook URL
First, we must generate a webhook URL to which we can send the loyalty notification requests.
Braze automatically generates a webhook URL when you create a data transformation. So let's do that:
- In Braze, open Data Settings > Data Transformation.
- Click Create transformation and configure the following parameters:
- In Transformation name, type a name for the transformation.
- In Editing experience, select Start from scratch.
- In Select destination, select POST: Track users.
This is the endpoint we will use to trigger the email campaign.
- Click Create Transformation.
- Next to Webhook URL, click Copy.
The webhook URL is copied to the clipboard.
Create the notification
Any of Talon.One's notifications can be used to trigger actions in Braze. In this tutorial, we want to inform customers when they earn or redeem loyalty points, so let's create an Added/deducted points notification:
- In Loyalty, select your loyalty program.
- On the left-side menu of the loyalty program, click Notifications.
- Click Create Notification.
- In the Create Notification drawer, select Added/deducted points.
- In Notification name, type a name for the notification.
- In the Request section, specify the details of the webhook request:
- In URL, paste the Braze webhook URL you created.
- In Header, add the following header:
Content-Type: application/json
.
- Send a test request to Braze by clicking Test Notification.
- Click Create Notification.
Configure the data transformation
Now that we sent a test request to Braze, we can configure the data transformation to transform the request into a valid Braze API call:
-
In Braze, close and reopen the data transformation you created.
Under Webhook details, you should see the payload of the test request you sent from Talon.One. -
Under Transformation code, write your transformation code. The code must transform the payload into a valid call to Braze's Track users endpoint. For example, you can use the following code:
let brazecall = {
"events": [
{
"external_id": payload.ProfileIntegrationID,
"name": "Loyalty points changed",
"time": new Date().toISOString(),
"properties": {
"points_amount": payload.Amount,
"operation": payload.Operation
}
}
]
};
return brazecall;This code creates a new event called
Loyalty points changed
with the following properties:points_amount
: The amount of added or deducted loyalty points.operation
: The operation performed (addition
ordeduction
).
The event is assigned to the user identified by their integration ID in Talon.One.
-
Click Validate to check the code for errors.
-
Click Activate.
-
In Talon.One, reopen the notification you created and click Test Notification.
This creates a new event in Braze namedLoyalty points changed
.
Trigger the email campaign
We can now use the Braze event to trigger an email campaign:
-
In Braze, click Messaging > Campaigns > Create campaign > Email.
-
In Campaign Name, type a name for your campaign.
-
In Email Variants, select HTML Editor and click Blank Template.
-
Click Edit Sending Info and enter a subject line for the email.
-
Click the Body tab and insert the following HTML code:
<p>Hey! Here's an update on your loyalty points:</p>
{% if event_properties.${operation} == "addition" %}
<p>You have earned {{event_properties.${points_amount}}} loyalty points.</p>
{% elsif event.properties.operation == "deduction" %}
<p>You have spent {{event_properties.${points_amount}}} loyalty points.</p>
{% endif %}
<p>Have a great day!</p>This code does the following:
- It reads the
operation
property to check whether points have been added or deducted, and displays a message accordingly. - It reads the
points_amount
property to show the amount of loyalty points added or deducted.
- It reads the
-
Click Done.
-
In the Schedule Delivery tab, select Action-Based as the delivery type.
-
In New Trigger Action, select Perform Custom Event and click Add Trigger.
-
In Choose a custom event, select Loyalty points changed.
-
In the Target Audiences tab, ensure that the targeted segment includes the email address of the user you want to send the loyalty information to.
-
Enter the remaining required campaign details, and click Launch Campaign.
Testing the setup
To test the setup, change the loyalty balance of a customer profile in Talon.One, for example, by manually adding loyalty points.
This triggers the notification you created, which in turn triggers the email campaign in Braze and sends an email to the customer with the updated loyalty points information.