SOLVED

Re: Can pass trigger token with webhook?

Go to solution
Gunpreet_Kaur1
Level 3

Can pass trigger token with webhook?

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

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Can pass trigger token with webhook?

9 REPLIES 9
SanfordWhiteman
Level 10 - Community Moderator

Re: Can pass trigger token with webhook?

Yes.
Gunpreet_Kaur1
Level 3

Re: Can pass trigger token with webhook?

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

Re: Can pass trigger token with webhook?

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.
Gunpreet_Kaur1
Level 3

Re: Can pass trigger token with webhook?

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

SanfordWhiteman
Level 10 - Community Moderator

Re: Can pass trigger token with webhook?

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

Re: Can pass trigger token with webhook?

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

Tyron_Pretorius
Level 8 - Champion

Re: Can pass trigger token with webhook?

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

Re: Can pass trigger token with webhook?

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 8 - Champion

Re: Can pass trigger token with webhook?

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