Email Notification App

A comprehensive email notification system with API endpoints for integration, supporting reminders, alerts, newsletters, and transactional emails.

Features

  • Multiple Notification Types: Reminders, alerts, newsletters, transactional emails
  • Dynamic Recipients: Rule-based recipient selection
  • Webhook Integration: Receive and process webhooks to trigger notifications
  • Form Submission Handling: Process form data and send notifications
  • Template System: Customizable email templates
  • Recipient Management: Store and manage recipient lists with criteria
  • API-First Design: RESTful endpoints for all operations

API Endpoints

Recipients Management

  • POST /api/recipients - Add new recipient
  • GET /api/recipients - List all recipients
  • PUT /api/recipients/:id - Update recipient
  • DELETE /api/recipients/:id - Remove recipient

Templates Management

  • POST /api/templates - Create email template
  • GET /api/templates - List all templates
  • PUT /api/templates/:id - Update template
  • DELETE /api/templates/:id - Delete template

Notifications

  • POST /api/notifications/send - Send immediate notification
  • POST /api/webhooks/notification - Webhook endpoint for triggering notifications
  • POST /api/forms/submit - Form submission endpoint

Analytics

  • GET /api/notifications/history - Get notification history
  • GET /api/notifications/stats - Get sending statistics

Project Structure

├── backend/
│   ├── database/
│   │   ├── migrations.ts    # Database schema setup
│   │   └── queries.ts       # Database query functions
│   ├── routes/
│   │   ├── recipients.ts    # Recipient management
│   │   ├── templates.ts     # Template management
│   │   ├── notifications.ts # Notification sending
│   │   ├── webhooks.ts      # Webhook handling
│   │   └── forms.ts         # Form submission handling
│   ├── services/
│   │   ├── emailService.ts  # Email sending logic
│   │   ├── recipientService.ts # Recipient filtering
│   │   └── templateService.ts  # Template processing
│   └── index.ts             # Main API server
├── shared/
│   └── types.ts             # Shared TypeScript types
└── README.md

Usage Examples

Adding Recipients

curl -X POST /api/recipients \ -H "Content-Type: application/json" \ -d '{ "email": "user@example.com", "name": "John Doe", "tags": ["premium", "newsletter"], "preferences": { "notifications": true, "newsletters": true } }'

Creating Templates

curl -X POST /api/templates \ -H "Content-Type: application/json" \ -d '{ "name": "welcome_email", "type": "transactional", "subject": "Welcome {{name}}!", "html": "<h1>Welcome {{name}}</h1><p>Thanks for joining!</p>", "text": "Welcome {{name}}! Thanks for joining!" }'

Sending Notifications

curl -X POST /api/notifications/send \ -H "Content-Type: application/json" \ -d '{ "type": "alert", "template": "system_alert", "criteria": { "tags": ["admin"], "preferences.notifications": true }, "data": { "message": "System maintenance scheduled", "time": "2024-01-15T10:00:00Z" } }'

Environment Variables

No API keys required - uses Val Town's built-in email service.