Locoia
  • Overview
  • Account and User Settings
    • User types
    • Adding Users
    • Teams
    • Access Permissions
    • 2 Factor Authentication 2FA
    • Versioning and Snapshots
    • Activity Log
  • Reset your Password
  • Invoices and Payments
  • Automation
    • Flow Builder
      • Flow Building Best Practices
      • Jinja Template Language
        • Jinja: (Custom) variables, wildcards and functions
        • Magic Code Samples
      • Connectors & APIs
        • Titles and References
        • Referencing data of objects, lists, arrays - how to pass data dynamically
        • Accessing Objects with JSONPath
        • Merging nested JSON objects
        • Parsing JSONs from String
        • Response Headers & Status Codes
        • Custom Data Fields
        • Wildcard API calls and actions
        • Response cleaning
      • Text Strings, Date & Time, Numbers and Currencies
        • Text and Strings
        • Dates & Time
        • Numbers (Thousand Separators, Currencies)
      • Email-formatting
      • Code Fields
      • Running single Flow steps
      • Flow run data retention, logging, and error notifications
      • Advanced View
      • Dynamic Title
      • Custom Error Handling
      • Error Handling Flows
      • Automatic Pagination
    • Flow Debugger
      • Automatic Retrying
      • Run Flows again
      • Troubleshooting Flows
    • Community Library
  • Connectors & Helpers
    • Connectors
      • Monday.com
      • ActiveCampaign
      • Aircall
      • Allthings
      • Amplitude
      • Animus
      • Assetti
      • Awork
      • AWS RDS Database - How to connect
      • bubble.io
      • Casavi
      • Chargebee
      • CleverReach
      • comgy
      • commercetools
      • Everreal
      • Exact Online
      • Facebook Marketing
      • Fahrländer Partner
      • FastBill
      • FILESTAGE.io
      • Freshdesk
      • Freshsales
      • Google Ads
      • Google Ads Lead Form
      • Google Analytics
      • Google Chat
      • Google Drive
      • Google Sheets
      • Gmail
      • HubSpot
      • Heyflow
      • iDWELL
      • ImmobilienScout24
      • Instagram Ads
      • Intercom
      • klaviyo
      • Kiwi Opening Doors
      • Klenty
      • Klipfolio
      • Kolibri CRM
      • konfipay
      • KUGU
      • Shopify
      • S3 AWS
      • SQS AWS
      • Lambda AWS
      • Learnster
      • lexoffice
      • LineMetrics
      • Linkedin
      • Locoia
      • Notion
      • MailGun
      • Makula
      • Microsoft Dynamics 365
      • Microsoft OneDrive
      • MixPanel
      • MongoDB
      • Odoo
      • OnFleet
      • OnOffice
      • Oracle NetSuite
      • Outbrain
      • Quickbooks
      • Trello
      • PandaDoc
      • Personio
      • Pinterest Ads
      • Pipedrive
      • Plentific
      • PriceHubble
      • relay
      • REALCUBE
      • Sage ERP
      • Salesforce
      • SAP
      • Scoro
      • Seafile
      • sevDesk
      • SharePoint
      • SharpSpring
      • Slack
      • Snapchat Marketing
      • Snowflake
      • Teamleader Focus
      • Teamwork.com
      • Tableau
      • TikTok
      • TinQwise
      • The Trade Desk
      • Twitter
      • Typeform
      • WordPress
      • Xero
      • Youtube
      • Zendesk
      • Zoho CRM
      • Zoom
    • Helpers
      • Scheduler
      • Webhook
      • Dict Helper
      • Spreadsheet Helper
      • REST Helper
      • Boolean Helper
      • Multi Case Helper
      • Looper
      • FTP Helper
      • CSV Helper
      • XLSX Helper
      • Mail Sender
      • Flow Trigger
      • File Storage Helper
      • Terminate Helper
      • Delay Helper
      • SQL Connector
      • PDF Helper
      • Zip Helper
      • Data Warehouse Helper
      • XML Helper
      • Form Helper
      • Arrow
      • Error Arrow
    • Authentication Types Available
      • Setting up authentication
      • OAuth1
      • OAuth2
      • Refreshable token
      • AWS Signature
      • Basic Auth and Other Simple Authentication Methods
      • How are API versioning and API updates handeled?
      • Custom OAuth2 clients (apps)
    • Building Connectors
      • Base Connector Setup
        • Connector Auth Validation
        • GraphQL APIs
        • Rendering with User Input
      • Building Connector Actions
        • Actions Examples
      • Search Automation
      • Pagination Automation
      • Uploading Files in Actions
      • Working with SOAP APIs
    • Super Actions
    • Webhook Trigger for Connectors
    • Data Mapping and Env Variables
  • Embed - White Label Portal
    • Embed Overview
      • 1. Embed Flow
        • 1.1 Creating Embed Flows
        • 1.2 Updating Embed Flows
        • 1.3 Embed Error Handling
        • 1.4 Setting up Callbacks for Integration activation/deactivation
        • 1.5 Setting up Remote search
        • 1.6 Setting up End User logs
      • 2. Configure Embed
        • 2.1 Embed Integration via SSO
        • 2.2 Proprietary connector setup
        • 2.3 Sharing level
        • 2.4 Consent screen
        • 2.5 Account Secrets
        • 2.7 Further settings
      • 3. Integrate Embed
        • 3.1 iframe vs native embed
        • 3.2 Customizing CSS
        • 3.3 Events emitted from iframe to parent window
      • 4. Embed for End User
        • 4.1 Embed Remote Search
        • 4.2 Embed End User Logs
      • 5. Test Embed Configuration
        • Testing example
      • 6. Embed Integrations and Connector Auths
    • Embed FAQs
  • Data and Dashboards
    • Dashboards & Insights
      • Introduction to Dashboards
      • Introduction to Insights
      • Introduction to Data Sources
      • Dashboard Filters
      • Insight Marketplace - Using Pre-Built Insights
      • Writing SQL Queries
      • Useful SQL Examples
      • Charts
        • Line Chart
        • Bar and Horizontal Bar Chart
        • Stat Card
        • Pie Chart
        • Gauge Chart
        • Donut Chart
        • Stacked Bar, Horizontal Stacked Bar, and Normalized Horizontal Stacked Bar
        • Multiple Line Chart
        • Pivot Table
        • Map Chart
  • Best Practice Guides
    • Integration Best Practices
    • Integration Check List
    • CSV Files in Excel
    • Multi-Tenant Flows
    • On-Premise Integrations
    • Database Connection Setup
    • Data and General Security
    • Using Tags
    • FAQ
  • API
    • Locoia API Authentication - Personal Access Token
    • Create Connector Authentication
  • Contact us
  • Status of Service
  • Data Privacy
  • Imprint
