Expression Copilot

  • Updated

Get CX Actions

Do you want access to this new feature? Contact your Zingtree Account Manager or our Support Team.

Introduction

The Expression Copilot is an AI assistant that helps you to create, understand, and troubleshoot Advanced Logic expressions. You can have a conversation with the Copilot in natural language and it will provide you with an expression to paste into your Advanced Logic node. The Copilot is specifically trained to assist with generating and evaluating expressions in an expression language.

Important Note Read on for some tips that will greatly improve your success with the Expressions CoPilot.

 

How to Access the Expressions Copilot

The Expressions Copilot is visible when authoring an Advanced Logic node. In your logic node, toggle to Advanced. You'll now see the Copilot icon near the bottom-right.

  • Add a Logic Expression
  • Converse with the CoPilot and paste its response into your expression.

Awareness

Variables: The CoPilot is aware of variables that have been defined in your tree. It can provide guidance and construct expressions based on the provided context and variable names, but does not have explicit information about specific values that the variables might take beyond what you provide. For example, if you mention certain values or case-sensitive preferences, the Copilot will take those into account for the expressions. If you have specific known or expected values for particular variables, provide those details so it can tailor the expression correctly.

Language: The CoPilot uses this supported Expression Language.

Prompts

Constructing your prompt in a clear and concise manner is key to getting accurate responses from the Copilot. Here are some examples:

Example #1: 

Example Prompt:

if age is greater than 45 but less than 55 and the state is 'California' 
and residence is 'Own'

Example Response:

Based on the provided variable definitions and the conditions you specified, you can construct an expression as follows:

let ageInt = int(age);
ageInt > 45 && ageInt < 55 && state == "California" && residence == "Own"

This expression assumes that the `age` variable is initially given as a text and needs to be converted to an integer for numerical comparison. The `state` and `residence` variables are directly compared as strings.

Why this prompt worked well:

  • The prompt told the Copilot what to expect for textual values of the state and residence variables by specifying 'California' and 'Own' which match the value options the tree is collecting. If we had given the prompt all lower-case values like 'california' and 'own' the expression provided by the Copilot would fail. It is important to prompt the CoPilot with exactly the values you are expecting.

Example #2

Example Prompt:

if width x height is greater than 100

Example Response:

You can construct an expression to evaluate if the product of `width` and `height` is greater than 100 as follows:

width * height > 100

In this expression, `width` and `height` are used directly assuming they are numbers, and their product is compared with 100.

Why this prompt worked well:

  • We prompted the Copilot with our exact variable names of width and height.
  • The expression language supports math operations. The Copilot is aware of the supported language and provided a response that is accurate for our needs.

Expressions with Dates

The Copilot will provide the most accurate expression when you construct your prompt with as much detail as you can. For example:

  • The variable name you used (or passed) when collecting the date.
  • The format of the date, e.g., mm/dd/yyyy
  • Valid time units for duration are "ns", "us", "ms", "s", "m", "h". The max unit is hours only. Not days.

Example of a Well Constructed Prompt with Date Calculation:

I have a form variable with the name of 'purchase_date' and would like
to check if the date is older than 7 days. The purchase_date is in mm/dd/yyyy format.

Response:

date(purchase_date, "01/02/2006") < now() - duration("168h")

Why this prompt worked well:

  • We prompted the Copilot with the name of our date variable
  • We prompted the Copilot with our date format of mm/dd/yyyy. To verify your own date format, add a form field with the data type 'Date'. Connect that node to a new node with ##ALL DATA## in the content area. Preview the tree, collect the date, and view the output.
    2025-02-04_12-04-11.gif

 

Conversations

Feel free to converse with the Copilot about its job and focus. In the example below, we asked the Copilot what variables it is aware of in this tree. 

If the Copilot provides you with an expression that does not work as you expected, continue to converse with the CoPilot and ask it what it might need from you to be more accurate for your specific use case.

Was this article helpful?

1 out of 1 found this helpful

Have more questions? Submit a request

Didn't find what you need?

Our friendly customer support team is here to help

Submit a Ticket

Looking for help or advice?

Reach out to our knowledgeable community of users.

Zingtree Community