ExternalCallout API example

This example creates an external callout that gets a credit score.

Create an external callout that gets a credit score:

  1. Create a file that is called GetCreditScore.java with the following contents. This file assumes that there is a class that is called ScoreQueryUtility that fetches a score from a modeling application.

    import java.util.Map;
    import com.unicacorp.interact.session.AudienceId;
    import com.unicacorp.interact.flowchart.macrolang.storedobjs.IAffiniumExternalCallout;
    import com.unicacorp.interact.flowchart.macrolang.storedobjs.CalloutException;
    import java.util.Random;
    public class GetCreditScore implements IAffiniumExternalCallout
    	// the class that has the logic to query an external system for a customer's credit score
    	private static ScoreQueryUtility scoreQueryUtility;
    	public void initialize(Map<String, String> configurationData) throws CalloutException
    		// configurationData has the key- value pairs specific to the environment the server is running in
    		// initialize scoreQueryUtility here
    	public void shutdown(Map<String, String> configurationData) throws CalloutException
    	// shutdown scoreQueryUtility here
    	public int getNumberOfArguments()
    		// do not expect any additional arguments other than the customer's id
    		return 0;
    	public List<String> getValue(AudienceId audienceId, Map<String, String> configurationData, 
    		Object... arguments) throws CalloutException
    		Long customerId = (Long) audienceId.getComponentValue("Customer");
    		// now query scoreQueryUtility for the credit score of customerId
    		Double score = scoreQueryUtility.query(customerId);
    		String str = Double.toString(score);
    		List<String> list = new LinkedList<String>();
    		return list;
  2. Compile GetCreditScore.java to GetCreditScore.class.

  3. Create a JAR file called creditscore.jar containing GetCreditScore.class and the other class files it uses.

  4. Copy the JAR file to some location on the runtime server, for example /data/interact/creditscore.jar.

  5. Create an External Callout with name GetCreditScore and classpath as /data/interact/creditscore.jar in the externalCallouts category on the Manage Configurations page.

  6. In an interactive flowchart, the callout can be used as EXTERNALCALLOUT('GetCreditScore').