Documentation Index
Fetch the complete documentation index at: https://docs.codenullapp.com/llms.txt
Use this file to discover all available pages before exploring further.
How to send a notification
In order to use the notifications you need to call it via hooks, and you can notify (send notification)
depends on your criteria, by users, roles, or all users.
To use it you need to follow these steps:
// Import the method to send notifications
const sendNotification = require("./utils/sendNotification").default;
const asyncFunctionExample = async (instance) => {
await sendNotification({ usersTo: "email@test.com",
message: "message to send", title: "Notifications title" });
}
asyncFunctionExample(instance);
Parameters:
- rolesTo (string): use it to send notifications to specific roles. To send multiple split by comma
- usersTo (string): use it to send notifications to specific users. To send multiple split by comma
- message (string): use it to send a message in the notification
- title (string): use it to send a title in the notification
- action (string): use it to send the feature you want to navigate
- messageType (string): success | info | error | warning;
How to send to multiple users
To send a notification to multiple users, you can send it with the email of the user already registered in the app or the Id of the user in the database, everything separated by commas to add multiple users, also you can combine the Id of the user and/or emails.
Use the parameter usersTo.
sendNotification(
{
usersTo: "email@test.com,1386223D-0515-4042-98E7-9DC2ADBE3C39,emailTwo@test.com",
message: "message to send", title: "Notifications title" }
);
How to send to multiple roles
To send a notification to multiple roles add the parameter usersTo and put the roleId and/or rolesId you want to send notifications, it will send a notification to every user with the Role sent in.
To send it to multiple roles add them separated by commas.
sendNotification(
{
rolesTo: "FD6B02C0-AD10-4FDC-83BB-0354880FB4F1,1386223D-0515-4042-98E7-9DC2ADBE3C39",
message: "message to send", title: "Notifications title" }
);
Hot to send to multiple roles and users
To send the notification to specific users and/or roles you can combine them just using the both parameters (rolesTo and usersTo).
sendNotification(
{
rolesTo: "FD6B02C0-AD10-4FDC-83BB-0354880FB4F1,1386223D-0515-4042-98E7-9DC2ADBE3C39",
usersTo: "email@test.com,1386223D-0515-4042-98E7-9DC2ADBE3C39,emailTwo@test.com",
message: "message to send", title: "Notifications title" }
);
How to send to all users
If you want to send a notification to all users in the app, do not use the parameters rolesTo and usersTo, to tell the app that need to send it to all users.
sendNotification({
message: "message to send", title: "Notifications title" }
);
Navigate to a feature when the user clicks the notification
To send a notification that allows navigate to another feature you have to add the action parameter with the URL of the feature you want to go.
sendNotification(
{
usersTo: "email@test.com,1386223D-0515-4042-98E7-9DC2ADBE3C39,emailTwo@test.com",
message: "message to send", title: "Notifications title" },
action: "/feature/6052169f34c619001287669c"
);
Also you can use the context of the UI application, To do that you need to send parameters
//the next two examples are equivalent.
//setup action with params
//this scenario is recomended only when you need some data that only exist on the UI session
//Otherwise we recommend send the action as an URL
sendNotification(
{
usersTo: "email@test.com,1386223D-0515-4042-98E7-9DC2ADBE3C39,emailTwo@test.com",
message: "message to send", title: "Notifications title" },
action: "{featureId: '6052169f34c619001287669c', params: [{type: 'querystring', value: 'abc-123', name='Id'}]}"
);
//the result of this action will be a url like
// /feature/6052169f34c619001287669c?Id=abc-123
// setup action only with url
sendNotification(
{
usersTo: "email@test.com,1386223D-0515-4042-98E7-9DC2ADBE3C39,emailTwo@test.com",
message: "message to send", title: "Notifications title" },
action: "/feature/6052169f34c619001287669c?Id=abc-123"
);
Agent Instructions: Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.
Perform an HTTP GET request on the current page URL with the ask query parameter:
GET https://codenull.gitbook.io/dev/configurations/hooks/notifications.md?ask=<question>
The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.
Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.