- Newest
- Most votes
- Most comments
Based on the behavior you're experiencing, Amazon Connect Message Templates have limitations when working with complex data structures from Customer Profiles. Here's what's happening and how to work with it:
Current Limitations:
Customer Profile attributes appear to be processed as strings rather than maintaining their complex object structure when passed to message templates. When you store an array of objects in a Customer Profile attribute, the template engine doesn't preserve the nested object properties, which is why {{this.Add_on_Name__c}} returns empty values.
What Works:
The #each helper does work with arrays, but it works best with simple arrays of primitive values (strings, numbers) rather than complex objects. This is why your second approach with pre-formatted strings like ["Sunroof — $1500", "Leather Seats — $2000"] works correctly - the helper can iterate over the array and access each string element using {{this}}.
Recommended Approaches:
-
Pre-format your data: Store your list data as an array of pre-formatted strings in the Customer Profile attribute, as you discovered works. While this reduces flexibility, it's the most reliable approach given current limitations.
-
Use Custom Attributes: When creating message templates, you can pass data through CustomAttributes (key-value pairs) rather than relying solely on Customer Profile attributes. This gives you more control over the data structure at template rendering time.
-
Flatten complex data: If you need multiple pieces of information, consider storing them in separate arrays that maintain parallel indices, or create multiple simple attributes rather than one complex nested structure.
For Dynamic Lists:
For use cases like quotes, invoices, or add-ons, the most practical approach is to pre-process and format your data before storing it in Customer Profiles or passing it as custom attributes. Structure your data as simple arrays of formatted strings that can be reliably iterated using the #each helper with {{this}} to reference each element.
The template system is designed to work with flattened data structures rather than deeply nested objects, so data preparation and formatting before template rendering is key to achieving the desired output.
Sources
Use message template helpers - Amazon Connect
TemplateAttributes - Amazon Connect
Relevant content
- asked 3 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 4 years ago
