Skip to main content
When users earn rewards in Nudj, they expect those rewards to appear in their existing wallets and loyalty systems. This guide covers how to connect Nudj’s reward system with your external infrastructure for seamless reward delivery.
Quick Decision: Have an existing loyalty system? Use API Integration. Need real-time notifications? Use Webhooks. Building something custom? Use Direct Integration.

Reward Delivery Methods

Webhook Integration

Best for: Real-time notifications, event-driven systemsPros: Instant delivery, reliable processing, automatic retriesCons: Requires endpoint setup, security considerations

API Integration

Best for: Existing loyalty systems, scheduled processingPros: Full control, batch processing, error handlingCons: Polling required, potential delays

Direct Integration

Best for: Custom systems, specialized requirementsPros: Maximum flexibility, custom logic, deep integrationCons: Complex setup, maintenance overhead

Understanding Nudj Rewards

  • Reward Types
Two main categories of rewards in Nudj:
Direct rewards that users receive immediately:
  • Points/Currency: Loyalty points, credits, tokens
  • Digital Items: Coupons, discount codes, digital content
  • Physical Items: Merchandise, gift cards (requires fulfillment)
  • Access Rights: Premium features, exclusive content
{
  "type": "asset",
  "reward": {
    "id": "reward_123",
    "name": "10% Discount Code",
    "type": "digital_coupon",
    "value": "SAVE10",
    "description": "10% off your next purchase"
  }
}
Competition entries that give users chances to win:
  • Prize Draws: Monthly competitions, grand prizes
  • Instant Win: Scratch cards, spin-to-win mechanics
  • Tiered Competitions: Multiple prize levels
  • Limited Availability: First-come-first-served rewards
{
  "type": "entry",
  "reward": {
    "id": "entry_456",
    "name": "Monthly Prize Draw Entry",
    "competition_id": "comp_789",
    "draw_date": "2024-03-01T00:00:00Z",
    "prize_description": "£500 Shopping Voucher"
  }
}

Webhook Integration

Real-time reward delivery using webhooks for immediate processing when users earn rewards.

Implementation Guide

1

Set Up Webhook Endpoint

Create a secure endpoint to receive reward notifications:
app.post('/webhooks/nudj/rewards', (req, res) => {
  // Verify webhook signature
  const signature = req.headers['x-nudj-signature'];
  if (!verifySignature(req.body, signature)) {
    return res.status(401).json({ error: 'Invalid signature' });
  }
  
  // Process reward
  processReward(req.body)
    .then(() => res.status(200).json({ success: true }))
    .catch(error => res.status(500).json({ error: 'Processing failed' }));
});
2

Configure Webhook in Nudj

Set up the webhook configuration in your Nudj admin panel:
{
  "webhook_config": {
    "url": "https://your-api.com/webhooks/nudj/rewards",
    "events": [
      "reward.earned",
      "reward.delivered",
      "reward.failed"
    ],
    "authentication": {
      "type": "hmac_sha256",
      "secret": "your-webhook-secret"
    }
  }
}

Real-World Integration Examples

  • Mobile App Wallet (Tesco-style)
  • E-commerce Loyalty Integration
Integration with mobile app loyalty systems:
async function handleMobileWalletDelivery(user, reward) {
  // Add points to mobile wallet
  const walletResult = await mobileWalletAPI.creditAccount({
    customer_id: user.external_id,
    amount: reward.value,
    currency: reward.currency,
    transaction_type: 'engagement_reward'
  });
  
  // Trigger push notification
  await pushNotificationService.send({
    device_tokens: user.device_tokens,
    notification: {
      title: 'Reward Earned!',
      body: `${reward.value} points added to your wallet`
    }
  });
}

API Integration

Pull-based integration where your system periodically retrieves earned rewards from Nudj APIs.

Implementation Guide

1

Set Up API Credentials

Configure API access for retrieving rewards:
NUDJ_API_BASE_URL=https://your-company.nudj.cx/api
NUDJ_API_TOKEN=your-api-token
2

Implement Reward Polling

Create a service to regularly check for new rewards:
async function pollForRewards() {
  const response = await this.apiClient.get('/rewards/pending', {
    params: {
      since: this.lastProcessedTimestamp,
      limit: 100,
      status: 'pending_delivery'
    }
  });
  
  const rewards = response.data.rewards;
  console.log(`Found ${rewards.length} pending rewards`);
  
  for (const reward of rewards) {
    await this.processReward(reward);
  }
}

Next Steps

I