Getting Started
Basic Concepts
Advanced Concepts
How-to Guides
Building integration flows
Data transformation
Integration patterns
Developing Components
Tenant Management
CRM Components
ERP Components
E-Commerce Components
Basic Components
Utility Components
Component Descriptor
Covered in this article
Related articles
Contracts and Workspaces Understanding credentials Data Sample Overview Creating your first integration flow Getting Started What is an integration component? What is an integration flow? What is a tenant? Take a tour of the product Creating a webhook flow Building a component in Java Building a component in Node.js Content-Based Routing Deploying a component How-to Guides Managing flow history Managing OAuth Clients Managing user roles in a tenant Managing Workspaces Mapping data Building real-time flows Sending data to a list of recipients REST API component Managing your SSH keys Managing your Teams/Components Allmysms component Amazon MWS component AMQP component AppDirect Component AWS Lambda component AWS SNS component Bazaarvoice component ChannelAdvisor component Configuration component CSV component Docusign component Dun-and-bradstreet component Ebay component Edifact-parser component Email component Exact Online component Filter component Google PubSub component Google-shopping component Google-translate component Goto-webinar component Google Spreadsheets component Components JDBC Component JDBC Component JDBC Component Jsonata component Key-value-component component Ldap component Lightspeed-ecom component Lightspeed-retail component Lionbridge-translation component Magento1 component Magento2 component Mailchimp component Mandrillapp component Mapper component Microsoft Dynamics CRM component MsSQL component NetSuite component ODATA component Outlook component Petstore-nodejs component Pipedrive component Postgresql component Quickbooks-component component Request-reply component Rest API component Router component Salesforce-cpq component Salesfoce Component Sdl-translate component Sftp component Shopify-admin component Shopware component Simple-trigger component Smarty-streets component Soap component Splitter component Stripe component Sugar-crm component Timer component Twitter component Webhook component Xml component Component Descriptor Structure References Sailor compatibility matrix View Classes

Code component


A code component for the platform, runs a piece of a JavaScript code inside your integration flow.

How Works

Pretty much the same way that you would use any other component in our system. It is deployed by default to production, so no need to deploy it yourself (although you could if you have extended it yourself). In our Dashboard start building your integration and include the Code component as well. You will see a picture similar to the one below:


However, don’t let the simple look fool you - it has a full-fledged interface with many very useful features like the ones you would expect from your favourite desktop developing tool:

  • Syntax highlighting - a standard for any online real-time coding interface
  • Code auto-completion - again a standard that you got used to from your desktop tool
  • Support for number of variables and libraries within the context of the execution
  • Support latest ECMAScript standard
  • Run and troubleshoot within the designer interface.

Available Variables and Libraries

Here are the available variables and libraries that can be used within the context of execution. The most up-to-date list can always be found in be used within the context of execution. The most up-to-date list can always be found in code.js of the component. Below is a sample for the reference:

  • console: - more on Node.js console,
  • process: - Current Node.js process,
  • require: - Module require,
  • setTimeout: - more on setTimeout,
  • clearTimeout: - more on clearTimeout,
  • setInterval: - more on setInterval,
  • clearInterval: - more on clearInterval,
  • msg: - Incoming message containing the payload from the previous step,
  • exports: {},
  • messages: - Utility for convenient message creation,
  • request: - Http Client (wrapped in co - this library),
  • wait: - wait,
  • emitter: user to emit messages and errors

Code component usage Examples

Use code is very simple, just do following:

async function run(msg) {
  console.log('Incoming message is %s', JSON.stringify(msg));
  const body = { result : 'Hello world!' };
  // You can emit as many data messages as required
  await this.emit('data', { body });
  console.log('Execution finished');

transform Please note if you have a simple one-in-one-out function you can simply return a JSON object as a result of your function, it will be automatically emitted as data.

Common usage scenarios

Doing complex data transformation

JSONata is great however sometimes it’s easier to do things in JavaScript, if you want to transform an incoming message with code, just use following sample:

async function run(msg) => {
  addition : "You can use code",
  keys : Object.keys(msg)

Calling an external REST API

It’s very simple to code a small REST API call out of the Code component, see following example:

async function run(msg) {
  const res = await request.get({
    uri: '',
    auth: {
      user: process.env.ELASTICIO_API_USERNAME,
      pass: process.env.ELASTICIO_API_KEY
    json: true
  return {
    fullName: res.body.first_name + " " + res.body.last_name,

Known issues and limitations

  • Snapshots are not supported
  • Credentials are not supported
  • No async is supported