Notifications
In-app notifications are an optional, extensible feature built in to OneStarter. This is a flexible, multi-channel notification system with in-app notifications being implemented. They can be extended to support other channels, such as Slack, Teams, or other third-party streams.
Notifications can be in one of three states:
PENDING
: Awaiting processingSENT
: Successfully deliveredFAILED
: Delivery failed
In-app notifications will always be in the SENT
state, but this has been architected to support multiple channels.
To demo the behaviour, we have a built-in in-app notification triggering whenever a new user joins a tenant.
tip
For a complete overview of the data model, review the db/supabase/migrations/120_notifications.sql
migration.
Trigger Recipes
- Global Broadcast
-- Send to all users in a tenant
select api.trigger_notifications(
'global',
payload_json,
tenant_id
);
- Targeted User Notification
-- Send to specific user
select api.trigger_notifications(
category,
payload_json,
tenant_id,
user_id
);
- Channel-Specific Notification
-- Send through specific channel
select api.trigger_notifications(
category,
payload_json,
tenant_id,
null,
channel
);
Notification Payload Structure
{
"type": "NOTIFICATION_TYPE",
"data": {
"customField1": "value1",
"customField2": "value2"
},
"actions": [
{
"label": "Action Button Text",
"url": "/action/path"
}
]
}