Skip to main content

Always triggering a discount

Prerequisites
Before you start, ensure you:
  1. Create your Integration API key.
  2. If you haven't done so already, fork our Sample Campaigns collection in Postman: Run in Postman.
  3. In the Campaign Manager, open the EASY-DISCOUNT: Always 10% off demo campaign and click Activate Campaign.
  4. Open the Rule Builder to get some context.

Let's create a promotion rule that always provides a 10% discount to every customer.

Let's cover the logic of this campaign and trigger it with an API request to simulate what the integration layer will do.

Creating the discount promotion

The logic of a campaign is always defined by its rules. A promotion rule typically has at least one condition and one effect. The effect represents the result of the campaign for individual customers.

In the current scenario, let's use one rule and name it Always 10% off.

Condition

Talon.One offers many conditions, but in our case, we don't need any because we want to offer a discount always.

To always trigger the effects of a rule, click Always Trigger Effects. By always, Talon.One means whenever a customer updates their shopping cart, for example by adding an item.

Effect

Talon.One also offers many effects and even allows you to create your own. In this scenario, we need the Discount session total effect:

  1. Set the Name to something descriptive, such as 10% off.
  2. Set the Discount value to [Session.Total]*10%:
    1. Click Add an attribute ( Plus sign. ).
    2. Search for the Session Total (Current Session) attribute and select it.
    3. Back in the Discount value field, type * 10% to complete the discount value.

In our case, we calculate the discount value using an attribute. Attributes represent any data stored inside Talon.One. Attributes can be calculated by Talon.One, like a session value, or can come from the integration layer.

The session total attribute represents the value of the shopping cart for any session. We multiply this by 10% to discount it.

Running the campaign

To run the campaign, use the following payload sent to the Integration API's Update customer session endpoint:

We can send any session update. The rule will always trigger. In this case, we share a session that contains one cart item. It is defined in the cartItems array on line 6.

Sending a session update
CURL -X PUT https://mycompany.europe-west1.talon.one/v2/customer_sessions/my_session_id -d
'{
"customerSession": {
"profileId": "TN6329YKC8",
"state": "closed",
"cartItems": [
{
"name": "ProductA",
"sku": "sku-00001",
"quantity": 1,
"price": 100,
"Category": "",
"weight": 0,
"position": 0,
"attributes": {}
}
],
"couponCodes": [""],
"referralCode": "",
"attributes": {},
"additionalCosts": {}
},
"responseContent": []
}'
Key Takeaways
  • Promotion rules are defined by conditions and effects.

    • A condition is what triggers a promotion, such as a customer created their account.
    • An effect is what your promotion does, for example discounting a session, giving loyalty points, etc. See effects.
  • You can use attributes in your effects to operate on data inside Talon.One.

  • The value of the shopping cart is represented by the Session Total attribute.

  • Trigger the rules by sending a session that satisfies the rule's conditions.

  • Send a session update with the Update customer session endpoint.