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.
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:
- Open the campaign.
- Click Settings > Coupon codes.
- Edit the format as needed.
Authenticating
Let's create a Braze-specific API key in Talon.One:
- In your Talon.One Application, 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 the key for later use.
The Braze-integration coupon endpoint
To generate a coupon from Braze, we call the following endpoint:
https://integration.talon.one/braze/coupon
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.
Open your Braze campaign/canvas for editing.
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 onuser_id
. - We save the result in a
result
variable. - Property names are case-sensitive so
result.Value
must be written with a capitalV
, 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}}- To have a unique identifier for every user, we compose the
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.