3rd Dec 2019

Creating coupons through Braze

This is a guide on integrating Braze with Talon.one. This guide will walk you through the Braze endpoint used to create coupons, it will also discuss the syntax required for supporting custom attributes on coupons.

Rate Limiting Recommendations

We recommend to set the "Delivery Speed Rate-Limiting" in your Braze settings to a maximum of 500 whenever you create a Braze campaign generating coupons in Talon.one. If the rate limit is increased, further coupons may not be created or may not appear correctly in the message sent through Braze.

Further information can be found here: Braze: Delivery Speed Rate-Limiting

Coupon settings

You can modify the form of coupon codes for any campaign by going to the Coupon Code Generator for that campaign (campaign -> settings -> coupon code generator)

LocationAttribute

Endpoint Usage

Because Braze-connected content only supports date type of 'string', a custom endpoint has to be used that will convert to the correct data types.

This endpoint contains the following built-in properties

(*) Required

  • applicationID (*)
  • campaignID (*)
  • identifier (*)
  • integrationID
  • startDate
  • expiryDate
  • usageLimit (is 1 by default)

The identifier is used to add flexability in the handling of duplicate requests from Braze, the recommended options are as follows;

  • message_api_id/variant_api_id - This will return unique identifiers for every testing variant within a Campaign or Canvas (lifecycle journey). By using this, Talon.One will return a new coupon per customer for every single variant within a Braze campaign, ensuring no duplicate coupons are created. Please note that you should use "message_api_id" for Campaigns while "variant_api_id" should be used for Canvases. For information on creating these types of AB and multivariate tests find Braze's documentation here.

  • campaign_id/canvas_id - This will return the unique identifier of the Campaign or Canvas itself. For Campaigns (one-off engagements) 'campaign_id' should be used, while for Canvas (lifecycle journey) 'canvas_id' should be used.

Example with only required properties

curl https://demo.talon.one/v1/braze/createcoupon \
 -X POST \
 -H 'Authorization: Bearer [sessionToken]' \ 
 -d '{
        "applicationID": "1",
        "campaignID: "1",
        "identifier": "an-example-identifier"
}'

Example with all built-in properties

curl https://demo.talon.one/v1/braze/createcoupon \
 -X POST \
 -H 'Authorization: Bearer [sessionToken]' \ 
 -d '{
        "applicationID": "1",
        "campaignID": "1",
        "identifier": "an-example-identifier",
        "integrationID": "an-example-integrationID",
        "startDate": "2019-06-12T09:00:00Z",
        "expiryDate": "2019-06-13T09:00:00Z"
}'

Custom attributes can also be passed directly. These attributes are notated with a dot prefix and must be wrapped in a string.

Example with string attribute

curl https://demo.talon.one/v1/braze/createcoupon \
 -X POST \
 -H 'Authorization: Bearer [sessionToken]' \ 
 -d '{
        "applicationID": "1",
        "campaignID": "1",
        "identifier": "an-example-identifier"
        ".stringAtrrName": "examplestring",
    }'

Example with list of numbers attribute

curl https://demo.talon.one/v1/braze/createcoupon \
 -X POST \
 -H 'Authorization: Bearer [sessionToken]' \ 
 -d '{
        "applicationID": "1",
        "campaignID": "1",
        "identifier": "an-example-identifier"
        ".listOfNumbers": "[1,2,3,4,5,6,7,8,9,10]",
    }'

Configuring Connected Content

To trigger the Talon.One coupon creation you have to use Braze's Connected Content Feature. You can use it in every campaign message body or any canvas message body.

ℹ️ The code snippet beneath these steps can be copied.

  1. Add the connected content tag to the body of your message. You can access Braze attributes by using liquid tags (e.g. {{${user_id}}} to pass the user id)

    LocationAttribute

  2. Add the URL to the createCoupon endpoint of your Talon.One deployment

    LocationAttribute

  3. Add the authorization header and the method (post) of the request. Please follow the instruction on this page to generate a session token. Additionaly you can get the token once you have admin permission in Talon by following [this instructions](.

    LocationAttribute

  4. Add the body of the request containing the coupon code specs mentioned above (The parameters are separated by an "&")

    ℹ️ the identifier attribute is necessary to prevent the creation of multiple coupons for one message

    LocationAttribute

  5. Add the "save" parameter at the end to store the Talon.One response as a Braze variable (in the below case, 'result').

    LocationAttribute

  6. Use a liquid tag to show the value of the generated code in the message. The whole response from Talon.One will look like this: {"id"=>1548040, "value"=>"44D4-U4PL", "__http_status_code__"=>200}

    LocationAttribute

  7. Testing the campaign/canvas will give you the following result:

    Coupon value only {{result.value}}:

    LocationAttribute

    Whole response {{result}}:

    LocationAttribute

Code snippet:

{% connected_content https://[YOUR_SUBDOMAIN].talon.one/v1/braze/createcoupon 

:headers {
  "authorization": "Bearer [sessionToken]"
 } 
:method post 
:body applicationID=1&campaignID=1488&identifier={{campaign.${message_api_id}}}&integrationID={{${user_id}}}
:content_type application/json 
:save result
%}

{{result.value}}

Extracting the session token

Once you are logged into your Talon.One deployment as an administrator, you can get your session token by following these steps:

  1. Open the console/developer settings of your browser
  2. Navigate to cookie storage
  3. Copy the value of the talonone-credentials cookie
  4. Paste it into an online URL decoder (example: https://meyerweb.com/eric/tools/dencoder/)

LocationAttribute

Still need help? Get in touch!
Last updated on 3rd Dec 2019

Was this article helpful?

Thank you! You have already voted

If you’d like a member of our support team to respond to you, please send a note to support@talon.one