SOLVED

Re: Can pass trigger token with webhook?

Go to solution
Gunpreet_Kaur1
Level 3

I am not well versed with webhooks, asking on behalf of a dev, can you pass trigger tokens like {{trigger.subject}} with webhooks?

Thank you!

1 ACCEPTED SOLUTION
SanfordWhiteman
Level 10 - Community Moderator
9 REPLIES 9
Tyron_Pretorius
Level 9 - Champion

Another workaround I have found useful is to use the {{campaign.description}} token in webhooks so that the same webhook can be used for different smart campaigns but have different payloads or be sent to different endpoints by editing the description of the campaign sending the webhook

Tyron Pretorius
SanfordWhiteman
Level 10 - Community Moderator
I mean yeah... but a {{my.token}} for that would be less disruptive, allowing the Description to be used for its original purpose.
Tyron_Pretorius
Level 9 - Champion

What if you have multiple campaigns within a single program then a {{my.token}} won't work if you want to use a single webhook?

 

 

Tyron Pretorius
SanfordWhiteman
Level 10 - Community Moderator
Yes.
Gunpreet_Kaur1
Level 3

We tried like in the screenshot below, got an error - 

Gunpreet_Kaur1_0-1612380884631.png

Gunpreet_Kaur1_1-1612380932973.png

Any suggestions?

Thank you!

 

SanfordWhiteman
Level 10 - Community Moderator
Well, you can't create correct JSON like that. The string field (the {[trigger.token}}) is going to be JSON-encoded, then you have it inside another JSON string = broken JSON.
SanfordWhiteman
Level 10 - Community Moderator

Fundamentally, you can't do this attempt at concatenation within a JSON payload.

 

The Marketo {{trigger.token}} could be used on its own as a JSON String property:

{
  "someProp" : {{trigger.token}}
}

 

And the {{lead.id}} can be used inside a JSON String only because it is itself a Number (so will be printed exactly as-is):

{
  "someProp" : "Some text and then the {{lead.id}}"
}

 

If you need to pass a value that consists of static text plus the {{lead.id}} and {{trigger.token}}, you could set a new custom lead field to that final value using Change Data Value, then do:

{
  "someProp" : {{lead.New Field that was set using Change Data Value}}
}

 

(I wouldn't do this myself — I'd use a custom service that relays to the original webhook — but should work for you.)

Gunpreet_Kaur1
Level 3

Thanks for the detailed answer. Appreciate it! I'll pass it along

Gunpreet_Kaur1
Level 3

Thanks for your reply. How it should be - can you guide us?