Appearance
Core Concepts
Understanding these core concepts will help you get the most out of Nexus and build powerful notification systems.
Organizations
Organizations are the top-level entity in Nexus. They represent your company or project and contain all your notification infrastructure.
typescript
{
id: "org_123",
name: "Acme Corporation",
apiKeys: ["sk_live_...", "sk_test_..."],
createdAt: "2024-01-01T00:00:00Z"
}Key Features:
- API Keys: Each organization has unique API keys for authentication
- Team Management: Invite team members with different permission levels
- Billing: Usage and billing are tracked at the organization level
- Settings: Global settings that apply to all environments
Environments
Environments allow you to separate your notification infrastructure between development, staging, and production.
typescript
{
id: "env_123",
organizationId: "org_123",
name: "production",
type: "PRODUCTION",
apiKey: "sk_live_..."
}Environment Types:
- Development: For local development and testing
- Staging: For pre-production testing
- Production: For live, customer-facing notifications
Benefits:
- Isolation: Each environment is completely isolated
- Testing: Test workflows without affecting production
- Configuration: Different provider settings per environment
Subscribers
Subscribers represent the recipients of your notifications. They can be users, customers, or any entity that receives notifications.
typescript
const subscriber = await nexus.subscribers.create({
subscriberId: 'user_123',
email: '[email protected]',
firstName: 'John',
lastName: 'Doe',
phone: '+1234567890',
data: {
plan: 'premium',
signupDate: '2024-01-01'
}
})python
subscriber = nexus.subscribers.create(
subscriber_id='user_123',
email='[email protected]',
first_name='John',
last_name='Doe',
phone='+1234567890',
data={
'plan': 'premium',
'signup_date': '2024-01-01'
}
)bash
curl -X POST https://api.nexus.dev/v1/subscribers \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"subscriberId": "user_123",
"email": "[email protected]",
"firstName": "John",
"lastName": "Doe",
"phone": "+1234567890",
"data": {
"plan": "premium",
"signupDate": "2024-01-01"
}
}'Subscriber Properties:
- subscriberId: Your unique identifier for the subscriber
- email: Email address for email notifications
- phone: Phone number for SMS notifications
- pushTokens: Device tokens for push notifications
- data: Custom data for template personalization
Workflows
Workflows define the notification flow and logic. They determine what notifications to send, when to send them, and through which channels.
typescript
{
id: "workflow_123",
name: "User Onboarding",
trigger: "user-signup",
steps: [
{
type: "email",
template: "welcome-email",
delay: 0
},
{
type: "delay",
duration: "1 day"
},
{
type: "email",
template: "onboarding-tips",
conditions: {
subscriber: {
data: {
plan: "free"
}
}
}
}
]
}Workflow Components:
1. Triggers
Events that start a workflow:
- API trigger
- Scheduled trigger
- Webhook trigger
2. Steps
Actions within a workflow:
- Channel Steps: Send notifications (email, SMS, push, etc.)
- Delay Steps: Wait before proceeding
- Digest Steps: Batch multiple events
- Filter Steps: Conditional logic
3. Conditions
Control flow based on:
- Subscriber properties
- Event payload data
- Time-based rules
- Previous step results
Templates
Templates define the content and design of your notifications. They support variables for personalization.
Email Templates
html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to {{company.name}}!</title>
</head>
<body>
<h1>Hi {{subscriber.firstName}},</h1>
<p>Welcome to {{company.name}}! Your {{payload.plan}} plan is now active.</p>
<a href="{{company.appUrl}}/get-started">Get Started</a>
</body>
</html>Template Variables
Variables use double curly braces and can access:
- subscriber: Subscriber properties
- payload: Event-specific data
- company: Default company variables
- step: Step-specific variables
Channels
Nexus supports multiple notification channels:
📧 Email
- Rich HTML emails
- Plain text fallback
- Attachments support
- Open/click tracking
📱 SMS
- Global delivery
- Unicode support
- Delivery reports
- Two-way messaging
🔔 Push
- Web push (PWA)
- Mobile push (iOS/Android)
- Rich notifications
- Deep linking
💬 In-App
- Real-time delivery
- Widget integration
- Action buttons
- Read receipts
💬 Chat
- Slack integration
- Microsoft Teams
- Discord
- Custom webhooks
🔗 Webhooks
- HTTP POST requests
- Custom headers
- Retry logic
- Response handling
Providers
Providers are the services that actually deliver your notifications. Nexus integrates with multiple providers per channel.
Email Providers
- SendGrid
- AWS SES
- Postmark
- Mailgun
- SMTP
SMS Providers
- Twilio
- AWS SNS
- Vonage
- MessageBird
Push Providers
- FCM (Firebase)
- APNS (Apple)
- Web Push API
Benefits of Multiple Providers:
- Failover: Automatic fallback if a provider fails
- Load Balancing: Distribute load across providers
- Cost Optimization: Route based on pricing
- Regional Routing: Use local providers for better delivery
Events
Events trigger workflows and carry the data needed for notifications.
typescript
// Trigger an event
await nexus.events.trigger('order-shipped', {
to: 'user_123',
payload: {
orderId: '12345',
trackingNumber: 'TRK-789',
carrier: 'FedEx',
estimatedDelivery: '2024-01-15',
items: [
{ name: 'T-Shirt', quantity: 2 },
{ name: 'Jeans', quantity: 1 }
]
}
})python
# Trigger an event
nexus.events.trigger(
'order-shipped',
to='user_123',
payload={
'orderId': '12345',
'trackingNumber': 'TRK-789',
'carrier': 'FedEx',
'estimatedDelivery': '2024-01-15',
'items': [
{'name': 'T-Shirt', 'quantity': 2},
{'name': 'Jeans', 'quantity': 1}
]
}
)Event Properties:
- name: Identifies which workflow to trigger
- to: Subscriber or list of subscribers
- payload: Custom data for the notification
- overrides: Override workflow settings
Topics
Topics allow you to send notifications to groups of subscribers without managing individual subscriptions.
typescript
// Create a topic
await nexus.topics.create({
key: 'product-updates',
name: 'Product Updates'
})
// Add subscribers to topic
await nexus.topics.addSubscribers('product-updates', {
subscribers: ['user_123', 'user_456', 'user_789']
})
// Send to all topic subscribers
await nexus.events.trigger('new-feature', {
to: { type: 'topic', topicKey: 'product-updates' },
payload: { feature: 'Dark Mode' }
})Preferences
Allow subscribers to control which notifications they receive and how they receive them.
typescript
// Update subscriber preferences
await nexus.subscribers.updatePreferences('user_123', {
channels: {
email: true,
sms: false,
push: true,
inApp: true
},
categories: {
marketing: false,
transactional: true,
updates: true
}
})Activity Feed
Track all notification activity for debugging and analytics.
typescript
// Get subscriber's notification history
const activities = await nexus.activities.list({
subscriberId: 'user_123',
channel: 'email',
status: 'delivered'
})Activity States:
- triggered: Event was triggered
- processed: Workflow processing started
- sent: Notification sent to provider
- delivered: Provider confirmed delivery
- read: Subscriber opened/read notification
- failed: Delivery failed
Best Practices
1. Use Meaningful IDs
typescript
// Good
subscriberId: 'user_123'
workflowId: 'order-confirmation'
// Avoid
subscriberId: '1'
workflowId: 'wf1'2. Structure Your Payload
typescript
// Good - Structured and typed
payload: {
order: {
id: '12345',
total: 99.99,
currency: 'USD'
},
customer: {
name: 'John Doe',
tier: 'premium'
}
}
// Avoid - Flat and untyped
payload: {
orderId: '12345',
total: 99.99,
customerName: 'John Doe'
}3. Handle Failures Gracefully
typescript
try {
await nexus.events.trigger('welcome-email', {
to: 'user_123',
payload: { ... }
})
} catch (error) {
// Log error but don't block user flow
console.error('Notification failed:', error)
// Continue with application logic
}4. Use Environments Properly
- Development: Test new workflows
- Staging: Validate with production-like data
- Production: Only tested, working workflows
5. Respect User Preferences
Always check and honor subscriber preferences before sending non-transactional notifications.
Next Steps
Now that you understand the core concepts: