Adding loyalty points via Braze
Let's set up Braze to give loyalty points to a customer when Talon.One receives a specific Braze event.
To do this, we must send a request to Talon.One from a campaign or canvas body using the Track event endpoint for Braze.
Talon.One requirements
- You have an Application and campaign in Talon.One.
- You have at least one customer profile in your Application. This profile also exists in Braze.
- You have set up a loyalty program.
Braze requirements
- You have created a campaign or canvas in Braze.
- You have a way to identify a given customer across Talon.One and Braze.
In this tutorial, we assume a customer's Talon.One
integrationId
is always equal to Braze'suser_id
. You can also create a new property on your Braze customer profiles to store Talon.One's integration ID.
Creating an API key in Talon.One
In the Campaign Manager, create a Braze-specific API key:
-
In your Application, click Settings > Integration API Keys.
-
Click Create API Key.
-
In the Create API Key drawer, select Production as the key type.
-
In Key name, type a name to identify the key.
-
In Key expiration date, select a date.
-
In Third-party integration, select Yes.
-
From Platform, select Braze.
-
Click Create API Key.
-
Click to copy the key for use.
noteYou cannot view or copy the API key after closing the drawer. If you lose it, create another API key.
We will use the API key in the Braze campaign template.
Creating the Talon.One rule
-
Create a new custom attribute that represents the event sent from Braze:
Property Value Entity Event Event type My Braze event
Type String API name myBrazeEvent
Name My Braze event
-
Open your campaign and create a rule to award points:
What Name Properties Conditions Check for event types
and custom event values- Event type:
My Braze event
- My Braze event (Event) is equal to
test_string
.
Effects Add loyalty points Select your profile-based loyalty program and set the amount of points to award. - Event type:
Sending the event to add loyalty points
To send the event, we call the following endpoint:
https://integration.talon.one/braze/event
See API Docs
To trigger the endpoint, we must use Braze's Connected Content feature.
We assume that your customer profile in Braze contains a unique identifier that is equal to the customer integration ID in Talon.One.
In this tutorial, we use ${user_id}
. Ensure the user ID matches the integration ID in Talon.One.
-
Open your Braze campaign or canvas for editing.
-
Add the following Connected Content call to the body of your message, where:
YOUR_API_KEY
is the API key you created.YOUR_DEPLOYMENT_URL
is the base URL of your Talon.One deployment.
{% capture postbody %}
{"eventType": "My Braze Event", "identifier": "{{ 'now' | date: '%Y-%m-%d %H:%M:%S.%N' }}",
"type":"string", "customerProfileId":"{{${user_id}}}",
"eventAttributes": {"myBrazeEvent": "test_string"}}
{% endcapture %}
{% connected_content https://integration.talon.one/braze/event
:headers {
"Authorization": "ApiKey-v1 YOUR_API_KEY",
"destination-hostname": "YOUR_DEPLOYMENT_URL"
}
:method post
:body {{postbody}}
:content_type application/json
:save result
%}
{% for effect in result.effects %}
{% if effect.effectType == "addLoyaltyPoints" %}
<p>You were awarded {{effect.props.value}} loyalty points!</p>
<p>(Reason: '{{effect.props.name}}')</p>
{% endif %}
{% endfor %}
<p>HTTP response code: {{result.__http_status_code__}}.</p>noteIn the example above, we use a timestamp for the
identifier
parameter. This ensures that a new event is sent for each email during testing. In production, consider using one of the available personalization tags, for example, the dispatch ID. -
To test your request:
- In the sidebar, click Preview & Test.
- In Preview message as user, select Search User and search for an existing user in Braze.