Trigger is a Lambda function used to retrieve data (e.g. record updates) from a 3rd party API and trigger the related workflow execution

Trigger Input Format

{
    // trigger metadata
    "_id": "56a8fa2a09e7e6b0e3b7082b",
    "trigger": "contactAddedOrUpdated",
    "trigger_id": "56a8fa2a09e7e6b0e3b7082b",
    "user_id": 9,
    "proxy": "cn_sf_cumulus",
    "status": "after_pause",
    "date": "2016-02-03T19:14:01.385960Z",
    "last_start_date": "2016-02-03T19:11:18.907107Z",
    "last_run_date": "2016-02-03T19:16:12.630688",
    "sent_to_process": false,
    "is_enabled": true,

    // trigger scheduler configuration
    "type": "schedule",
    "cron_params": {
        "minute": "15",
        "hour": "17/8"
    },

    // A set of parameters needed to connect to 3rd party API.
    // These parameters will be requested on the application connection form.
    "apiKey": "SOME-API-KEY",
    // etc.

    // Workflow configuration parameters will be placed within the "conditions" object.
    // These parameters will be requested on the workflow configuration page.
    "conditions": {
        "monitorFromDate": "2016-01-01T00:00:00.000Z",
        "filter": "..."
        // etc.
    },

    // Persisted trigger metadata from the previous trigger execution (see Output Format)
    "meta": {
        "origMonitorFromDate": "2016-01-01T00:00:00.000Z",
        "processFromDate": "2016-01-11T11:11:11.111Z"
        // etc.
    }, 

    // This is where trigger result data must be uploaded to.
    // There is no need to specify s3 credentials explicitly, the lambda function itself 
    // will be authorized to perform GetObject/PutObject operations for the given bucket
    "s3": {
        "bucketName": "apination-intermediate-data-stg",
        "keyPrefix": "2016/02/08/21-30-12-345-"
    }
}

Trigger Output Format

Trigger output consists of 2 parts:

S3-uploaded Data

S3-uploaded data must be a serialized JSON array, where each element corresponds to an update (transaction/object) retrieved from a 3rd party application (even if there is only one update retrieved):

[
    {...},
    {...},
    ...
]

You can find a JavaScript example of data upload to AWS bucket in the s3Helper.js of cn-example-lambda

Trigger Execution Summary

The following summary must be returned by Lambda function (or passed to context.succeed in case of NodeJS environment):

{
    // 's3://{bucketName}/{key}', where retrieved data is saved
    "data": "s3://apination-intermediate-data-stg/2016/02/08/21-30-12-345-5ffe478b-3af3-4f6c-9db3-457634e00d36",

    // Everything returned in the "meta" object will be saved for the current trigger_id
    // and submitted back to trigger upon next trigger execution.
    // (See #date-ranges-processing for the usage sample)
    "meta": {
        "origMonitorFromDate": "2016-01-01T00:00:00.000Z",
        "processFromDate": "2016-02-08T21:30:12.345Z"
    },

    "stats": {
        // A single object name (e.g. contact, transaction, etc.)
        // will be used to format a user-facing log message. 
        // For example:
        // - "Object update retrieved"
        "objectName": "object update",

        // A plural object name (e.g. contacts, transactions, updates, etc.)
        // will be used to format a user-facing log message. 
        // For example:
        // - "25 object updates retrieved"
        // - "3 object updates retrieved (ABC001, ABC002, ABC003)"
        "objectNamePlural": "object updates",

        // A list of user-facing reference numbers or object names.
        // If the number of retrieved objects exceeds reasonable amount, 
        // only a total number of retrieved objects must be returned
        // (e.g. "retrieved: 25")
        "retrieved": ["ABC001", "ABC002", "ABC003", ...]
    }
}