Sending coupons via CleverTap
In this tutorial, let's set up Talon.One to automatically generate coupons and send them via CleverTap.
Let's imagine you want to email a coupon code to every customer who spends $200 or more on their order.
To do so, we rely on Talon.One's webhook functionality and CleverTap's Upload Events endpoint.
Talon.One requirements
- You are an Admin user.
- You have set up an Application.
- Your Application contains a running campaign with the Coupons feature enabled.
CleverTap requirements
- You have set up your CleverTap account.
- You are an Admin user.
- You have configured an email provider in CleverTap and tested it.
Creating and sending the coupon code
In the sections below, we create a workflow that includes the following steps:
- Closing a customer session with a cart item value of $200 or more creates a coupon code and triggers a custom webhook in Talon.One.
- The webhook calls CleverTap's Upload Events endpoint, providing the coupon code and a customer profile ID.
- Registering the event triggers a campaign in CleverTap.
- The campaign sends an email with the provided coupon code to the customer with the provided profile ID.
Creating the webhook in Talon.One
To create a webhook that calls CleverTap's Upload Events:
-
In the Campaign Manager, click Account > Tools > Webhooks and click Create Webhook.
-
In Properties, enter a name and select your Application.
-
Add the parameters to include in the request. In this tutorial, we'll use the following parameters:
Param type Param name string
CouponCode
string
CustomerProfileID
-
In Request, set Verb to
POST
. -
In URL, enter
https://<YOUR_REGION>.api.clevertap.com/1/upload
, whereYOUR_REGION
is your region key, for example,us1
. -
In Headers, click Add and define the following HTTP headers:
X-CleverTap-Account-Id: <YOUR_PROJECT_ID>
, whereYOUR_PROJECT_ID
is your Project ID in CleverTap.X-CleverTap-Passcode: <YOUR_PROJECT_PASSCODE>
, whereYOUR_PROJECT_PASSCODE
is your Passcode in CleverTap.Content-Type: application/json; charset=utf-8
-
In Payload, add the following request payload:
{
"d": [
{
"type": "event",
"evtName": "Coupon Generated",
"$source": "Talon.One",
"identity": "${$CustomerProfileID}",
"evtData": {
"CouponCode": "${$CouponCode}"
}
}
]
}noteTo learn more about accessing Talon.One attributes and including them in the webhook, see Using parameters in a webhook.
-
In Preview, click Copy.
-
Click Create Webhook.
-
Paste and run the copied
curl
command in your terminal.
This calls the endpoint with placeholder data, which creates a custom event namedCoupon Generated
in CleverTap. The event is required to create the campaign.
Creating the campaign in CleverTap
To create an email campaign that can be triggered by our webhook:
- In CleverTap, in the sidebar, open Campaigns.
- Click + Campaign > Email.
- In Name, type a name for your campaign.
- In Start here > Qualification criteria, select Live behavior and click Done.
- In Email Service Provider, select the email provider you configured and click Done.
- In Set a goal, click Done.
- In Who > Target Segment > As soon as user does, select the name of the event you created (Coupon Generated, in our case) and click Done.
- In Control group and target segment cap, click Done.
- In What, select Single Message and click Go To Editor.
- Select a template and personalize your message in the message editor.
- In the email body, type @ and select the desired custom event property
(@Coupon Generated - CouponCode, in our case). Replace
[default value]
with a default value for the coupon code, for example,[DISCOUNT10]
. - In Sender Details, fill in the sender information as required and click Done.
- In When > Date and time, click Done.
- In Delivery preferences, click Done.
- Click Publish Campaign.
Creating the rule
Now, let's bring it all together by creating a rule in Talon.One that generates the coupon code and triggers the webhook:
What | Name | Properties |
---|---|---|
Condition 1 | Check attribute value | Session Total (Current Session) is greater than or equal to 200 . |
Condition 2 | Check for event types and custom event values | Event type is Customer Session Closing . |
Effect 1 | Create coupon code |
|
Effect 2 | Webhooks |
|
Testing the setup
Let's test our setup by simulating a purchase with a high cart item value.
-
Send the following payload to the Update customer session endpoint, where
YOUR_PROFILE_ID
refers to a customer identity in CleverTap. For testing, provide an email address to send the email to, for example,john@doe.com
.{
"customerSession": {
"profileId": "YOUR_PROFILE_ID",
"state": "open",
"cartItems": [
{
"name": "Fine woven scarf",
"sku": "SCARF123",
"quantity": 1,
"price": 249.99
}
]
}
} -
Send the payload again with the
state
property set toclosed
.
The session is now closed, with a cart item value greater than $200. This triggers our rule.
The rule calls CleverTap's API endpoint using the webhook, which in turn activates the campaign and sends an email to the provided profile ID.