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 a least one customer profile in Talon.One. This profile also exists in Braze.
- You have set up a loyalty program for your Application. For more information, see the Product docs.
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:
- Open your Talon.One Application in the Campaign Manager and click Settings > Developer settings.
- Click Create API Key.
- For Do you want to use this API Key with a 3rd party service?, select Yes.
- From Platform, select Braze.
- Select an expiration date and click Create API Key.
- Copy it for later use.
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 Note Associated Entity Event Event type My Braze event
This is an example. Choose something as descriptive as possible. Attribute Type String API name myBrazeEvent
This is an example. Choose something as descriptive as possible. Rule Builder name An event sent from Braze
This is an example. Choose something as descriptive as possible. Open your campaign and create a rule to award points:
What Name Properties Conditions Check for event types - Event type:
My Braze event
myBrazeEvent
Effects Add loyalty points Select your program and amount of points. - Event type:
Sending the event from Braze to Talon.One
To send the event, we use the Track event endpoint for Braze integrations:
https://integration.talon.one/braze/event
Setting up Braze to send the event
Let's use Braze's connected content feature and Braze's liquid tags.
You can use it in every campaign message body or any canvas message body.
We assume that your Braze setup sets an attribute for each user equal to the value of
the customer profile's integrationID
in Talon.One. This allows you to dynamically
retrieve the loyalty points of any user. We call this attribute ${user_id}
in this
tutorial.
Open your Braze campaign/canvas for editing.
According to the Braze docs, add the following connected content tag to the body of your message and add the URL to the loyalty endpoint. You can access Braze attributes by using liquid tags. For example,
{{${user_id}}}
to pass the user ID.{% capture postbody %}
{"eventType": "My Braze Event", "identifier": "{{campaign.${dispatch_id}}}",
"type":"string", "customerProfileId":"{{${user_id}}}",
"eventAttributes": {"myBrazeEvent": "my event"}}
{% endcapture %}
{% connected_content https://integration.talon.one/braze/event
:headers {
"Authorization": "ApiKey-v1 5df1c999014aca8a9a9d905d60836a5cc5045",
"destination-hostname": "https://mycompany.europe-west1.talon.one/"
}
:method post
:body {{postbody}}
:content_type application/json
:save result
%}
{% comment %} Extract the number of points awarded by finding the correct effect
in the effects array from the response. {% endcomment %}
{% 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>To test your request, click Preview in the template editor.
tipWe highly recommend you use Postman or similar tools to ensure you understand the structure of the response.