timesync
12/18/2016 - 9:36 PM

Activity Builder Sample Code

Activity Builder Sample Code

/**
 * sample-activity.js
 *
 * @author Sample Author
 *
 * @platform Built.io Flow
 *
 * @description Sample activity description.
 *
 * @input
 *      var: Sample variable description
 *
 * @output
 *      var: Sample variable description
 */

/**
 * Module configuration variables
 */
const activityId = 'sample-activity-id';						// Activity ID
const activityLabel = 'Sample Activity Label';					// Activity Label
const activityHelp = 'Sample Activity Help Text';				// Help Text

const activityInputSchema = {
    title: activityLabel,
    type: 'object',
    properties: {
    	sample_input: {
            title: 'Sample Input',
            type: 'string',
            description: "Sample input description.",
            propertyOrder: 1,
            minLength: 1
    	}        
    }
};

const activityOutputSchema = {
    title:'Output',
    type: 'object',
    properties: {
        sample_output: {
            title: 'sample_output',
            type: 'string'
        }
    }
};

/**
 * executeActivity()
 *
 * @description This function performs the API call and any necessary manipulation.
 */
function executeActivity(input, output) {
    if(input.sample_input){
        return output(null,{sample_output:"Hello "+input.sample_input + " !"});
    }
}

/**
 * Built.io activity creation happens here.
 */
module.exports = function() {
    this.id = activityId;
    this.label = activityLabel;
    this.help = activityHelp;
    this.input = activityInputSchema;
    this.output = activityOutputSchema;
    this.execute = executeActivity;
};