Skip to content

messente/messente-api-java

Repository files navigation

Messente API Library

  • Messente API version: 2.0.0
  • Java artifact version: 4.4.0

Messente is a global provider of messaging and user verification services. * Send and receive SMS, Viber, WhatsApp and Telegram messages. * Manage contacts and groups. * Fetch detailed info about phone numbers. * Blacklist phone numbers to make sure you're not sending any unwanted messages. Messente builds tools to help organizations connect their services to people anywhere in the world.

Installation

Install Messente API library via Maven, Gradle, Ivy or manual build.

Gradle

dependencies {
    implementation 'com.messente.api:messente-api:4.4.0'
}

Maven

<dependency>
  <groupId>com.messente.api</groupId>
  <artifactId>messente-api</artifactId>
  <version>4.4.0</version>
</dependency>

Ivy

<dependency org='com.messente.api' name='messente-api' rev='4.4.0'/>

Manual Build

Generate

mvn clean package

Install

  • target/messente-api-4.4.0.jar
  • target/lib/*.jar

Features

Messente API has the following features:

Messente API Library provides the operations described below to access the features.

BlacklistApi

  1. Adds a phone number to the blacklist addToBlacklist
  2. Deletes a phone number from the blacklist deleteFromBlacklist
  3. Returns all blacklisted phone numbers fetchBlacklist
  4. Checks if a phone number is blacklisted isBlacklisted

BulkMessagingApi

  1. Sends a bulk Omnimessage sendBulkOmnimessage

ContactsApi

  1. Adds a contact to a group addContactToGroup
  2. Creates a new contact createContact
  3. Deletes a contact deleteContact
  4. Lists a contact fetchContact
  5. Lists groups of a contact fetchContactGroups
  6. Returns all contacts fetchContacts
  7. Removes a contact from a group removeContactFromGroup
  8. Updates a contact updateContact

DeliveryReportApi

  1. Retrieves the delivery report for the Omnimessage retrieveDeliveryReport

GroupsApi

  1. Creates a new group with the provided name createGroup
  2. Deletes a group deleteGroup
  3. Lists a group fetchGroup
  4. Returns all groups fetchGroups
  5. Updates a group with the provided name updateGroup

NumberLookupApi

  1. Requests info about phone numbers fetchInfo

OmnimessageApi

  1. Cancels a scheduled Omnimessage cancelScheduledMessage
  2. Sends an Omnimessage sendOmnimessage

StatisticsApi

  1. Requests statistics reports for each country createStatisticsReport

Auth

Type: HTTP basic authentication

Read the external getting-started article which explains API keys and Sender ID logic.

Getting started: sending an omnimessage

import com.messente.ApiClient;
import com.messente.ApiException;
import com.messente.api.*;
import com.messente.auth.HttpBasicAuth;

import java.util.Arrays;
import java.util.List;

// repositories { mavenCentral() }
// dependencies { implementation 'com.messente.api:messente-api' }

public class Main {
    public static void main(String[] args) {
        ApiClient apiClient = new ApiClient();
        OmnimessageApi apiInstance = new OmnimessageApi(apiClient);

        HttpBasicAuth basicAuth = (HttpBasicAuth) apiClient.getAuthentication("basicAuth");
        basicAuth.setUsername("YOUR_MESSENTE_API_USERNAME");
        basicAuth.setPassword("YOUR_MESSENTE_API_PASSWORD");

        Viber viber = new Viber();
        viber.text("hello viber");
        viber.sender("<sender name (optional)>");
        OmnimessageMessagesInner viberOmnimessageInner = new OmnimessageMessagesInner(viber);
        viberOmnimessageInner.setActualInstance(viber);

        SMS sms = new SMS();
        sms.text("hello sms");
        sms.sender("<sender name (optional)>");
        OmnimessageMessagesInner smsOmnimessageInner = new OmnimessageMessagesInner(sms);
        smsOmnimessageInner.setActualInstance(sms);

        WhatsAppParameter whatsAppParameter = new WhatsAppParameter();
        whatsAppParameter.type("text");
        whatsAppParameter.text("hello whatsapp");

        WhatsAppComponent whatsAppComponent = new WhatsAppComponent();
        whatsAppComponent.type("body");
        whatsAppComponent.setParameters(List.of(whatsAppParameter));

        WhatsAppTemplate whatsAppTemplate = new WhatsAppTemplate();
        whatsAppTemplate.name("<template_name>");
        whatsAppTemplate.language(new WhatsAppLanguage().code("<language_code>"));
        whatsAppTemplate.setComponents(List.of(whatsAppComponent));

        WhatsApp whatsApp = new WhatsApp();
        whatsApp.sender("<sender name (optional)>");
        whatsApp.template(whatsAppTemplate);

        OmnimessageMessagesInner whatsAppOmnimessageInner = new OmnimessageMessagesInner(whatsApp);
        whatsAppOmnimessageInner.setActualInstance(whatsApp);

        Omnimessage omnimessage = new Omnimessage();
        omnimessage.setMessages(
                Arrays.asList(
                        smsOmnimessageInner,
                        viberOmnimessageInner,
                        whatsAppOmnimessageInner
                )
        );
        omnimessage.setTo("<recipient_phone_number>");

        try {
            OmniMessageCreateSuccessResponse result = apiInstance.sendOmnimessage(omnimessage);
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling sendOmnimessage");
            System.err.println(e.getResponseBody());
        }
    }
}

License

Apache-2.0

Terms

https://messente.com/terms-and-conditions