B. Groovy Bots


ITFramework Groovy SDK


ITFramework allow developers to write custom modules which can be easily integrated into the framework. Custom modules are Groovy scripts (http://groovy.codehaus.org/). These scripts can access the ITFramework modules at runtime and interact with them.

Common uses of these Groovy modules:

  1. Write bots which can query any data source – LDAP, RSS/ATOM feeds, web services

  2. Interact with existing ITFramework modules – Queue and Interviews, subscribe to their events

  3. Perform a quick look up to fetch meta data associated with an conversation or a customer and tag

  4. Push customers to a Queue

  5. Write custom logging modules; etc…

A Groovy module for ITFramework comprises of two pieces:

  1. Script file containing implementation

  2. XML file containing module configuration data

Setting up development environment

Take the following steps to setup a development environment for writing groovy scripts for ITFramework

  1. Install SUN JDK 1.6

  2. Download latest Groovy release (1.6 and above from http://groovy.codehaus.org/Download)

  3. Extract the Groovy SDK and go to the bin folder as specified in the following screen shot:

  4. Run the file “groovyConsole.bat”, this will then launch Groovy editor as lighted in the following screen shot:

  5. Access to an ITFramework deployment to test the scripts

Groovy Scripts – Basic Bots

Groovy script skeleton looks like following:

import com.instant.applications.bots.*
import com.instant.services.*;
import com.instant.services.im.*;
import com.instant.applications.dynamic.*
import com.instant.applications.*;
import com.instant.services.database.*;
import com.instant.util.*;
import org.apache.log4j.*;
import groovy.text.Template
import groovy.text.SimpleTemplateEngine

public class myBot extends MultiServiceBot






public void start()


//Initialize Messaging Service

_MsgServicesInterface = new MsgServices(new ITFSametimeIMService(), new ITFOCSIMService(), new ITFXMPPIMService(),new ITFFaceBookIMService())

registerAndLogin(“ST”, ServerIP, BotUserName, BotPassword);


public void stop()


//Event fires when bot logs in successfully
void loggedIn(ITFLoginEvent loginEvent) {

//Event fires when bot logs out successfully or fails to login
void loggedOut(ITFLoginEvent loginEvent) {

//Fires when there is a new incoming IM session
public void ImReceived(ITFIMEvent ImEvent) {

//Fires when a user connected with bot sends a text message
public void ImTextReceived(ITFIMEvent ImEvent) {

//To send IM partner a text message
public void sendMessage(String partner, String message) {
String msgType = ImEvent.getMsgServiceType()
MsgServiceInterface myService = getMsgService(msgType)
myService.sendText(partner, message, ImEvent.getConfigId())


Deploying Groovy Scripts

To deploy a Groovy Script take following steps:

  1. Go to the system running ITFramework

  2. Go to the folder “” containing scriptloadlist.xml

  3. Add the following block
    <Description>My Test Bot</Description>
    <!-- Path to the Groovy File -->
    <!-- Path to the Groovy Bot Configuration XML File -->

  4. Restart the Apache Service from the Services applet in Control Panel.


Instant Documentation,
Oct 11, 2010, 9:31 AM