Creating a webhook to MoEngage
To make the most of Talon.One and MoEngage, you can integrate them by creating a webhook to MoEngage in Talon.One.
In this tutorial, let's create a webhook to MoEngage and create a campaign to send coupon codes on Christmas Day (25 December).
Prerequisites
- You have a MoEngage account.
- You are an Admin user in Talon.One and MoEngage.
Creating a webhook
Let's create a webhook to MoEngage
and name it Send MoEngage Email
.
Adding parameters
Add parameters for any webhook-specific data to pass to MoEngage. In our case, we want to pass the profile ID of the user and the generated coupon code, so we create the following parameters:
Param type | Param name |
---|---|
string | profileid |
string | couponcode |
Creating the request
- Set Request Verb to
POST
. - Target the relevant URL. For MoEngage, it is:
https://api-0X.moengage.com/v1/event/<APP ID>
, where0X
represents the MoEngage data center number, andAPP ID
represents the MoEngage APP ID.
- To learn about the data center number and
APP ID
, in the MoEngage documentation, see API Overview. - To learn about events, in the MoEngage documentation, see Event.
Setting the headers
Add the following mandatory HTTP request headers:
Authorization: Basic <header>
, where<header>
represents a Base64-encoded string containing the DATA API ID as username and DATA API KEY as password for all API requests.Content-Type: application/json
MOE-APPKEY: <APP ID>
, whereAPP ID
represents the MoEngage APP ID
- To generate the
<header>
string, use a public header string generator like Basic Authentication Header Generator. - To learn about DATA API ID and DATA API KEY, in the MoEngage documentation, see API Overview.
- To learn about
APP ID
, in the MoEngage documentation, see API Overview.
Creating the payload
Let's define the payload of the request using the following parameters:
{
"type": "event",
"customer_id": "${$profileid}",
"actions": [
{
"action": "Coupon code creation",
"attributes": {
"CouponCode": "${$couponcode}"
}
}
]
}
Your payload definition may vary depending on the data you dynamically populate in your MoEngage campaign content, but the same principles apply.
To learn more about accessing Talon.One attributes and including them in the webhook, see Using parameters in a webhook.
Creating a campaign for coupon creation
Let's create a standard campaign with a single rule.
Name the rule Create coupon on Xmas Day
and add one condition and two effects:
Condition
- Check attribute value:
Current time
is on exact day12/25/2022
.
Effects
- Create coupon code: In the current campaign, Recipient is Current Customer (Friend), and Redemption Limit is
100
. - Send MoEngage Email: profileId is
Integration ID(Customer Profile)
and couponCode isGenerated coupon in Session
.
Using the generated coupon code in MoEngage
The webhook configuration is now complete. You can now use the coupon code generated by Talon.One in your MoEngage campaign content.
To learn to create event-triggered campaign content, in the MoEngage documentation, see Campaigns and channels.
To verify whether MoEngage received a request, on the MoEngage dashboard, click Test & Debug > Recent events.