# ESL (UbiQuity's Scripting Language)

## Introduction to ESL

The ESL (Scripting Language) is a dynamic scripting language designed to make it easy to customise UbiQuity. You can add ESL pretty much anywhere: email templates, layouts, forms, surveys and events.

* Reference and re-format fields and questions, write if/then statements, loops and create and reference your own functions - it's a full development language.

This help section is part resource and part tutorial and will help you get started quickly with ESL. The examples below are focused around email but ESL can be used throughout Engage.

Please don't hesitate to contact us for help or to give us feedback and ideas.

## An understanding of what comprises ESL

When ESL is used in UbiQuity it lets UbiQuity know that it should process the code on the server and return the correct value before the HTML page is rendered.&#x20;

The syntax to use will change depending upon what you want UbiQuity to do, but will ultimately fall back to one of the following code examples.

### **Merge Fields**

Merge fields can be inserted throughout UbiQuity and will pull in data specific to each contact. If the field has no value it will return as Null. An example of this is:

```
Hi [Database.Name], this is an email just for you!
```

You can learn more about [data types](/documentation/keep-learning/esl-ubiquitys-scripting-language/data-types.md) and how to [format merge fields](/documentation/keep-learning/esl-ubiquitys-scripting-language/merge-field-formatters.md) for more info.

### **Directives**

Double curly braces **{{** will represent the opening of a logic sequence, or this is the start of an operation that will determine what will happen next.

Usually these are used for creating different results for different contacts based on a value from a merge field.

```
{{ If([Database.Name] eq "John") }}
```

Check out our [directives documentation](/documentation/keep-learning/esl-ubiquitys-scripting-language/directives.md) for more info.

### **Functions**

A pipe **|** represents a function in ESL. Functions are pre-rolled sequences of code that make repetitive tasks easier. They are often used for transforming data, such as making text uppercase, or adding two numbers together.

```
| function( parameters go here ) |
```

You can use functions inside directives (e.g. in an if statement):

```
{{ If(|function( parameters go here )| eq true) }}
```

If not used in a directive you can merge the result of a function out onto your page. To do this you'll need to wrap the function in square bracket&#x73;**.**

```
[| SmartCase([Database.Name]) |]
```

Some ESL options are available as both directives and functions. The benefit of using a function is that they can be nested inside each other, allowing you to perform complex actions. When nesting functions you only need to use the pipes around the outermost function.

In this example the cast function is nested inside the format function so that we can cast a text field as a mobile number field, then format this in a nice way. The result will be merged onto the page.

```
[| Format(Cast([Database.Mobile Number], "MobileNumber"), "f") |]
```

Check out our [functions documentation](/documentation/keep-learning/esl-ubiquitys-scripting-language/functions.md) for more info.

### **ESL Comments**

These are viewable within HTML source code and when in designers (e.g. when creating an email template), but anywhere that creates a personalised version such as in previewing as a contact or in live versions they will be removed.

They are not used very often but allow you to leave notes to users on the UbiQuity interface that will be removed for the version that the user actually sees.

```
{~~ This is an ESL Comment, Users won't see me ~~}
```

```
<!-- {~~ --> 
    If you wrap the ESL Comment tags in HTML comment tags then you won't see the comment tags on the interface 
<!-- ~~} -->
```

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ubiquity.co.nz/documentation/keep-learning/esl-ubiquitys-scripting-language.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
