Skip to main content

Introduction

Trigger automated notifications and messages based on system events.

🎯 What does this module do?

The Events module lets you set up automated notifications that trigger when something happens in your system - like sending an email when a product is back in stock, or a push notification when an order ships.

Think of it as your notification automation system - you define the trigger (what happens) and the action (who gets notified and how).

📖 Simple Explanation

Imagine you're running an online store and want to keep users informed:

  • 📦 Order placed → Send confirmation email
  • 🚚 Order shipped → Send push notification with tracking
  • Product back in stock → Notify users who requested alerts
  • 💳 Payment received → Send receipt email
  • 🎉 New promotion → Send marketing email to subscribers
  • ⚠️ Password changed → Send security alert

Instead of manually coding each notification:

  • ✅ Configure events in OneEntry admin panel
  • ✅ Define triggers (what happens)
  • ✅ Set up actions (notifications to send)
  • ✅ Customize messages per event
  • ✅ Track delivery and engagement

Real-world example:

Without Events Module (manual):
- User registers → Write code to send email ❌
- Product restocked → Write code to notify users ❌
- Each event needs custom code ❌

With Events Module (automated):
- Configure "User Registered" event → Auto sends welcome email ✅
- Configure "Product Restocked" event → Auto notifies waitlist ✅
- All events managed in one place ✅

✨ Key Concepts

What is an Event?

An event is something that happens in your system that can trigger notifications:

  • Trigger - The action that starts the event (e.g., "order placed")
  • Notification - What users receive (email, push, socket message)
  • Recipients - Who gets notified (specific users, all users, admins)
  • Template - The message content

Event Types

OneEntry supports different trigger types:

Trigger TypeWhen It FiresExample
Status ChangeEntity status changesProduct: Out of Stock → In Stock
Entity CreatedNew item addedNew order, new user registration
Entity UpdatedItem modifiedProfile updated, order status changed
Custom TriggerManual trigger from codeNewsletter sent, promo started

Notification Channels

Three ways to notify users:

ChannelDescriptionBest For
EmailSend email messagesOrder confirmations, receipts, newsletters
Push NotificationMobile/browser alertsReal-time updates, urgent alerts
Socket.IOReal-time websocket messagesLive updates, chat, instant sync

Event Flow

1. Something happens (Trigger)

2. Event detects the trigger

3. Event checks conditions (if any)

4. Event sends notifications

5. Users receive message

📋 What You Need to Know

Common Event Triggers

Typical events you might set up:

E-commerce:

  • Order placed
  • Order shipped
  • Order delivered
  • Payment received
  • Product back in stock
  • Price drop alert

User Management:

  • User registered
  • Email verified
  • Password changed
  • Profile updated
  • Account deleted

Content:

  • New article published
  • Comment added
  • Content approved
  • Subscription renewed

Template Variables

Use placeholders in notification templates


📊 Quick Reference Table - Common Methods

MethodWhat It Does
getAllSubscriptions()Get all subscriptions
subscribeByMarker()Subscribe to specific event by marker
unsubscribeByMarker()Unsubscribe from specific event by marker

Note: Events are configured in OneEntry admin panel. The SDK is read-only - use it to fetch event info, not create events.


❓ Common Questions (FAQ)

How do I create or edit events?

Events are managed in OneEntry admin panel:

  1. Log in to OneEntry admin
  2. Go to Events section
  3. Create or edit events
  4. Configure triggers, channels, and templates
  5. Activate the event

The SDK is read-only - use it to fetch event info, not create events.


What's the difference between Push Notification and Socket.IO?

Push Notification - Sent to device (works even when app is closed)

  • Appears in notification center

  • User can tap to open app

  • Best for: Important alerts, reminders

  • Socket.IO - Real-time websocket message (only when app is open)

    • Instant delivery to connected clients
    • Live updates without refresh
    • Best for: Live data, chat, collaboration

Can I manually trigger an event from my code?

The SDK doesn't support manual triggers. Events fire automatically based on configured triggers in OneEntry.


Can I customize email templates?

Yes! In OneEntry admin panel:

  • HTML email templates
  • Custom styling
  • Multi-language support
  • Test before activating

What happens if an event fails to send?

OneEntry handles retries and logging:

  • Failed emails are queued for retry
  • Failed push notifications are logged
  • Check event logs in admin panel
  • Configure fallback options

Can I use rich content in notifications?

  • Email - Full HTML support (images, links, styling)
  • Push Notification - Title + body text + optional image
  • Socket.IO - Any JSON data structure

What's the difference between Event and Form submission?

  • Events - System-triggered automated notifications
  • Forms - User-submitted data you collect

Example:

  • Event: "User registered" → Auto-send welcome email
  • Form: User fills contact form → You receive submission

💡 Important Notes

📬 Notification Channels

In the Platform OneEntry, there are three ways to interact with the users of your system through the "Events" module:

  • 📧 Email - Send email messages with rich HTML content
  • 📱 Push Notification - Send real-time alerts to mobile/browser
  • 🔌 Socket.IO - Send instant websocket messages to connected clients

Events are Read-Only in SDK

Remember: The SDK is for reading events, not creating them.


Event Naming Convention

Use clear, descriptive markers:

✅ Good markers:
- order_confirmed
- product_back_in_stock
- user_registered
- payment_failed
- password_reset_requested

❌ Bad markers:
- event1
- notification
- email_event
- test

🎓 Best Practices

  • Use descriptive event markers
  • Test events before activating
  • Provide fallback values for variables
  • Monitor event logs regularly
  • Deactivate unused events
  • Use appropriate channels (email for receipts, push for urgency)
  • Localize event messages
  • Handle missing/disabled events gracefully

More information about the module's user interface https://doc.oneentry.cloud/docs/events/introduction


Definition of the Events module


const { Events } = defineOneEntry(
"your-project-url", {
"token": "your-app-token"
}
);