Before start developing a bot you should first create a bot in the Avaamo Dashboard. Follow the steps in this Getting Started page to create a bot in the dashboard.
Avaamo Java Bot SDK is a single jar file, avaamo.jar.
Download SDK
This file has the full example referred in this page.
Import Avaamo java package.
import com.avaamo.java.Avaamo;Initialize the library with your BOT UUID and Access Token.
avaamo = new Avaamo(<YOUR-BOT-UUID>, <YOUR-BOT-ACCESS-TOKEN>);
avaamo.addEventHandler(new Avaamo.MessageHandler() {
@Override
public void handleMessage(IncomingMessageModel message) {
try{
String content = message.message.content;
System.out.println("\n==> "+message.user.firstName+": "+ content);
}catch (Exception error){
error.printStackTrace();
System.err.println("Error processing the message."+ error.getMessage());
}
}
@Override
public void handleReadAck(ReadAckModel readAckModel) {
System.out.println("Incoming read ack for message uuid : " + readAckModel.read_ack.message_uuid );
}
});// message is the JSON string
avaamo.sendMessage(message)Image image = new Image(new File("test_image.jpg"));
image.setCaption("This is the image caption");
avaamo.sendImage(image, cuuid);FileAttachment fileAttachment = new FileAttachment(new File("TestFile.txt"));
avaamo.sendFileAttachment(fileAttachment, cuuid);CardAttachment cardAttachment = new CardAttachment();
cardAttachment.setTitle("Card Title");
cardAttachment.setDescription("Card Description. This has minimal rich text capabilities as well. For example <b>Bold</b> <i>Italics</i>");
cardAttachment.addLink(new CardAttachment.WebpageCardLink("Web URL", "http://www.avaamo.com"));
cardAttachment.addLink(new CardAttachment.SendMessageDeeplink("Post a Message", "Sample Action"));
cardAttachment.addLink(new CardAttachment.SendFormToConversationDeeplink("Open a Form", "63c906c3-553e-9680-c273-28d1e54da050", "Say Yes", null));
cardAttachment.setShowcaseImage(new File("test_image.jpg"));
avaamo.sendCardAttachment(cardAttachment, cuuid);

