Skip to content

Commit 6e45e46

Browse files
committed
Fix: refine the en-US handbook/notification document @11nov
1 parent 1ce13b5 commit 6e45e46

File tree

7 files changed

+455
-321
lines changed

7 files changed

+455
-321
lines changed
Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,45 @@
1-
# Notification: in app message
1+
# Notification: In-App Message
22

33
<PluginInfo name="notification-in-app-message"></PluginInfo>
44

55
## Introduction
66

7-
Support users in receiving message notifications within the application.
7+
Enables users to receive real-time message notifications directly within the NocoBase application.
88

9-
## User Manual
9+
## Installation
1010

11-
Example: Sending In-app Activity Notifications
11+
This plugin is pre-installed, so no additional setup is required.
1212

13-
1. First, configure an in-app message channel in the notification channel management.
14-
![20241017075823-2024-10-17-07-58-27](https://static-docs.nocobase.com/20241017075823-2024-10-17-07-58-27.png)
15-
![20241017080112-2024-10-17-08-01-16](https://static-docs.nocobase.com/20241017080112-2024-10-17-08-01-16.png)
13+
## Adding an In-App Message Channel
1614

17-
2. Configure a workflow, add a notification node, and select the channel created in the previous step for configuration.
18-
![20241017081301-2024-10-17-08-13-05](https://static-docs.nocobase.com/20241017081301-2024-10-17-08-13-05.png)
15+
Go to the notification management section, click adding button and select In-app message.
16+
![2024-11-08-08-33-26-20241108083326](https://static-docs.nocobase.com/2024-11-08-08-33-26-20241108083326.png)
1917

20-
3. Trigger the workflow execution, and you will receive notifications in real-time.
21-
![20241017082030-2024-10-17-08-20-34](https://static-docs.nocobase.com/20241017082030-2024-10-17-08-20-34.png)
18+
Fill in the channel name and description, then click submit.
19+
![2024-11-08-08-34-32-20241108083431](https://static-docs.nocobase.com/2024-11-08-08-34-32-20241108083431.png)
2220

23-
4. In-app messages will be grouped by the name of the sending channel. Based on the read/unread status of the messages, you can filter by all, unread, or read message groups. Clicking the “View” button will redirect you to the configured link page.
24-
![20241017082305-2024-10-17-08-23-10](https://static-docs.nocobase.com/20241017082305-2024-10-17-08-23-10.png)
21+
The new channel will now appear in the list.
22+
23+
![2024-11-08-08-34-52-20241108083452](https://static-docs.nocobase.com/2024-11-08-08-34-52-20241108083452.png)
24+
25+
## Example Usage Scenario
26+
27+
To clarify the use of In-app message, here’s an example for "Marketing Lead Follow-Up".
28+
29+
Imagine your team is running a major marketing campaign aimed at tracking responses and needs from potential clients. Using in-app messages, you can:
30+
31+
**Set Up a Notification Channel:** Begin by creating a channel called "Marketing Clue" in notification management, making it easy for team members to identify its purpose.
32+
33+
![2024-11-08-08-34-32-20241108083431](https://static-docs.nocobase.com/2024-11-08-08-34-32-20241108083431.png)
34+
35+
**Configure a Workflow:** Create a workflow that automatically triggers notifications whenever a new lead is generated. Add a notification node to this workflow, select the "Marketing Clue" channel, and customize the message content according to campaign needs. For example:
36+
37+
![image-1-2024-10-27-14-07-17](https://static-docs.nocobase.com/image-1-2024-10-27-14-07-17.png)
38+
39+
**Receive Notifications in Real-Time:** Once the workflow triggers, all relevant team members will receive notifications instantly, allowing for quick responses.
40+
41+
![image-2-2024-10-27-14-07-22](https://static-docs.nocobase.com/image-2-2024-10-27-14-07-22.png)
42+
43+
**Message Management and Tracking:** In-app messages are grouped by channel name, and you can filter messages by read or unread status to prioritize important information. Clicking "View" redirects you to a configured link, allowing you to manage tasks seamlessly.
44+
45+
![20241027140648-2024-10-27-14-06-51-2024-10-29-13-26-41](https://static-docs.nocobase.com/20241027140648-2024-10-27-14-06-51-2024-10-29-13-26-41.png)
Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
# API
2+
3+
## Server Side
4+
5+
### `BaseNotificationChannel`
6+
7+
This abstract class represents a base for different types of notification channels, defining essential interfaces for channel implementation. To add a new notification channel, you must extend this class and implement its methods.
8+
9+
```ts
10+
export abstract class BaseNotificationChannel<Message = any> {
11+
constructor(protected app: Application) {}
12+
abstract send(params: {
13+
channel: ChannelOptions;
14+
message: Message;
15+
}): Promise<{ message: Message; status: 'success' | 'fail'; reason?: string }>;
16+
}
17+
```
18+
19+
### `PluginNotificationManagerServer`
20+
21+
This server-side plugin serves as a notification management tool, providing methods for registering notification channel types and sending notifications.
22+
23+
#### `registerChannelType()`
24+
25+
This method registers a new channel type on the server side. Example usage is provided below.
26+
27+
```ts
28+
import PluginNotificationManagerServer from '@nocobase/plugin-notification-manager';
29+
import { Plugin } from '@nocobase/server';
30+
import { ExampleServer } from './example-server';
31+
export class PluginNotificationExampleServer extends Plugin {
32+
async load() {
33+
const notificationServer = this.pm.get(PluginNotificationManagerServer) as PluginNotificationManagerServer;
34+
notificationServer.registerChannelType({ type: 'example-sms', Channel: ExampleServer });
35+
}
36+
}
37+
38+
export default PluginNotificationExampleServer;
39+
```
40+
41+
##### Signature
42+
43+
`registerChannelType({ type, Channel }: {type: string, Channel: BaseNotificationChannel })`
44+
45+
#### `send()`
46+
47+
The `send` method is used to dispatch notifications via a specified channel.
48+
49+
```ts
50+
send('in-app-message',
51+
message: [
52+
receivers: [1, 2, 3],
53+
receiverType: 'userId',
54+
content: 'In-app message test',
55+
title: 'In-app message test title'
56+
],
57+
triggerFrom: 'workflow')
58+
59+
send('email',
60+
message: [
61+
62+
receiverType: 'email',
63+
content: 'Email test',
64+
title: 'Email test title'
65+
],
66+
triggerFrom: 'workflow')
67+
```
68+
69+
##### Signature
70+
71+
`send(sendConfig: {channelName: String, message: Object, receivers: ReceiversType, triggerFrom: String })`
72+
73+
The `receivers` field currently supports two formats: NocoBase user IDs`userId` or custom channel configurations`channel-self-defined`.
74+
75+
```ts
76+
type ReceiversType =
77+
| { value: number[]; type: 'userId' }
78+
| { value: any; type: 'channel-self-defined'; channelType: string };
79+
```
80+
81+
##### Detailed Information
82+
83+
`sendConfig`
84+
85+
| Property | Type | Description |
86+
| -------------- | ---------------- | ------------------------ |
87+
| `channelName` | `string` | Channel identifier |
88+
| `message` | `object` | Message object |
89+
| `receivers` | `ReceiversType` | Recipients |
90+
| `triggerFrom` | `string` | Source of trigger |
91+
92+
## Client Side
93+
94+
### `PluginNotificationManagerClient`
95+
96+
#### `channelTypes`
97+
98+
The library of registered channel types.
99+
100+
##### Signature
101+
102+
`channelTypes: Registry<registerTypeOptions>`
103+
104+
#### `registerChannelType()`
105+
106+
Registers a client-side channel type.
107+
108+
##### Signature
109+
110+
`registerChannelType(params: registerTypeOptions)`
111+
112+
##### Type
113+
114+
```ts
115+
type registerTypeOptions = {
116+
title: string; // Display title for the channel
117+
type: string; // Channel identifier
118+
components: {
119+
ChannelConfigForm?: ComponentType // Channel configuration form component;
120+
MessageConfigForm?: ComponentType<{ variableOptions: any }> // Message configuration form component;
121+
ContentConfigForm?: ComponentType<{ variableOptions: any }> // Content configuration form component (for message content only, excluding recipient configuration);
122+
};
123+
meta?: { // Metadata for channel configuration
124+
createable?: boolean // Whether new channels can be added;
125+
editable?: boolean // Whether channel configuration is editable;
126+
deletable?: boolean // Whether channel configuration is deletable;
127+
};
128+
};
129+
130+
type RegisterChannelType = (params: ChannelType) => void
131+
```

0 commit comments

Comments
 (0)