- Create your Integration API key.
- If you haven't done so already, fork our Sample Campaigns collection in Postman:
- In the Campaign Manager, open the EASY-DISCOUNT: Always 10% off demo campaign and click Activate Campaign.
- 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 rule typically has at least one condition and one effect. The effect represents the result of the promotion campaign for individual customers.
In the current scenario, let's use one rule and name it
Always 10% off.
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.
- Set the Name to something descriptive, such as
- Set the Discount value to [Session.Total]
- Click Add an attribute ( ).
- Search for the Session Total (Current Session) attribute and select it.
- 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 mutliple it 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:
- 🚀 Request
- ✅ Response
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.
CURL -X PUT https://mycompany.europe-west1.talon.one/v2/customer_sessions/my_session_id -d
We receive this response showing our only effect in the
a 10% discount representing 10USD off the original item (10% off 100USD).
"ruleName": "Always 10% off",
"name": "10% off",
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.