2

Is there any good solution for sending nested (not flat) data to triggered send?

Suppose I want to send a transaction confirmation email. Ideally, I would like to send a json (or json-like) object like this one (every transaction can have many payment details and translations):

{
    "transaction":{
        "number":"...",
        "recipient":{
            "name":"John Smith",
            "country":{
                "name":"Colombia"
            },
        },
        "sender":{
            "name":"Jane Smith"
        },
        "payment_details":[
            {
                "name":"Amount payable:",
                "value":"€101.00"
            },
            ...
        ]
    },
    "translations":
        "subject":"Translated subject",
        ...
    }
}

And use it directly. But I haven't found anything like it in the documentation, so I assume it's not possible.

So far I came up with 2 solutions:

  1. Create a separate data extension for every nested structure (For example 'Translations' DE: email_id, key, value). But this will require to add a lot of records for every email we send.
  2. Create a long text attribute with xml and parse this xml using AMPscript, as described here: http://help.exacttarget.com/en/documentation/exacttarget/content/ampscript/using_ampscript_with_the_web_service_api/passing_content_to_a_triggered_send_message_at_send_time/. But that seems hacky and error-prone. I'm also worried about the length of the text field. Is there any limit? Xml is very verbose.

Is there any better approach?

Thanks.

2

You should send an XML payload to your trigger and then use an XSLT to transform it using the TransformXML() AMPSCript function in your email template.

The XSLT files are stored in the Portfolio.

One link tracking gotcha with XSLTs -- you'll need to have ET/SFMC Support enable the WRAP_HTTPGET_URLS business rule with a Quality of 99 and prefix the links in your XML file with httpgetwrap| so they get properly tracked.

1

I agree with Adam's recommendation. You can pass the hierarchical data as an additional attribute in your trigger call. You need to add a text field to the triggered send data extension the trigger writes in order to capture this information. Alternatively, you could add an list attribute to store this data. But, I would recommend the data extension route. Storing in a list attribute would require that you overwrite the value each time the trigger is called for the same subscriber.

  • p.s. be sure to encode the XML payload or use <![CDATA]> to prevent any parsing issues by the Soap API. – David Devoy Mar 16 '16 at 18:55
  • p.s.s You could just as easily pass the payload as JSON. However, email ampscript language has functions for parsing XML. But, does not have similar functions for processing JSON. – David Devoy Mar 16 '16 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.