Skip to main content

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:

  1. A customer completes an order. Your integration closes the customer session in Talon.One.
  2. You ship the order, and your order management system tracks the shipment.
  3. When the order is delivered, the OMS calls the Track advanced event endpoint, using the closed customer session as the connected session.
  4. The Rule Engine evaluates the event, reads the total of the connected session, and awards loyalty points.

Prerequisites

Set up the integration

1

Create an Integration API key

In your Application, create an Integration API key.

important

Ensure the Application is connected to your loyalty program.

2

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:

  1. Click > Tools > Attributes > Create Attribute.
  2. In Entity, select Event.
  3. In Event type, enter orderStatusChanged.
  4. In Type, select String.
  5. In API name, enter deliveryStatus.
  6. In Name, enter Delivery Status.
  7. In Description, enter The status of the delivery.
  8. Click Create Attribute.
3

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.

WhatNameProperties
ConditionsCheck for event types
and custom event values
  • Event type: orderStatusChanged
  • Delivery Status (Event) is equal to delivered
EffectsAdd loyalty points
  • Loyalty program: Select your loyalty program.
  • Recipient: Current Customer (Friend)
  • Reason: Delivery reward
  • Amount of points: [AdvancedEvent.ConnectedSession.Total]*10%
4

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_URL is the base URL of your Talon.One deployment, for example, mycompany.europe-west1.talon.one.
  • YOUR_API_KEY is the Integration API key you created.
  • CUSTOMER_PROFILE_ID is the ID of an existing customer profile.
  • EVENT_INTEGRATION_ID is a unique identifier for this event, for example, testevent1234.
  • CLOSED_SESSION_ID is 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"
}
}'
note
  • The session must be in the closed state. If the session is still open, Talon.One returns a 400 error.
  • Advanced events are idempotent. If you send the same event more than once with the same ID, Talon.One returns a 409 error.
5

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:

The advanced event call is also listed in the Events page of your Application.