Skip to main content

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

  1. You have an Application and campaign in Talon.One.
  2. You have a least one customer profile in Talon.One. This profile also exists in Braze.
  3. You have set up a loyalty program for your Application. For more information, see the Product docs.

Braze requirements

  1. You have created a campaign or canvas in Braze.
  2. 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's user_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:

  1. Open your Talon.One Application in the Campaign Manager and click Settings > Developer settings.
  2. Click Create API Key.
  3. For Do you want to use this API Key with a 3rd party service?, select Yes.
  4. From Platform, select Braze.
  5. Select an expiration date and click Create API Key.
  6. Copy it for later use.

We will use the API key in the Braze campaign template.

Creating the Talon.One rule

  1. Create a new custom attribute that represents the event sent from Braze:

    PropertyValueNote
    Associated EntityEvent
    Event typeMy Braze eventThis is an example. Choose something as descriptive as possible.
    Attribute TypeString
    API namemyBrazeEventThis is an example. Choose something as descriptive as possible.
    Rule Builder nameAn event sent from BrazeThis is an example. Choose something as descriptive as possible.
  2. Open your campaign and create a rule to award points:

    WhatNameProperties
    ConditionsCheck for event types
    • Event type: My Braze event
    • myBrazeEvent
    EffectsAdd loyalty pointsSelect your program and amount of points.

Sending the event from Braze to Talon.One

To send the event, we use the Track event endpoint for Braze integrations:

POST Track event (Braze)
https://integration.talon.one/braze/event
See API Docs

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.

Important

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.

  1. Open your Braze campaign/canvas for editing.

  2. 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>
  3. To test your request, click Preview in the template editor.

    tip

    We highly recommend you use Postman or similar tools to ensure you understand the structure of the response.