diff --git a/src/main/java/org/sadtech/autoresponder/AutoResponder.java b/src/main/java/org/sadtech/autoresponder/AutoResponder.java index 1f2c15c..8fd61b2 100644 --- a/src/main/java/org/sadtech/autoresponder/AutoResponder.java +++ b/src/main/java/org/sadtech/autoresponder/AutoResponder.java @@ -53,7 +53,12 @@ public class AutoResponder { public Optional answer(@NonNull Long entityId, @NonNull String message) { Optional> unitPointer = unitPointerService.getByEntityId(entityId); final Optional answer = nextUnit( - unitPointer.isPresent() ? unitPointer.get().getUnit().getNextUnits() : startUnits, message + unitPointer.isPresent() + && unitPointer.get().getUnit().getNextUnits() != null + && !unitPointer.get().getUnit().getNextUnits().isEmpty() + ? unitPointer.get().getUnit().getNextUnits() + : startUnits, + message ); if (answer.isPresent()) { final U unitAnswer = answer.get();