SOLVED

Re: Transactional Email with dynamic Interest List

Go to solution
Anonymous
Not applicable

Transactional Email with dynamic Interest List

I am in the process of setting up a transactional email that will be triggered off an API call, I have everything working except for how to pass in values through the REST api and use that in my velocity foreach script.

For testing purposes, I have this:

#set( $myList = [ "Item 1", "Item 2", "Item 3" ] )

<ul>

#foreach ($cat in $myList)

     <li>$cat</li>

#end

</ul>

I'm looking to replace $myList with the values I pass in through my api call, for reference i'm using the /rest/v1/campaigns/{ID}/trigger.json endpoint to add the lead to my smart campaigns.

Any help would be great!

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Transactional Email with dynamic Interest List

If you can't wait for the sync, you can either

(a) Pass a dynamic {{my.token}} that holds an already-formatted HTML block based on the CO data.

(b) Copy the raw CO data into a temporary lead field (like Last CO Mirror or suchlike) as JSON or XML, and then call the trigger. A Velocity token can then take care of formatting, making this more manageable than (a) once built.

View solution in original post

8 REPLIES 8
SanfordWhiteman
Level 10 - Community Moderator

Re: Transactional Email with dynamic Interest List

You can't pass dynamic Velocity tokens with an API call. While you can pass non-Velocity tokens (text or rich text) with the Request Campaign endpoint, you can't access those tokens from static Velocity tokens.

You will have to make a separate API call to update Velocity token(s). Of course this can lead to race conditions of you're triggering a campaign for multiple leads in parallel.

Anonymous
Not applicable

Re: Transactional Email with dynamic Interest List

Thanks Stanford.

What would be the recommendation on how to accomplish what i'm after? We need the email to go out as quick as possible. For more context, we have Salesforce as our CRM and this 'interest' information about a lead will be in a custom object.

SanfordWhiteman
Level 10 - Community Moderator

Re: Transactional Email with dynamic Interest List

If the info is in already-synced COs, why do you need to pass any new token values at trigger time? What is it that wouldn't be accessible in existing data?

Anonymous
Not applicable

Re: Transactional Email with dynamic Interest List

We need this email to be sent within 1 minute, my understanding is the sync between marketo and salesforce is 5+ minutes. I'm newer to Marketo so please let me know if i'm mistaken!

SanfordWhiteman
Level 10 - Community Moderator

Re: Transactional Email with dynamic Interest List

If you can't wait for the sync, you can either

(a) Pass a dynamic {{my.token}} that holds an already-formatted HTML block based on the CO data.

(b) Copy the raw CO data into a temporary lead field (like Last CO Mirror or suchlike) as JSON or XML, and then call the trigger. A Velocity token can then take care of formatting, making this more manageable than (a) once built.

Anonymous
Not applicable

Re: Transactional Email with dynamic Interest List

Re: (a) Makes sense.

Re: (b) Would you pass that into a lead field through another call? So you'd populate that field, then add the lead to the smart campaign?

SanfordWhiteman
Level 10 - Community Moderator

Re: Transactional Email with dynamic Interest List

Yes, (b) requires another API call to the update.

There's even  (c) if you want to go there: make the data available via webhook and have the lead fetch the data that way when triggered. Saves the extra API call.

Anonymous
Not applicable

Re: Transactional Email with dynamic Interest List

Awesome, this is exactly what I needed. Thank you!