Java UAS Application Samples

The following samples illustrate how to use the Java UAS application framework to create simple UAS applications that handle inbound and outbound calls, play and record wav files, play and detect DTMF digits, perform call connection, transfer and conferencing.

Please note that in the interests of clarity these samples are short on the kind of error handling and diagnostic aspects that would typically be required in a live environment.

  • Where to Find Them
They are included in the Java UAS download package and located in the <UAS installation folder>\Samples\UASApplications folder.
Pre-built versions of all of these samples are provided in the <UAS installation folder>\Samples\UASApplications\bin subfolder.

  • How to Build Them
Each sample contains eclipse .project and .classpath files and an Ant build script file (build.xml). All the samples depend on the common.jar library for which the source is also provided.

Each sample requires the UAS API library (uasapi-x.x.x-release.jar) to be on its classpath. This resides in the <UAS install folder>\Repository folder. The Ant build.xml script automatically sets this classpath. However building from Eclipse with the Java compiler requires the global Classpath Variable UASAPI_LIB to be configured to point to this jar file.

  • How to Install and Configure Them
Use the UAS Management Console to install a built application.
Use cloud.aculab.com to configure a service that will invoke an application.
The service configuration settings required (applicationParameters, outboundParameters, extraChannels and fax settings) are shown in [brackets] below each application.

  • Media Files
Some of these samples play or record media files. These files reside on the cloud and may be manually uploaded or downloaded via the File Management page of cloud.aculab.com.

  • Local Database
The database and voicemail4 samples access a local SQLEXPRESS database 'test'. See Tutorial - Database for instructions on preparing this database.

The Samples:

AddToConference

An inbound application that prompts the user to enter a 4-digit pin that represents a conference to which they are then transferred.
[1 extra channel]

Database2

An inbound application that opens a local database of pincodes and associated ages, answers the call and prompts the caller to enter a four digit pin code. It then queries the database for the age associated with the entered pin code and says it to the caller.
[none]

Database3

Extends the Database2 sample to provide the caller with the option of modifying the age within the database.
[none]

Database4

Extends the Database3 sample to provide the caller with the option of adding a new entry if the pin code is not within the database.
[none]

GetUSWeather

An inbound application that prompts the caller to enter a US Zipcode then reads the weather for that location to the caller.
e.g.
90212 - Beverley Hills CA
10036 - Times Square, NY
33139 - South Beach, FL
94129 - San Fransisco, CA
20011 - Washington, DC
90028 - Hollywood, CA
[none]

InboundPlayWav

An inbound application that simply plays a wav file (filename passed in) to the caller then hangs up.
[applicationParameters = the wav filename]

InboundReceiveFax

An inbound application that answers a call and receives a fax from that call. The received fax is saved to a TIFF file name constructed from the user part of the callFrom field and the current date.
Fax receiving can be enabled for a particular service by editing the service entry from the Inbound Services page.
[Enable Fax Receive = enabled in the service invoking this application]


InboundWithTTS

An inbound application that simply says some text (passed in) to the caller then hangs up.
[applicationParameters = the text to say]

OutboundConnect

An outbound application that makes calls to two destination addresses (passed in). It prompts the first call to record a message and plays this to the second call before tromboning the two calls together. It then waits for the calls to be hung up.
[outboundParameters = two destination addresses for the outgoing call, semicolon delimited]
[1 extra channel]
e.g.
outboundParameters = "sip:bob@bobscompany.com;sip:brian@brianscompany.com"
applicationParameters = ""
or
outboundParameters = "tel:441908081876;tel:441908678180"
applicationParameters = "tel:441908876543"

OutboundReminder

An outbound application that makes a call to a destination address (passed in) from a source address (passed in) and says a text string (also passed in) and optionally plays a wav file (also passed in, but can be omitted) to that call.
[outboundParameters = destination address;source address;text to say;wav filename]
e.g.
outboundParameters = "sip:bob@bobscompany.com;;Time for your meeting"
or
outboundParameters = "tel:441908081876;tel:441908876543;Time for your meeting;alarm.wav"

OutboundSendFax

An outbound application that makes a call to a destination address (passed in) from a source address (passed in) and sends a fax to that call. The fax is constructed from a single header page and 1 or more content pages. The header page is obtained from a TIFF file specified in the service's application parameters. The content pages are obtained from a TIFF file specified in the outboundParameters. A page number is inserted into each page before sending.
Fax sending can be enabled for a particular service by editing the service entry from the Outbound Services (or Inbound Services) page.
[Enable Fax Send = enabled in the service invoking this application]
[outboundParameters = destination address;source address;file name of fax]
[applicationParameters = file name (.tif) of header page] (optional)
e.g.
outboundParameters = "sip:bob@bobscompany.com;;ContractFax.tif"
or
outboundParameters = "tel:441908081876;tel:441908876543;ContractFax.tif"

PinInput

An inbound application that answers the call, prompts for the caller to enter a 4 digit pin code. It waits for 30 seconds for 4 digits to be entered and replays them to the caller.
[none]

QuickStart

A simple inbound application that is provided as the default Developer Service Target Entry. It rings the call for 4 seconds, answers the call, then reads out the decoded pincode and username from the called address before hanging up.
[none]

TransferMenu

An inbound application that prompts the user to select an Inbound Service target to be transferred to. A prompt (to be read out) and the service (to be transferred to) need to be listed at service registration.
[applicationParameters/app_args = semicolon delimited list of prompt,servicename
e.g.
"join a conference, AddToConferenceService;
listen to media file, InboundPlayMusicService"]
[1 extra channel]

UASConnectionTest

A simplified inbound application that rings the call for 2 seconds, answers the call, then reads out some text including the machine name on which the UAS is running and the application parameters sent to the application, before hanging up.
[optional: applicationParameters = text to say]

Voicemail1

An inbound application that answers the call, prompts the caller to record a message (and to press any key to stop recording), plays a beep to indicate it is recording and then waits for a max of 60 seconds.
The recorded filename is samples/voicemail1/recordedMessageFromcallFrom.wav. It checks that a recorded message file exists.
[none]

Voicemail2

An inbound application that answers the call, loops round prompting the caller to record a message and playing it back to them until they are satisfied with it.
The recorded filename is samples/voicemail2/recordedMessageFromcallFrom.wav.
[none]

Voicemail3

An inbound application that answers the call, says "Welcome to the voicemail server for name." name is obtained from applicationParameters. It is compared with the user part of the callFrom property of the inbound call.

If callFrom equals name
- Say "Press 1 to hear all messages, press 2 to delete all messages".
- 1. Play all existing messages
- 2. Delete all existing messages
else
- Do recording as in voicemail 2.

All options return to the above menu.
The app only completes when the call is hung up.
The recorded filename is samples/voicemail3/name/msgcounter.wav.
The counter is a variable, initialised to 1, which increments each time a message is successfully saved.
[applicationParameters = name of voicemailbox (e.g. calling number)]

Voicemail4

Extends the voicemail3 sample so that option 1 additionally allows each message to be deleted after it is played. Also it adds a third option to record a welcome message to be played after the call is answered.

To avoid any eventual consistency issues with media file storage the list of recorded message files is saved in a local SQLEXPRESS database.
[applicationParameters = name of voicemailbox (e.g. calling number)]