Admin Notifications
Ledgerline automatically posts messages to a configured Discord channel when key order and payment events occur. This page describes what triggers each notification and how to configure the admin channel.
Configuring the Admin Channel
In the AdminJS panel, open Bot Config for your tenant and set one of:
- Announcement Channel ID — Discord channel snowflake (takes precedence if both are set).
- Admin Channel ID — fallback channel if
announcementChannelIdis blank.
If neither is set, admin notifications are silently dropped (no error is raised — the consumer logs a skip and continues).
Notification Events
Order Created — Approval Request
Trigger: a customer submits an order via the Discord bot.
Channel post: a rich embed showing:
- Customer name
- Total amount and currency
- Line items
- Current status
Action buttons:
| Button | custom_id format |
|---|---|
| Approve Payment | payment:approve:<orderId> |
| Reject Payment | payment:reject:<orderId> |
These buttons are handled by the Payments feature interaction router. Until that router is wired, the buttons are rendered but non-functional.
Payment Rejected
Trigger: an admin rejects a payment via the /payment-confirm command or the approval button.
Channel post: a brief embed — "Payment Rejected by Admin" — including the orderId and the rejecting admin's name (if available).
Admin email alert (optional): When the Bot Config record carries an adminNotifyEmail field, a plain-text email is also sent to that address. This is useful for operators who monitor email out-of-band. Set adminNotifyEmail directly in the MongoDB document or via a seed script; AdminJS does not expose this field by default. Requires EMAIL_PROVIDER to be set to sendgrid (or capture for testing).
Idempotency
Each notification is deduplicated using a Valkey key:
notif:delivery:<eventId>:<consumerId>
TTL is 24 hours. Replaying the same event within the TTL window will silently skip the channel post. This prevents duplicate messages from retry storms.
Email Notifications
In addition to Discord DMs, Ledgerline can deliver transactional emails to customers when the EMAIL_PROVIDER environment variable is set to sendgrid.
Setup
Set the following environment variables on your deployment:
| Variable | Description |
|---|---|
EMAIL_PROVIDER | Set to sendgrid to enable email delivery |
SENDGRID_API_KEY | Your SendGrid API key |
EMAIL_FROM | The verified sender email address (e.g. orders@yourstore.com) |
When these variables are absent or incomplete, email delivery silently falls back to a no-op — DM notifications are unaffected.
Per-customer email opt-in
Customers can configure which email types they receive via the /email-prefs command:
| Event type | Default |
|---|---|
| Order received | On |
| Payment confirmed | On |
| Order shipped | On |
| Refunds | On |
Email is only delivered when the customer's profile has an email address on file. Admins can update the email address via the AdminJS Customer admin panel.
Email failures
Email send errors are non-blocking — a failure to deliver an email does not prevent the matching Discord DM from being sent. Errors are logged but swallowed. If you need to diagnose delivery failures, check the SendGrid Activity Feed in your SendGrid dashboard.
Related
- Guild Member Notifications — customer DM messages
- Order Management
- Alert reference