SailFin-CAFE provides functionality to create conversation between User and MediaGroup. For instance, a simple snippet for playing an announcement to a user would look like: Player p = session.createParticipant(Player.class, "myPlayer");
Conversation conv = session.createConversation(p);

CommunicationBeans can be used to listen media events, DTMF signals and many other events, based on which application logic can be decided.

Listener for media event when a player(announcement) is finished would be:

@CommunicationEvent(type = CommunicationEvent.Type.MEDIAENDED)
public void mediaEnded() {
----- application logic ------

DTMF Signal is intercepted through CommunicationEvent type MessageArrived:

@CommunicationEvent(type=CommunicationEvent.Type.M ESSAGEARRIVED)
void handleMessage() {
DtmfSignal ds = (DtmfSignal) ctx.getMessage();
String signal = ds.getSignal();

At the same time Communication API makes it very handy to replace participants in a conversation. eg. Replacing a user with media group or vice-versa.

All this makes it quite simple to write applications like GreetingService. The basic idea of a GreetingService is to allow users to record messages to be played to their friends at a particular date and time.

Following image illustrates the above:

Greeting Service Example

In the above scenario Alice wants to wish Bob, so she logs in and schedules a greeting for Bob. GreetingService calls Alice for recording the message, CommunicationBean is used to play initial announcement and receive DTMF signals to start/stop recording the message.

Once the recording is finished, an agent(GreetingAgent) is invoked to schedule the Greeting. GreetingAgent calls recepient at scheduled time and plays announcement informing about the Greeting.

Based on the DTMF response of the recepient, greeting is either played or rejected. Sender is informed about the status of the Greeting through an InstantMessage.

Read More about [SailFin-CAFE GreetingService Demo...