Payload

We use the payload to pass any data to our connector. E.g. instead of storing our credentials right in the code, we can store them securely in the Xomlo.io secrets and pass them through environment variables once the connector is started. There are two types of payloads, create and run. The payload can be defined in the application or via our API.

Create is stored as a secret env and defined while the connector is being created. Then it's passed every time the connector is started. This is good for storing credentials.

Run is not specified until the connector is started and deleted after the process is finished. This is good for things like catching data from webhooks.

You can define your payload variables in the configuration file ./xomlo.json. All names should be in camel case syntax:

{
    ...
    "payload": {
        "create": [],
        "run": ["name"]
        ...
    }
}

For test purposes, you can specify your payload in the .env file. This is an example using capitalized snake case syntax with the prefix XOMLO_PAYLOAD_:

XOMLO_PAYLOAD_NAME="John Smith"

Inside a connector, the create and run payload is passed as one object straight to the main function. To make it easier you can define your payload interface with all your payload variables like this:

interface Payload {
    name: string;
}

You can then work with a payload like this:

import { functions } from '@xomlo/xomlo-sdk';

interface Payload {
    name: string;
}

functions.main(async ({name}: Payload) => {
    functions.logger.info(`Hello ${name}!`);
});

After running the connector you should get:

$ Hello John Smith!

Last updated