Custom Tokens for a Webhook | Community
Skip to main content
June 21, 2017
Question

Custom Tokens for a Webhook

  • June 21, 2017
  • 1 reply
  • 6265 views

Hi all,

We need to create a custom token with custom object fields in order to push this data by a webhook.

We're trying to preserve our API quota. Is this possible?

I'm able to create an email script token to pull in the fields but it's only at program level. Am I doing this wrong?

1 reply

SanfordWhiteman
Level 10
June 21, 2017

You can't use Velocity tokens directly in webhooks, as you've found. I recommend you use JSON text fields instead of Custom Objects (in many ways JSON is more powerful, since your "poor man's" COs can then be accessed on LPs as well).

FlowBoost Pro has what we call Floxy (FlowBoost Proxy) that does allow real COs to be passed to external services, but it's better to avoid the need entirely.

Peter_Fedewa
Level 2
April 16, 2019

Hi @Sanford Whiteman,

I am trying to scale a system where we have VTL script tokens in the JSON for an endpoint that we call on click of an email that is within the campaign where those VTL tokens reside.

Are you saying that these tokens will not resolve within the flow step that calls the webhook for each contact that clicks?

Excerpt of the JSON:

{

"perk": {

"name": {{my.promoPerk1}},

"num_days_active": {{my.daysActive}}

},

"message": {{my.promoMessage}},

...

}

my.promoPerk1 is a VTL script token in the campaign as is my.promoMessage.

Scripting for my.promoPerk1

#set ($vertical = ${Product_Metric__cList.get(0).Vertical__c}) ## Salesforce object

#set ($perk = "")

#define ($beautySpa)

20% off all services

#end

#define ($food)

20% off one main dish

#end

#define ($shopping)

25% off one full price item

#end

#define ($default)

20% entire purchase

#end

#if ($vertical == "Beauty & Spa")

#set ($perk = $beautySpa)

#elseif ($vertical == "Food")

#set ($perk = $food)

#elseif ($vertical == "Shopping")

#set ($perk = $shopping)

#else

#set ($perk = $default)

#end

$perk

I think my other option is to make one campaign for each vertical that we target and use text tokens for each value (instead of script tokens). I know that will work it is just not as clean and takes a lot more time to set up when we want to do one of these campaigns.

Thanks for any help!

SanfordWhiteman
Level 10
April 16, 2019

Are you saying that these tokens will not resolve within the flow step that calls the webhook for each contact that clicks?

Yes: Velocity is evaluated in an email assembly context (including View as Web Page) only.

P.S. Careful with that use of formal notation in the first line. You can use simple notation there (only use formal when proven necessary).