Nudge Webhook
Send the nudge payload (similar to rewards) to your servers in case of not configuring direct nudges from CustomerGlu to End User Device using Firebase/APNS
A webhook url can be provided to CustomerGlu to receive the nudges to be shown to users in real-time
The app can be configured to open the url present in "clickAction" property in a webview.
A POST request will be made to the specified Webhook URL . Example request body is as follows:
{
"client":"xyzc-b2e0-4927-8653-cba2babc2",
"campaignId":"acxscx26-5437-4b37-855f-a3f6edqccqc4",
"userId":"glutest-1",
"notificationType":"push",
"pageType":"full-default",
"content":{
"button":{
"text":"Go to Reward",
"action":"https://xyz.customerglu.net"
},
"title":"Scratch card unlocked! 😍",
"body":"Check to see how much you've won 🙌",
"clickAction":"https://xyz.customerglu.net",
"image":""
},
"timeRemaning":"",
"expiry":""
}
Optionally, to verify the authenticity of request, a secret token can be provided to CustomerGlu.
When you set a token, you'll receive the X-CG-SIGNATURE
header in the webhook POST
request. value of this header will be a hmac hexdigest of the request body with the provided token. See on how to validate the requests
Validating Nudge Webhook
const verifySignature = (reqBodyDigest, cgHeader) => {
return crypto.timingSafeEqual(Buffer.from(cgHeader), Buffer.from(`${reqBodyDigest}`));
}
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/hook', (req, res) => {
const jsonString = JSON.stringify(req.body);
const reqBodyDigest = crypto.createHmac('sha1', token)
.update(jsonString)
.digest('hex');
const cgHeader = req.headers['x-cg-signature'];
const verify = verifySignature(reqBodyDigest, cgHeader)
}
Last updated
Was this helpful?