You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Descriptive name given during creation of topic can be changed later. This can be done like this:
48
-
49
-
```typescript
50
-
import { Novu } from"@novu/node";
51
-
52
-
const novu =newNovu("<NOVU_SECRET_KEY>");
53
-
54
-
const topicKey ="posts:comment:12345";
55
-
const topicName ="Post Comments";
56
-
57
-
const result =awaitnovu.topics.rename(topicKey, topicName);
58
-
```
59
-
60
-
This will return the whole Topic information, including the subscribers if having any.
61
-
62
-
<Note>Topic Key can not be changed</Note>
63
-
64
52
## Add subscribers to a topic
65
53
66
54
Adding subscribers to the topic is the main usecase of topic. A topic is like a group of subscribers. A notification can be sent to all subscribers of a topic at once
@@ -105,71 +93,8 @@ The field `succeeded` will return the array of subscriber ids that have been c
105
93
To facilitate flows we allow to create a topic on the fly when adding subscribers.
106
94
107
95
If the topic key used does not exist for the selected environment and organization, Novu will create a new topic with name `Autogenerated-<TOPIC_KEY>` and the subscribers will be assigned to this newly created topic.
108
-
109
96
After that, that topic created on the fly can be managed in the same ways as the ones created in the normal way.
110
97
111
-
## Verify if subscriberId belongs to a topic
112
-
113
-
There would be times when it would be needed to verify if a certain subscriber belongs to a topic in order to decide what to do with that subscriber. The API call to achieve that is the following:
Where `subscribers` will be an array of the subscriberIds we want to remove from the topic. If successful an empty response will be returned.
152
-
153
-
## Delete a topic
154
-
155
-
An existing topic can be deleted using topic-key as topic-key is the unique identifier for a topic.
156
-
157
-
```typescript
158
-
import { Novu } from"@novu/node";
159
-
160
-
const novu =newNovu("<NOVU_SECRET_KEY>");
161
-
162
-
const key ="unique-topic-identifier";
163
-
164
-
const result =awaitnovu.topics.delete(key);
165
-
```
166
-
167
-
<Warning>
168
-
A topic can only be deleted if it doesn't have any subscriber added. When
169
-
trying to delete a topic with subscribers a conflict error will be returned.
170
-
This is done to prevent accidental topic deletions.
171
-
</Warning>
172
-
173
98
## Trigger workflow to a topic
174
99
175
100
A workflow can be triggered to a single subscriber and an array of subscribers. While doing so, one need to send subscriberIds in `to` field. In case of trigger, we have already stored subscriberIds in a topic, so a topic key can be used to trigger a workflow. Workflow will be triggered to all subscribers in the topic.
User X makes a comment, other users (A, B) who've already commented before should get a notification. So, when triggering the notification on that topic, you would usually want to exclude User X from receiving a notification about their own comment. To do that - you would need to add User X's subscriberId to the trigger event.
0 commit comments