Notifications
Business rules can send notifications through multiple channels using the notify() function from a script, or the send_notification action.
notify() takes a single recipient user ID and an options object:
notify(userId, { title, // notification title body, // notification body channels, // optional: array of 'in_app', 'email', 'sms' (defaults to ['in_app']) metadata // optional: extra data (e.g. { action_url: '/a/crm/t/leads/...' })});If no channels are specified, the notification is delivered in-app. When the channels include email or sms, oikapi looks up the recipient’s contact details automatically; channels with no contact info on file are skipped.
Channels
Section titled “Channels”| Channel | Backend | Description |
|---|---|---|
in_app | Built-in | In-application notifications |
email | SMTP | HTML and plain-text email |
sms | Twilio | Text messages |
The platform can also deliver push notifications (APNs, FCM, and Web Push) through the notification system; push delivery is configured by superusers rather than addressed directly from the notify() channel list.
Examples
Section titled “Examples”Multi-channel notification
Section titled “Multi-channel notification”notify(record.assigned_to, { title: 'Task assigned', body: 'You have a new task: ' + record.title, channels: ['in_app', 'email'], metadata: { record_id: record.id, table: 'tasks' }});Notify everyone with a role
Section titled “Notify everyone with a role”notifyRole('manager', { title: 'Approval needed', body: 'Order ' + record.id + ' is awaiting approval', channels: ['in_app']});Convenience wrappers
Section titled “Convenience wrappers”Send directly to an address (no user lookup):
sendEmail('ops@example.com', 'Order received', 'Order ' + record.id + ' was placed');sendSMS('+15551234567', 'Your order shipped');The send_notification action
Section titled “The send_notification action”Rules can also send email or SMS without a script via the send_notification action, with field references interpolated from the record:
{ "type": "send_notification", "config": { "channel": "email", "to": "$record.contact_email", "subject": "Order $record.id received", "body": "Thanks for your order." }}User preferences
Section titled “User preferences”Recipients can control how they’re notified: per-notification-type channel overrides, quiet hours (suppress or defer delivery during set times), and digests (batch lower-priority notifications instead of sending each individually).
Templates
Section titled “Templates”Templates support HTML, plain text, and variable interpolation. Configure the email sender and SMS provider in server configuration.
Delivery
Section titled “Delivery”Notifications are dispatched asynchronously in a detached goroutine after the triggering transaction commits, and delivery is recorded for each recipient. Failed deliveries retry with exponential backoff.