Mixmax Webhook Transform Language (Advanced)

In this article, we discuss how to use the  Mixmax Webhook Transform Language feature of Mixmax Rules.

By default, when using the  Incoming webhook Mixmax Rule, Mixmax will pass on the entire payload (the data, typically in JSON format) of the event to the rule "action" (under Then). This is often not desired. For example, if you're receiving a webhook from a third party system with the following payload:

{
    "applicant": {
        "first_name": "Jane",
        "last_name": "Candidate"
        "email_addresses": [
            "type": "work",
            "email": "jane@example.com"
         ]
    }
}

and you're using a Mixmax Rule action such as add to sequence that requires email and name properties at the root-level, you need to set a transform to convert the webhook to:

{
    "name": "Jane Candidate",
    "email": "jane@example.com"
}

In order to do this, you'll need to specify the following webhook transforms:

email = applicant.email_addresses.0.email
name = applicant.first_name + " " + applicant.last_name 

This uses Mixmax Webhook Transform Language. Here are more examples of how you can transform webhook properties:

Transform Description Before After
a = b.c Returns a nested property {"b" : {"c": 1}} {"a": 1}
a = b.0 Returns the Nth element of an array {"b": [1]} {"a": 1}
a.b.0 = z Sets a nested property {"z": 1} {"a": {"b": [1}}
a = b[index] Returns the Nth element of an array, using another property as the index {"b": [10,11], "index": 1} {"a": 11}
a = b.c + d.b Concatenates (joins) two strings {"b": {"c": "x", "d": "y"}} {"a": "xy"}
a = b.c + d.b Adds two numbers (only if inputs are numbers) {"b": {"c": 1, d: 2}} {"a": 3}
a = "string literal" Sets a string literal (useful for "hardcoding" properties when posting to a webhook) {"b": 1} {"a": "string literal"}
a = b.c + "-" + b.d Concatenates with a string literal {"b": {"c": "x", "d": "y"}} {"a": "x-y"}
c = . Returns the root object {"a": 1, "b": 2} {"c": {"a": 1, "b": 2}} <br> <br>

Similarly, when using the post to webhook action (under the Then section), you may apply a transformation to convert the Mixmax-chosen webhook payload into a payload that can more easily received by your external system.