Spend 1 point as 1 dollar
Prerequisites
- 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 MEDIUM-LOYALTY: Spend 1 point as 1$ demo campaign and click Activate Campaign.
- Open the Rule Builder to get some context.
Let's create a promotion rule that allows customers to pay using the points they collected. One point should equal one dollar.
Creating the coupon promotion
In the current scenario, let's use one rule and name it 1 point = $1
.
Condition
We want the rule to redeem points when they are used, meaning when the customer has paid for the order. This is represented by a closed session in Talon.One.
- Click Add condition and select Check for event type and validate custom event values.
- Select Customer Session Closing.
Effects
The logic of the rule relies on two effects:
- Setting the value of a point via a discount effect.
- Redeeming points when they are used.
We have to know how many points each customer wants to use. For this, we assume that your shop system has a way for the customers to input how many points they want to use as they are about to place their order.
This number of points must be communicated to Talon.One, and we do this with a custom attribute called DEMO Points to spend (Current Session). This custom attribute was created for the purpose of the demo. Attributes are set during the request to the Update customer session endpoint.
Let's set the Set discount effect, which sets the value of a point:
- Set Discount name to
Spending loyalty points
. - Set Discount value to [Session.Attributes.PointsToSpend]. In other words, the discount itself is the number of points used. So for example: 12 points is a discount of $12.
The next effect redeems points as they are used by the customer:
- Set Loyalty program to Sample Wallet, which is provided in the Demo deployment.
- Set Recipient to Current Customer.
- Set Reason to
Spending loyalty points
to identify why points were deducted. - Set Amount of point to [Session.Attributes.PointsToSpend].
Running the campaign
To run the campaign, use the following payload sent to the Integration API's Update customer session endpoint:
- 🚀 Request
- ✅ Response
To trigger the rule, we must:
- Line 5: Send a session with a
closed
state - Line 23: Set a value for the [Session.Attributes.PointsToSpend] attribute.
CURL -X PUT https://mycompany.europe-west1.talon.one/v2/customer_sessions/my_session_id -d
'{
"customerSession": {
"profileId": "{{Integration_id}}",
"state": "closed",
"cartItems": [
{
"name": "ProductC",
"sku": "sku-00004",
"quantity": 1,
"price": 200,
"Category": "",
"weight": 0,
"position": 0,
"attributes": {}
}
],
"couponCodes": [
""
],
"referralCode": "",
"attributes": {
"PointsToSpend": 50
},
"additionalCosts": {}
},
"responseContent": []
}'
We receive this response, which shows our effects in the effects
array:
- Line 15:
deductLoyaltyPoints
represents how many points were redeemed, in our case50
. - Line 28:
setDiscount
represents the value of the discount, which is also50
to match our 1:1 point-to-dollar ratio.
{
"createdCoupons": [],
"createdReferrals": [],
"effects": [
{
"campaignId": 5,
"rulesetId": 19,
"ruleIndex": 0,
"ruleName": "1 point = $1",
"effectType": "deductLoyaltyPoints",
"props": {
"ruleTitle": "1 point = $1",
"programId": 1,
"subLedgerId": "",
"value": 50,
"transactionUUID": "6c629d3b-aea0-4e08-92e1-c278fa11176f",
"name": "Spending loyalty points"
}
},
{
"campaignId": 5,
"rulesetId": 19,
"ruleIndex": 0,
"ruleName": "1 point = $1",
"effectType": "setDiscount",
"props": {
"name": "Spending loyalty points",
"value": 50
}
}
]
}
- You can redeem or deduct loyalty points with the Redeem loyalty points effect.
- To set the value of a loyalty point, use a discount effect and use an attribute related to points in the Discount value field.
- Attributes, custom or not, are set in the Update customer session requests.