How to handle list type data in transactional email

Anonymous
Not applicable

How to handle list type data in transactional email

Hi all,

I have implemented Java client sending transactional emails including data from tokens sent in rest API call. So far everything has gone smoothly but now I faced a new challenge - I should include variable length lists to email from tokens sent in rest API call. Velocity script would be most the obvious solution, but can't find information if tokens sent in API call exists in Velocity context. Does anyone have information on this? Are there any other possible ways to include lists to emails?

Thx,

Janne

5 REPLIES 5
SanfordWhiteman
Level 10 - Community Moderator

Re: How to handle list type data in transactional email

Velocity tokens can't be sent as temporary tokens (along with the Schedule/Request Campaign APIs).

You have to update the token separately/permanently using the Asset API, then send the mail.

Anonymous
Not applicable

Re: How to handle list type data in transactional email

Sandford,

Thank you for your reply. That is what I was afraid of. Unfortunately updating tokens separately is no-go, the email is sent easily with thousands of different token sets in one "transaction" on client side.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to handle list type data in transactional email

Why can't those key-value pairs (let's not call them "tokens," because they need not be individual tokens) be stored in only ​one ​Velocity token, storing a HashMap keyed on the Lead ID?

Anonymous
Not applicable

Re: How to handle list type data in transactional email

Sanford, thank you for the suggestion,

Single token with JSON content would do as it is be possible to parse JSON in Velocity. I'm afraid storing this JSON to Lead would be just asking for trouble. It is possible that multiple emails are sent for a single Lead with different token values within seconds (or milliseconds depending on latency). I doubt that consistence in this case is guaranteed, meaning all these emails would have expected content.

SanfordWhiteman
Level 10 - Community Moderator

Re: How to handle list type data in transactional email

I doubt that consistence in this case is guaranteed, meaning all these emails would have expected content.

You can guarantee that the Velocity token will be updated when you receive the HTTP response, so not sure I see the specific concurrency issue here, long as you serialize each token update and its subsequent Request Campaign.