Allow Velocity Script Tokens in Webhook Payload

Allow Velocity Script Tokens in Webhook Payload

Currently, Webhook payloads do not allow Velocity Script tokens. Why not?

Using a Velocity Script token to generate the JSON payload for a Webhook would be very helpful. For instance, the JSON structure of my Webhook could vary conditionally based on Lead and/or Program tokens. Currently, if I want to perform different actions in an external API, I would have to create numerous Webhooks. I don't want to have a different Webhook for each variation of my API calls. I would like to use a single Webhook, but vary the payload using the conditional logic of a Velocity Script.

Desired

Webhook - Mail Item

{

     "leadId": {{lead.Id}},

     "sku": {{my.SKU}},

     "qty": 1,

     "address": {

          "name": {{lead.Full Name}},

          "street": {{lead.Address}},

          "city": {{lead.City}},

          "state": {{lead.State}},

          "postcode": {{lead.Postal Code}}

     },

     "data": {{my.Custom Script}}

}

Velocity Script Token - {{my.Custom Script}}

{

     "postcard_message": "Dear ${lead.FirstName},\\nYour subscription is about to expire on ${lead.subscriptionEndDate}.\\nRenew today!"

}

Velocity Script Token - {{my.Custom Script}} in another Program

{

     "brochure_image": "${my.brochureImage}",

     "brochure_copy": "${my.brochureCopy}"

}

Current

Webhook 1 - Mail Postcard

{

     "leadId": {{lead.Id}},

     "sku": {{my.SKU}},

     "qty": 1,

     "address": {

          "name": {{lead.Full Name}},

          "street": {{lead.Address}},

          "city": {{lead.City}},

          "state": {{lead.State}},

          "postcode": {{lead.Postal Code}}

     },

     "data": {

          "postcard_message": {{my.Custom Postcard Message}}

     }

}

Webhook 2 - Mail Brochure

{

     "leadId": {{lead.Id}},

     "sku": {{my.SKU}},

     "qty": 1,

     "address": {

          "name": {{lead.Full Name}},

          "street": {{lead.Address}},

          "city": {{lead.City}},

          "state": {{lead.State}},

          "postcode": {{lead.Postal Code}}

     },

     "data": {

          "brochure_image_1": {{my.Custom Brochure Image}},

          "brochure_copy": {my.Custom Brochure Copy}}

     }

}

2 Comments
Level 10 - Community Moderator

Yeah, I'll vote up... but give it a 0% chance of happening.

Velocity simply doesn't execute in the tier you want it to (the engine isn't running there). Would be equally cool if we could use VTL tokens in LPs, so we wouldn't need to maintain VTL and JS versions of the same logic... but I have no expectation that the LP servers will ever officially compile VTL.

Community Manager
Status changed to: Open Ideas