Award loyalty points after delivery
You can reward customers with loyalty points after their order is delivered by using advanced events and a connected session ID to reference the original purchase.
Let's imagine we run an ecommerce store and want to give customers 10% of their session total as loyalty points after their shipment arrives. For example, a $300 order earns 30 points. Our order management system (OMS) notifies Talon.One when the delivery is confirmed.
Overview
This use case requires advanced events, since the delivery confirmation arrives after the purchase session is already closed. Only advanced events can reference a closed session's data, via the connected session ID.
The flow works as follows:
- A customer completes an order. Your integration closes the customer session in Talon.One.
- You ship the order, and your order management system tracks the shipment.
- When the order is delivered, the OMS calls the Track advanced event endpoint, using the closed customer session as the connected session.
- The Rule Engine evaluates the event, reads the total of the connected session, and awards loyalty points.
Prerequisites
- You have created an Application and a campaign in Talon.One.
- You have set up a profile-based loyalty program. The loyalty program is connected to your Application.
- The Loyalty feature is enabled in your campaign.
- Your Application contains at least one closed session.
Set up the integration
Create an Integration API key
In your Application, create an Integration API key.
Ensure the Application is connected to your loyalty program.
Create the event
For this tutorial, we assume your order management system sends an event of type
orderStatusChanged and the delivery status in a deliveryStatus property.
To allow Talon.One to process this event, create an advanced event and a custom attribute:
- Click > Tools > Attributes > Create Attribute.
- In Entity, select Event.
- In Event type, enter
orderStatusChanged. - In Type, select String.
- In API name, enter
deliveryStatus. - In Name, enter
Delivery Status. - In Description, enter
The status of the delivery. - Click Create Attribute.
Create a promotion rule
Open your campaign and create a promotion rule to award points when the delivery event is received.
The rule checks for the orderStatusChanged event type and the delivery status, and awards
points based on the total of the connected session.
| What | Name | Properties |
|---|---|---|
| Conditions | Check for event types and custom event values |
|
| Effects | Add loyalty points |
|
Trigger the event
In your OMS, implement the logic to call the Track advanced
event endpoint when the OMS confirms
delivery. Include the connectedSessionId parameter to link the event to the original
purchase session.
To send a test event, use the following cURL command, where:
YOUR_DEPLOYMENT_URLis the base URL of your Talon.One deployment, for example,mycompany.europe-west1.talon.one.YOUR_API_KEYis the Integration API key you created.CUSTOMER_PROFILE_IDis the ID of an existing customer profile.EVENT_INTEGRATION_IDis a unique identifier for this event, for example,testevent1234.CLOSED_SESSION_IDis the ID of an existing closed customer session.
curl https://YOUR_DEPLOYMENT_URL/v3/events \
-X POST \
-H "Authorization: ApiKey-v1 YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"profileId": "CUSTOMER_PROFILE_ID",
"integrationId": "EVENT_INTEGRATION_ID",
"type": "orderStatusChanged",
"connectedSessionId": "CLOSED_SESSION_ID",
"attributes": {
"deliveryStatus": "delivered"
}
}'
- The session must be in the
closedstate. If the session is still open, Talon.One returns a400error. - Advanced events are idempotent. If you send the same event more than once with the same
ID, Talon.One returns a
409error.
Verify the result
After the call, Talon.One evaluates the rule and awards loyalty points to the customer profile.
You can verify this in two ways:
- In your Application, on the Customers page, open the customer profile and check the Loyalty Points tab.
- Use the Get customer's loyalty balances API endpoint.
The advanced event call is also listed in the Events page of your Application.