?? Understanding Workato Message Templates: A Guide with Examples

?? Understanding Workato Message Templates: A Guide with Examples

Workato message templates enable you to create static templates for commonly used messages. They utilize Mustache as the templating language, making it easy to generate HTML, text, JSON, or XML messages. By separating the message composition logic (designing the message) from the generation logic (sending the message), developers can modify message formats without altering the underlying recipes.

? Key Features of Workato Message Templates

  1. Logic-Less Design: Templates lack control flow logic like if/else or looping. Instead, they use tags for variable substitution, conditional blocks, and list iteration.
  2. Dynamic Variable Support: Variables, enclosed in {{ }}, enable dynamic content insertion.
  3. Input Schema: Each template has an associated schema defining variables, supporting both scalar (string, integer) and complex data types (object, array).
  4. Reusability: Features like partials allow for reusable template snippets, enhancing modularity.
  5. Separation of Concerns: Developers can focus on the message’s design independently of its execution.

??? Template Basics and Syntax

1.Variable Substitution: Variables are placeholders for dynamic content.

Example:

<p>{{name}}</p>        

?If the variable name is "Fiona Summers," the output will be:

<p>Fiona Summers</p>        


2. HTML Escaping: Variables are HTML escaped by default. To disable escaping, use triple braces ({{{ }}}) or an ampersand ({{& }}).

3.Sections:

  • Object Sections: Rendered once if the variable is an object.
  • List Sections: Rendered multiple times for lists.
  • Inverted Sections: Rendered if a variable is missing, false, or empty.

4.Comments: Comments, enclosed in {{! }}, are ignored during rendering. 5.Partials: Reusable snippets defined with {{> partial_name }} inherit the parent context.


?? Real time examples

For one of our enterprise customers, we implemented an integration for onboarding and offboarding, utilizing an HTML message template to design the format according to their specific requirements.

Input:

{ "name": "John", "company": "Twenty20 Sytems", "location": "New Jersey", "joining_date": "31-01-2025" }        

Output:

Another example involves creating a custom page in Confluence with employee data. Using this message template, we implemented the format to meet the specified requirements.?

Input:

[{ ? ? "First_name": "John", ? ? "Last_name": "Doe", ? ? "Gender": "Male", ? ? "Age": 29, ? ? "Department": "Engineering", ? ? "JobTitle": "Software Engineer", ? ? "EmployeeId": "E12345", ? ? "City": "New York", ? ? "Country": "USA" ? }, ? { ? ? "First_name": "Jane", ? ? "Last_name": "Smith", ? ? "Gender": "Female", ? ? "Age": 34, ? ? "Department": "Marketing", ? ? "JobTitle": "Marketing Manager", ? ? "EmployeeId": "E12346", ? ? "City": "Los Angeles", ? ? "Country": "USA" ? }, ? { ? ? "First_name": "Carlos", ? ? "Last_name": "Gomez", ? ? "Gender": "Male", ? ? "Age": 41, ? ? "Department": "Sales", ? ? "JobTitle": "Sales Executive", ? ? "EmployeeId": "E12347", ? ? "City": "Madrid", ? ? "Country": "Spain" ? }, ? { ? ? "First_name": "Anna", ? ? "Last_name": "Ivanova", ? ? "Gender": "Female", ? ? "Age": 28, ? ? "Department": "Finance", ? ? "JobTitle": "Financial Analyst", ? ? "EmployeeId": "E12348", ? ? "City": "Moscow", ? ? "Country": "Russia" ? }, ? { ? ? "First_name": "Liam", ? ? "Last_name": "Brown", ? ? "Gender": "Male", ? ? "Age": 35, ? ? "Department": "Human Resources", ? ? "JobTitle": "HR Manager", ? ? "EmployeeId": "E12349", ? ? "City": "Sydney", ? ? "Country": "Australia" ? }]        

Output:


?? Using Templates in Workato Recipes

To use templates in recipes:

  1. ? Add the "Create message" action from the Workato Message Template adapter.
  2. ?? Map template variables to datapills or hardcoded values.
  3. ?? Generate messages dynamically during recipe execution.


?? Conclusion

Workato message templates are a powerful feature for creating structured, reusable, and dynamic messages. By leveraging their flexibility and modularity, developers can simplify automation workflows while maintaining high-quality communication outputs. Whether for emails, notifications, or reports, message templates provide an efficient and scalable solution??

If you're interested in automating updates or exploring similar integrations, feel free to reach out: Learn more here.

Saravana Kumar

CTO @ Twenty20 Systems | We are Hiring !

2 周

Great write up Vinay Kumar N ??

要查看或添加评论,请登录

Vinay Kumar N的更多文章

社区洞察

其他会员也浏览了