Powered by GitBook
On this page
  • What is Jinja?
  • How Jinja is used in Locoia
  • 1. Referencing to previous steps and connectors in a flow
  • 2. Using functions and filters to format and change data
  • 3. Adding advanced logic to flow steps which cannot be easily done with existing flow helpers
  • Filtering a list by a list
  • Further Information

Was this helpful?

  1. Automation
  2. Flow Builder

Jinja Template Language

What is Jinja?

We use Jinja2 for rendering data across the app in combination with JsonPath - so both are core concepts to understand. Jinja2, short Jinja, is a template language, based on the programming language Python. It can be used within HTML code and as a simpler alternative to Python in tools such as Locoia.

One of the primary use cases of Jinja is to use it to define and refer to variables. In the first step, a variable is defined in a JSON dictionary:

{
    "name": "John",
    "age": 35
}

In a text, you can now refer to those variables by using double curly bracket ( {{ … }} ), such as:

Hello {{ name }}!

This will output: Hello John!

Logic, such as if-else logic, can also be used in Jinja:

{% if age >= 30 %}
   {{ name }} is 30 years or older.
{% else %}
   {{ name }} is less than 30 years old.
{% endif %}

Based on the variables defined above, this would output: John is 30 years or older.

How Jinja is used in Locoia

Jinja has three main purposes in Locoia

  1. Referencing to previous steps and connectors in a flow

  2. Using functions and filters to format and change data

  3. Adding advanced logic to flow steps which cannot be easily done with existing flow helpers

