Installation
JDK 11 or later is required. Maven users:<dependency>
<groupId>co.novu</groupId>
<artifactId>novu-java</artifactId>
<version>LATEST</version>
</dependency>
implementation 'co.novu:novu-java:LATEST'
Usage
- US Region
- EU Region
package hello.world;
import co.novu.Novu;
import co.novu.models.components.*;
import co.novu.models.errors.*;
import co.novu.models.operations.EventsControllerTriggerResponse;
import java.lang.Exception;
import java.util.Map;
public class Application {
public static void main(String[] args) throws PayloadValidationExceptionDto, ErrorDto, ValidationErrorDto, Exception {
Novu sdk = Novu.builder()
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
EventsControllerTriggerResponse res = sdk.trigger()
.body(TriggerEventRequestDto.builder()
.workflowId("workflow_identifier")
.to(To2.of("SUBSCRIBER_ID"))
.payload(Map.ofEntries(
Map.entry("comment_id", "string"),
Map.entry("post", Map.ofEntries(
Map.entry("text", "string")))))
.overrides(TriggerEventRequestDtoOverrides.builder()
.build())
.actor(TriggerEventRequestDtoActor.of("<value>"))
.context(Map.ofEntries(
Map.entry("tenant", TriggerEventRequestDtoContextUnion.of("org-acme"))))
.build())
.call();
if (res.triggerEventResponseDto().isPresent()) {
// handle response
}
}
}
package hello.world;
import co.novu.Novu;
import co.novu.models.components.*;
import co.novu.models.errors.*;
import co.novu.models.operations.EventsControllerTriggerResponse;
import java.lang.Exception;
import java.util.Map;
public class Application {
public static void main(String[] args) throws PayloadValidationExceptionDto, ErrorDto, ValidationErrorDto, Exception {
Novu sdk = Novu.builder()
.serverUrl("https://eu.api.novu.co")
.secretKey("YOUR_SECRET_KEY_HERE")
.build();
EventsControllerTriggerResponse res = sdk.trigger()
.body(TriggerEventRequestDto.builder()
.workflowId("workflow_identifier")
.to(To2.of("SUBSCRIBER_ID"))
.payload(Map.ofEntries(
Map.entry("comment_id", "string"),
Map.entry("post", Map.ofEntries(
Map.entry("text", "string")))))
.overrides(TriggerEventRequestDtoOverrides.builder()
.build())
.actor(TriggerEventRequestDtoActor.of("<value>"))
.context(Map.ofEntries(
Map.entry("tenant", TriggerEventRequestDtoContextUnion.of("org-acme"))))
.build())
.call();
if (res.triggerEventResponseDto().isPresent()) {
// handle response
}
}
}