N
Novu5mo ago
vikram

Assistance Needed for Checking Undefined or Empty Subscriber Data Field in Novu

I am currently working on setting up a condition in Novu to check if a specific field (data) in the subscriber object is either empty or not defined. I have attempted to use the IS_DEFINED operator with is_negated to check for the absence of the field, but it did not work as expected. is there any way to achieve this?
14 Replies
Ask Inkeep
Ask Inkeep5mo ago
Hi @vikram, I'm an AI assistant for Novu. While a team member reviews this question, I'll see if I can find relevant sources for your question. ----------------------------- While I generate an answer, here are some sources that might be helpful: * General * Subscribers * NextJS * Step Conditions -----------------------------
Ask Inkeep
Ask Inkeep5mo ago
Answer In Novu, you can use the "Is Defined" condition to check whether a specific key in the payload or subscriber data is present or not. However, this condition checks only for the presence of a key, not whether the value is empty or not (1) . If you attempted to use the Is Defined condition with is_negated and it did not work as expected, you might need to ensure that your setup is correctly targeting the desired field and that the field is indeed part of the data being evaluated in the workflow. Here's a general example of how you might set up a condition to check if a key is defined:
{
"on": "subscriber",
"key": "dataFieldName",
"operator": "Is Defined",
"is_negated": true
}
{
"on": "subscriber",
"key": "dataFieldName",
"operator": "Is Defined",
"is_negated": true
}
In this condition setup: - "on": "subscriber" specifies that the condition checks something within the subscriber object. - "key": "dataFieldName" should be replaced with the actual field name you are checking. - "operator": "Is Defined" is used to check for the presence of the key. - "is_negated": true is used to invert the condition, thus the condition will pass if the key is not defined. If you need to check if the field is empty, you might need to additionally handle this logic within your application logic or look for updates from Novu that might add more granularity to condition checks in future releases. Always ensure your fields are being passed correctly and that the workflow is set up to evaluate the conditions as expected. For the most up-to-date information and potential feature extensions, you might also want to keep an eye on the official Novu documentation or community discussions.
Ask Inkeep
Ask Inkeep5mo ago
Got it. Tagging @Support for additional help. Got it. Tagging @Support for additional help.
Pawan Jain
Pawan Jain5mo ago
@vikram are you adding conditions like this?
Pawan Jain
Pawan Jain5mo ago
No description
vikram
vikram5mo ago
yes @Pawan Jain just give you little context in a app i send notification to users mentioned in a comment. and i want to give users a feature to opt out from particular thread. so for that i'm maintaining each user opt out list storing the list in novu subscriber.data object and based on this list will apply step condition. now problem is how can i allow to send notification to user who doesn't have subscriber.data object. there is no not defined operator in novu. i tried is_defined with negated = true but it does not work the way it should be.
Novu_Bot
Novu_Bot5mo ago
@vikram, you just advanced to level 2!
Pawan Jain
Pawan Jain5mo ago
@vikram did you try topics feature for this?
vikram
vikram5mo ago
@Pawan Jain yes but using topic i will not be able opt out from particular channel. is it possible to check if subscriber.data not exist. (it will be great if we have not defined operator as well)
Pawan Jain
Pawan Jain5mo ago
@vikram could you share more info about this? i tried is_defined with negated = true
vikram
vikram5mo ago
@Pawan Jain in update workflow api we can add filters for step in which we have property isNegated so i add filter check attachment. according to my understanding i think it will pass if subscriber.data not defined but it doesn't work as expected
No description
vikram
vikram5mo ago
@Pawan Jain by any chance do we have IS_NOT_DEFINED operator or something like that (or can we add it will be great please let me know)
Pawan Jain
Pawan Jain5mo ago
@vikram thanks for sharing the above screenshot. It clears the confusion with this. Can you please create a new github issue for this? !feature
Want results from more Discord servers?
Add your server