com.greenapi.client.examples.SendMessageExample Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of whatsapp-api-client-java Show documentation
Show all versions of whatsapp-api-client-java Show documentation
WhatsApp java client Green API
package com.greenapi.client.examples;
import com.greenapi.client.pkg.api.GreenApi;
import com.greenapi.client.pkg.models.request.OutgoingMessage;
import lombok.extern.log4j.Log4j2;
@Log4j2
public class SendMessageExample {
private void sendMessageExample(GreenApi greenApi) {
var message = greenApi.sending.sendMessage(
OutgoingMessage.builder()
.chatId("[email protected]")
.message("hola a todos")
.build());
if (message.getStatusCode().is2xxSuccessful()) {
log.info(message.getBody());
} else {
log.warn("Message isn't sent, status code: " + message.getStatusCode());
}
}
}