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 the Create coupons endpoint for Braze that will generate coupons, and we'll send requests to it from Braze through the Connected Content feature.

Talon.One requirements

You can edit the default format of the coupon codes in the campaign's Settings section.

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'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. In your Application, click Settings > Integration API Keys.

  2. Click Create API Key.

  3. In the Create API Key drawer, select Production as the key type.

  4. In Key name, type a name to identify the key.

  5. In Key expiration date, select a date.

  6. In Third-party integration, select Yes.

  7. From Platform, select Braze.

  8. Click Create API Key.

  9. Click to copy the key for use.

    note

    You 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 coupon code

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

POST Create coupon
https://integration.talon.one/braze/coupon

See API Docs

To trigger the endpoint, we must use Braze's Connected Content feature.

important

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.

  1. Open your Braze campaign or canvas for editing.

  2. Add the following Connected Content call to the body of your message, where:

    • YOUR_DEPLOYMENT_URL is the base URL of your Talon.One deployment.
    • YOUR_APPLICATION_ID is the ID of your Application in Talon.One.
    • YOUR_CAMPAIGN_ID is the ID of your campaign in Talon.One.
    • YOUR_API_KEY is the API key you created.
    {% capture postbody %}
    {"deploymentUrl": "YOUR_DEPLOYMENT_URL", "applicationId":YOUR_APPLICATION_ID,
    "campaignId":YOUR_CAMPAIGN_ID, "identifier":"{{ 'now' | date: '%Y-%m-%d %H:%M:%S.%N' }}", "integrationId":"{{${user_id}}}"}
    {% endcapture %}

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

    Your coupon code is: {{result.Value}}
    note
    • In the example above, we use a timestamp for the identifier parameter. This ensures that a new coupon code is generated for each email during testing. In production, consider using one of the available personalization tags, for example, the dispatch ID.
    • result.Value must be written with a capital V, according to the response of the Create coupon endpoint.
  3. To test your request:

    1. In the sidebar, click Preview & Test.
    2. In Preview message as user, select Search User and search for an existing user in Braze.
      You should see a coupon code.

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

Customizing the coupon call

You can customize the Braze call with the following form.

note

This form does not cover all the available options for creating coupon codes. See the API docs for an exhaustive list.