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 Token

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 Token. Tokens are representations of data. When a workflow runs, tokens are replaced with real data.

The following is an example that loops over each line item from the Iterator'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. Afterwards, 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 Token. To type the token, 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 token will read {{custom.personalization_option}}.