Business Communications Tools & App Development Platform | Avaya

Java Getting Started



This java library is an open source tool built to simplify interaction with the Zang telephony platform. Zang makes adding voice and SMS to applications fun and easy.

For more information about Zang, please visit:

To read the official documentation, please visit:


Clone the repo, and install via maven:

$ git clone
$ cd zang-java
$ mvn install

To use this library, include the following dependency within pom.xml:




See the Zang REST API documentation for more information.

Send SMS Example

package com.zang.api.examples;
import com.zang.api.configuration.BasicZangConfiguration;
import com.zang.api.connectors.SmsConnector;
import com.zang.api.connectors.ZangConnectorFactory;
import com.zang.api.domain.SmsMessage;
import com.zang.api.domain.list.SmsMessageList;
import com.zang.api.exceptions.ZangException;

public class SmsExample {

    public static void main(String[] args) {
        BasicZangConfiguration conf = new BasicZangConfiguration();
        SmsConnector conn = ZangConnectorFactory.getSmsConnector(conf);

        //send sms message
        try {
            SmsMessage sentSmsMessage = conn
                            "(XXX) XXX-XXXX",
                            "(XXX) XXX-XXXX",
                            "This is an SMS message sent from the Zang Java helper! Easy as 1, 2, 3!",
                            null, null, null);
        } catch (ZangException e) {



First a configuration must be created by using one of the provided configuration classes (BasicZangConfiguration, PropertiesFileZangConfiguration) or by creating your own implementation with the ZangConfiguration interface.

Normally you'll want to just enter your Zang Platform AccountSid and AuthToken, but you can also define a proxy server or change the base API URL.

Next you'll have to create a connector by using ZangConnectorFactory. This can be done in multiple ways. The usual way is to instantiate ZangConnectorFactory, pass the configuration object to the factory and have it instantiate ZangConnector objects:

ZangConnectorFactory zangConnectorFactory = new ZangConnectorFactory(conf);
CallsConnector callsConnector = zangConnectorFactory.getCallsConnector();

Alternatively you can create a connector directly like this:

CallsConnector callsConnector = ZangConnectorFactory.getCallsConnector(conf);

Besides the configuration parameter you can also specify a custom ClientHttpEngine both for the whole factory or for a specific connector. If a custom ClientHttpEngine is used, the proxy server configuration parameters aren't used.

Request parameters

Request parameters are passed as parameters to connector object methods as shown previously. All methods have convenience overloads which use the AccountSid parameter specified in the configuration automatically:

UsagesConnector connector = connectorFactory.getUsagesConnector();
//explicit accountSid
Usage usage = connector.viewUsage("{accountSid}", "{UsageSid}");
//accountSid from configuration used automatically
Usage usage = connector.viewUsage("{UsageSid}");

Methods with a large number of possible parameters have convenience builder objects, e.g.:

CallsConnector connector = connectorFactory.getCallsConnector();
Call call = connector.makeCall(MakeCallParams.builder()

Response data

The received data can be an object, e.g.:

UsagesConnector connector = connectorFactory.getUsagesConnector();
Usage usage = connector.viewUsage("{UsageSid}");

Or a list of objects in which case the list is iterable, e.g.:

UsagesConnector connector = connectorFactory.getUsagesConnector();
ListUsagesParams params = ListUsagesParams.builder()
UsagesList list = connector.listUsages(params);
for(Usage usage : list) {


InboundXML is an XML dialect which enables you to control phone call flow. For more information please visit the Zang InboundXML documentation.


package com.zang.api.examples;

import com.zang.api.exceptions.ZangException;
import com.zang.api.inboundxml.ZangInboundXml;
import com.zang.api.inboundxml.elements.Say;
import com.zang.api.inboundxml.elements.enums.Language;
import com.zang.api.inboundxml.elements.enums.Voice;

public class InboundXmlExample {

    public static void main(String[] args) {
        try {
            String result = ZangInboundXml.builder()
                            .setText("Welcome to Zang!")
        } catch (ZangException e) {



will render

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Say loop="3" voice="female" language="en">Welcome to Zang!</Say>

Pending updates to this document

Subscribe for Updates