Skip to main content

Creating coupons via Braze

In this tutorial, let's set up Braze to automatically generate coupons inside Talon.One and deliver the coupon codes to specific customer segments.

To do so, we will rely on a Talon.One Braze-specific endpoint that will generate coupons and we'll send requests to it from Braze.

Setting up your Braze account

We assume that you have set up your Braze account and that you have an active Braze campaign or canvas for which you want to generate coupon codes.

note

If you're not using Braze, see the generic customer engagement platform endpoints.

Setting up your Talon.One campaign

Ensure you already have an Application set up and that it contains a running campaign.

Coupon settings

We can edit the format of the coupon codes for any campaign from the Coupon Code Generator page of that campaign.

To edit the coupon code settings:

  1. Open the campaign.
  2. Click Settings > Coupon codes.
  3. Edit the format as needed.

Authenticating

Let's create a Braze-specific API key in Talon.One:

  1. In your Talon.One Application, 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 the key for later use.

The Braze-integration coupon endpoint

To generate a coupon from Braze, we call the following endpoint:

POST coupon
https://integration.talon.one/braze/coupon
See API Docs
Getting existing coupons

You can get the details of an existing coupon by calling the same endpoint providing the Identifier value of the coupon to be retrieved.

Displaying the coupon code in Braze

To trigger the Talon.One coupon creation endpoint, we must 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.

  1. Open your Braze campaign/canvas for editing.

  2. Insert the following connected content that include authentication and the method (post) of the request that uses the Braze-specific token you generated earlier.

    Some notes about the sample:

    • To have a unique identifier for every user, we compose the identifier parameter based on user_id.
    • We save the result in a result variable.
    • Property names are case-sensitive so result.Value must be written with a capital V, according to the response of the Create coupon endpoint.
    {% assign userid = {{${user_id}}} %}
    {% assign somecampaign = {{campaign.${dispatch_id}}} %}
    {% assign unique_identifier = {{userid}} | append: {{somecampaign}} %}

    {% capture postbody %}
    {"deploymentURL": "mycompany.europe-west1.talon.one", "applicationID":316,
    "campaignID":4767, "identifier":"{{unique_identifier}}", "integrationID":"{{${user_id}}}"}
    {% endcapture %}

    {% connected_content https://integration.talon.one/braze/coupon
    :headers {
    "Authorization": "ApiKey-v1 ..."
    }
    :method post
    :body {{postbody}}
    :content_type application/json
    :save result
    %}

    Your coupon code is: {{result.Value}}
  3. Test your connected content by clicking Preview. You should see a coupon code.

Your coupon codes are now generated automatically when your campaign is running.