Custom Code by MESA

The Custom Code by MESA app allows you to add complex logic to a workflow that might otherwise be difficult with the MESA building blocks. You can integrate third-party services that MESA does not yet integrate with, write Javascript code, and send data to third-party services. 

You can click on {/} Edit Code to add your custom code. 

For technical details, you can click here.

Assigning data from your custom code to a MESA variable

When writing custom code, you will need a way to send that custom data further down in the workflow. The best way to do that is to assign the custom data to a MESA variable. Variables are representations of data. When a workflow runs, variables are replaced with real data.

The following is an example that loops over each line item from the Loop's payload. MESA will loop through each line item property in a line item and look for a match with the specified line item property name. Afterward, MESA will assign the line item property. You can see this in the screenshot below: MESA assigns the values to {{payload}} and then sends {{payload}} to the next output. 

After your custom code is established, go back to the individual workflow view and locate the Custom Code step. Click on the three-dotted icon and click on Copy next to the step's Key

In your workflow's later steps, locate the field that needs the custom variable. To type the variable, enter {{ and then paste the copied key. Next, add a period (.) and then manually type out the key that is assigned to the custom data. Lastly, add }}

It should look something like below. For instance, where we set `personalization_option` to the payload in the Custom step, the variable will read {{custom.personalization_option}}