N
Novu9mo ago
Etigma

Trigerring workflow with topic not working.

Hi, I'm trying to use a simple topic to send email to somes subscribers. But its not working: I'm on Java 11. using sdk Novu 1.5.0. Calling like this:
Topic t = new Topic();
t.setType("Topic");
t.setTopicKey(topicId);

TriggerEventRequest triggerEventRequest = new TriggerEventRequest();

triggerEventRequest.setTo(t);
triggerEventRequest.setName(workflowId);
TriggerEventResponse triggerEventResponse = novu.triggerEvent(triggerEventRequest);
Topic t = new Topic();
t.setType("Topic");
t.setTopicKey(topicId);

TriggerEventRequest triggerEventRequest = new TriggerEventRequest();

triggerEventRequest.setTo(t);
triggerEventRequest.setName(workflowId);
TriggerEventResponse triggerEventResponse = novu.triggerEvent(triggerEventRequest);
I've also tryed with curl: Ensuring that my topic exist with subscribers: Get topic:
{
"_id": "660158ce03df956825fbf0dc",
"_environmentId": "65fd49a203df956825fbb40f",
"_organizationId": "65fd49a203df956825fbb409",
"key": "topicTestId",
"name": "super-topic-test",
"subscribers": [
"superTestId2",
"superTestId",
"Wouhou",
"lorem2"
]
}
{
"_id": "660158ce03df956825fbf0dc",
"_environmentId": "65fd49a203df956825fbb40f",
"_organizationId": "65fd49a203df956825fbb409",
"key": "topicTestId",
"name": "super-topic-test",
"subscribers": [
"superTestId2",
"superTestId",
"Wouhou",
"lorem2"
]
}
Get of subscriber:
{
"_id": "6601592503df956825fbf16d",
"_organizationId": "65fd49a203df956825fbb409",
"_environmentId": "65fd49a203df956825fbb40f",
"firstName": "Super",
"lastName": "Test",
"subscriberId": "superTestId",
"email": "[email protected]",
"channels": [
{
"credentials": {
"webhookUrl": "<webhook>"
},
"_integrationId": "660544c403df956825fca201",
"providerId": "slack"
}
],
"deleted": false,
"createdAt": "2024-03-25T10:59:49.150Z",
"updatedAt": "2024-03-28T14:01:20.355Z",
"__v": 0,
"data": {
"lang": "EN"
},
"id": "6601592503df956825fbf16d"
}
{
"_id": "6601592503df956825fbf16d",
"_organizationId": "65fd49a203df956825fbb409",
"_environmentId": "65fd49a203df956825fbb40f",
"firstName": "Super",
"lastName": "Test",
"subscriberId": "superTestId",
"email": "[email protected]",
"channels": [
{
"credentials": {
"webhookUrl": "<webhook>"
},
"_integrationId": "660544c403df956825fca201",
"providerId": "slack"
}
],
"deleted": false,
"createdAt": "2024-03-25T10:59:49.150Z",
"updatedAt": "2024-03-28T14:01:20.355Z",
"__v": 0,
"data": {
"lang": "EN"
},
"id": "6601592503df956825fbf16d"
}
14 Replies
Ask Inkeep
Ask Inkeep9mo ago
Hi @Etigma, I'm an AI assistant for Novu. While a team member reviews this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @Ask Inkeep with any follow-up questions. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Java quickstart * Go quickstart * Kotlin quickstart * .NET ----------------------------- Answer Based on the information you've provided, it looks like your setup and trigger event request are correctly structured. If you're experiencing issues with triggering a workflow using topics, ensuring that the topic and subscriber IDs are correctly set up and that the workflow ID you're using in your request matches one that's configured in your Novu environment is crucial. For triggering a notification to a topic in Java, your approach appears aligned with Novu's recommended practices. If issues persist, confirm the following: - The topicId used in setting t.setTopicKey(topicId); matches the key of an existing topic you've retrieved. - The workflowId used in triggerEventRequest.setName(workflowId); is correct and corresponds to a configured workflow in Novu that is designed to send emails. - Ensure that your Novu SDK version is compatible with the functionality you're trying to use. As you mentioned using Novu SDK 1.5.0, checking for any updates or discrepancies in the documentation might help. - The subscribers are correctly identified and associated with the topic in question. Additionally, verify the Novu environment setup, including API keys and any configurations specific to email or subscriber channel setups, to ensure they are correct and active. If the problem persists, reviewing the Novu official documentation and ensuring your setup aligns with the latest guidelines might provide further insights.
Etigma
EtigmaOP9mo ago
When i try to trigger the topic with this curl:
curl --location 'myBaseUrl/v1/events/trigger' \
--header 'Authorization: ApiKey myApiKey' \
--header 'Content-Type: application/json' \
--data '{
"name": "emailmeinstant",
"to": [{
"type": "Topic",
"topicKey": "topicTestId"
}]
}'
curl --location 'myBaseUrl/v1/events/trigger' \
--header 'Authorization: ApiKey myApiKey' \
--header 'Content-Type: application/json' \
--data '{
"name": "emailmeinstant",
"to": [{
"type": "Topic",
"topicKey": "topicTestId"
}]
}'
I receive:
{
"data": {
"acknowledged": true,
"status": "processed",
"transactionId": "af95ea56-1234-4d99-a28f-ead896db72fb"
}
}
{
"data": {
"acknowledged": true,
"status": "processed",
"transactionId": "af95ea56-1234-4d99-a28f-ead896db72fb"
}
}
But nothing in show in activity and no email is sent. Here is the workflow in picture:
No description
Etigma
EtigmaOP9mo ago
When i try the same things in the novu playground. Everything work fine. The only difference in workflow is that there is a " "type": "REGULAR"," in the workflow of the playground.
Ask Inkeep
Ask Inkeep9mo ago
Got it. Tagging @Support for additional help.
Etigma
EtigmaOP9mo ago
I'm using the 0.23 version
Pawan Jain
Pawan Jain9mo ago
@Etigma Thanks for sharing I see there is some issue with topics in self hosting using docker. I will keep you updated about this when we will fix this
Etigma
EtigmaOP9mo ago
Thanks
Novu_Bot
Novu_Bot9mo ago
@Etigma, you just advanced to level 1!
Mei
Mei9mo ago
When self-hosting, I have found that the IS_TOPIC_NOTIFICATION_ENABLED env var defaults to false. Have you set it to true in your environment? When it’s not set to true, you see behaviour exactly like this. A trigger will succeed but start workflows for an empty subscriber list, basically doing nothing.
Tomer Barnea
Tomer Barnea9mo ago
@Pawan Jain seems like @Mei is 100% right here, can you confirm?
Pawan Jain
Pawan Jain9mo ago
Thanks for sharing @Mei TBH, I was not aware of this variable. I spent almost 1 hour debugging the issue with @maybeNoT 🫠 @Etigma could you try setting this variable in api and worker service?
Etigma
EtigmaOP9mo ago
I currently do not have access to the environment. Will keep you updated. Many thanks
Veljko Sicevic Didimora
Hello everyone, I can confirm what @Mei wrote here. IS_TOPIC_NOTIFICATION_ENABLED env var should be changed. I had the same problem and with this thread I've fixed it. Tnx
Tomer Barnea
Tomer Barnea7mo ago
Thanks @Veljko Sicevic Didimora !!
Want results from more Discord servers?
Add your server