1. Referencing to previous steps and connectors in a flow

Similar to the variables example stated above, Jinja can be used within Locoia to reference to previous steps in a flow. For example, the flow could consist of a Dict Helper and Freshsales Connector:

The Dict Helper (dic1), in this example, contains the following dictionary:

{
    "firstName": "john",
    "lastName": "Doe",
    "email": "john.doe@example.com"
}

In order to refer to those values in the Freshsales Connector, Jinja needs to be used. To do so, one needs to enter the entire path to the value which should be referred to. The path, in this example, consists of:

  1. The reference to the connector (in this case dic1)

  2. The key within the dictionary (e.g., firstName)

The elements of the path are separated by dots, and the entire path is wrapped in double curly brackets. By using that schema, the reference to the first name is:

{{ dic1.firstName }}

The references to the fields are written into the Freshsales connector, such as:

When the flow is run, the Freshsales connector receives the following input data:

{
  "contact": {
    "first_name": "john",
    "last_name": "Doe",
    "email": "john.doe@example.com"
  }
}

2. Using functions and filters to format and change data

In the previous example, the first name is given in lower case ("john") by the dict helper; in order to send "John" to Freshales, i.e., capitalizing the first letter of a word, one can make use of the Jinja capitalize filter. Using a filter is as simple as using a pipe (|) after the variable which should be changed:

{{ dic1.firstName | capitalize }}

When the flow is run, the Freshsales connector now receives the following input data:

{
  "contact": {
    "first_name": "John",
    "last_name": "Doe",
    "email": "john.doe@example.com"
  }
}

3. Adding advanced logic to flow steps which cannot be easily done with existing flow helpers

Sometimes one might want to use logic in a connector input to change the input depending on the inserted value.

{% if '@' in dic1.email %}
   {{ dic1.email }}
{% else %}
   Check for the correct E-Mail! {{ dic1.email }}
{% endif %}

If the email would not contain an @ symbol, e.g., john.doeexample.com, the Freshsales connector would receive the following input data for the email field:

Check for the correct E-Mail! john.doeexample.com

Filtering a list by a list

Based on the list below (L1), you want to filter another list (L2) and only get the domains back from L1 which are starting with L2.

L1:

[
  "questions@airtable.com",
  "legal@airtable.com",
  "privacy@airtable.com",
  "integrations@airtable.com"
]

L2:

[ "questions@", "legal@" ]

Solution:

{% set emails = L1 %}
{% set white_list = L2 %}
[
  {% for email_beginning in white_list %}
    {% for email in emails %}
        {% if email_beginning in email %}
             "{{ email }}",
        {% endif %}
    {% endfor %}
  {% endfor %}
]

Further Information

PreviousFlow Building Best PracticesNextJinja: (Custom) variables, wildcards and functions

Last updated 8 months ago

Was this helpful?

Example Flow
References in Freshsales Connector

You can find out more about referencing using Jinja .

Functions and filters in Jinja are similar to Excel functions; they can, for example, , , or .

For example, it could be checked if the email contains the @ symbol, and if that is the case, the email is inserted into the field; otherwise, a comment and the email is inserted into the email field. This can be done by using a Jinja if-else statement in combination with the :

The official documentation, which includes most of the Jinja functions which you can use in Locoia as well as extensive explanations of the correct syntax, can be found .

In order to test your Jinja code, you can use a third party . Please note that you should not enter any confidential information (such as company or customer data) in such tools, as they might store your input data.

here
change date formats
replace certain words and letters
capitalize words
Jinja in test
here
Jinja playground