6.9 KiB
Novu Cloud Integration Setup Guide
This guide will help you set up and configure Novu Cloud for the ThrillWiki notification system.
Overview
The notification system uses Novu Cloud for managing multi-channel notifications including:
- In-app notifications
- Email notifications
- Push notifications
- SMS notifications (planned)
Prerequisites
- A Novu Cloud account (sign up at https://novu.co)
- Access to the Supabase project
- Environment variable configuration access
Step 1: Create a Novu Cloud Account
- Go to https://novu.co and sign up
- Create a new application in the Novu dashboard
- Note down your Application Identifier from the Settings page
Step 2: Configure Environment Variables
Add the following environment variables to your .env file:
# Novu Configuration
VITE_NOVU_APPLICATION_IDENTIFIER="your-app-identifier"
VITE_NOVU_SOCKET_URL="wss://ws.novu.co"
VITE_NOVU_API_URL="https://api.novu.co"
Step 3: Add Novu API Key to Supabase Secrets
The Novu API key needs to be stored as a Supabase secret (already done via the setup):
- Go to your Novu dashboard
- Navigate to Settings > API Keys
- Copy your API Key
- The secret
NOVU_API_KEYshould already be configured in Supabase
Step 4: Create Novu Workflows
Create the following workflows in your Novu dashboard to match the templates in the database:
1. Review Reply (review-reply)
Trigger Identifier: review-reply
Channels: Email, In-App
Payload Variables:
reviewTitle- Title of the reviewreplyAuthor- Name of the person who repliedreplyContent- Content of the replyreviewUrl- Link to the review
2. New Follower (new-follower)
Trigger Identifier: new-follower
Channels: Email, In-App, Push
Payload Variables:
followerName- Name of the new followerfollowerProfile- Link to the follower's profile
3. System Announcement (system-announcement)
Trigger Identifier: system-announcement
Channels: Email, In-App, Push
Payload Variables:
title- Announcement titlecontent- Announcement contentpriority- Priority level (info, warning, critical)
4. Weekly Digest (weekly-digest)
Trigger Identifier: weekly-digest
Channels: Email
Payload Variables:
userName- User's nameweekStart- Start date of the weekweekEnd- End date of the weekstats- Activity statistics objecthighlights- Array of highlighted content
5. Monthly Digest (monthly-digest)
Trigger Identifier: monthly-digest
Channels: Email
Payload Variables:
userName- User's namemonth- Month namestats- Monthly statistics objecttopContent- Array of popular content
6. Moderation Alert (moderation-alert)
Trigger Identifier: moderation-alert
Channels: Email, In-App
Payload Variables:
itemType- Type of content (review, photo, etc.)itemId- ID of the itemsubmitterName- Name of the submittermoderationUrl- Link to moderation queue
7. Content Approved (content-approved)
Trigger Identifier: content-approved
Channels: Email, In-App
Payload Variables:
contentType- Type of contentcontentTitle- Title/name of contentcontentUrl- Link to the approved content
8. Content Rejected (content-rejected)
Trigger Identifier: content-rejected
Channels: Email, In-App
Payload Variables:
contentType- Type of contentcontentTitle- Title/name of contentrejectionReason- Reason for rejection
Step 5: Configure Webhook (Optional)
To track notification delivery status:
- Go to Novu Dashboard > Settings > Webhooks
- Add a new webhook endpoint:
https://ydvtmnrszybqnbcqbdcy.supabase.co/functions/v1/novu-webhook - Select events:
notification.sent,notification.delivered,notification.read,notification.failed
Step 6: Test the Integration
Run these tests to ensure everything works:
Test Subscriber Creation
import { notificationService } from '@/lib/notificationService';
await notificationService.createSubscriber({
subscriberId: 'user-id',
email: 'user@example.com',
firstName: 'John',
lastName: 'Doe',
});
Test Notification Trigger
import { notificationService } from '@/lib/notificationService';
await notificationService.trigger({
workflowId: 'review-reply',
subscriberId: 'user-id',
payload: {
reviewTitle: 'Great ride!',
replyAuthor: 'Jane Doe',
replyContent: 'Thanks for the review!',
reviewUrl: 'https://example.com/review/123',
},
});
Architecture
Database Tables
- notification_templates - Stores workflow configuration
- notification_logs - Tracks sent notifications
- notification_channels - Manages available channels
- user_notification_preferences - User preferences and Novu subscriber mapping
Edge Functions
- create-novu-subscriber - Creates/updates Novu subscribers
- update-novu-preferences - Syncs preferences with Novu
- trigger-notification - Triggers notification workflows
- novu-webhook - Handles Novu webhook events
Frontend Components
- NotificationsTab - User preferences management
- NotificationCenter - In-app notification display
- notificationService - Core notification logic
Switching to Self-Hosted Novu
To switch to a self-hosted Novu instance:
- Update environment variables:
VITE_NOVU_SOCKET_URL="wss://your-novu-instance.com"
VITE_NOVU_API_URL="https://your-novu-instance.com/api"
-
Update the Novu API key in Supabase secrets to match your self-hosted instance
-
No code changes required! The system is designed to work with both Cloud and self-hosted versions
Troubleshooting
Notifications Not Sending
- Check that
VITE_NOVU_APPLICATION_IDENTIFIERis set - Verify
NOVU_API_KEYis configured in Supabase secrets - Check edge function logs: https://supabase.com/dashboard/project/ydvtmnrszybqnbcqbdcy/functions
- Verify workflow IDs match between database and Novu dashboard
User Not Receiving Notifications
- Check user's notification preferences in the database
- Verify subscriber was created in Novu
- Check notification logs table for delivery status
- Verify user's email/push permission settings
Webhook Not Working
- Verify webhook URL is correct in Novu dashboard
- Check that
novu-webhookedge function hasverify_jwt = false - Review edge function logs for errors
Monitoring
Track notification performance:
- View delivery rates in
notification_logstable - Monitor edge function logs for errors
- Check Novu dashboard analytics
- Query notification statistics:
SELECT
status,
COUNT(*) as count,
AVG(EXTRACT(EPOCH FROM (delivered_at - created_at))) as avg_delivery_time_seconds
FROM notification_logs
WHERE created_at > NOW() - INTERVAL '7 days'
GROUP BY status;
Support
- Novu Documentation: https://docs.novu.co
- Novu Discord: https://discord.gg/novu
- ThrillWiki Support: [Add support contact]