home

Browse documentation

ezyVet Knowledge Center

Get access to documentation, training, and other high-quality resources.

Twig templates and AI assistants

An AI assistant can write a document template with Twig template variables. You give the AI assistant a description of the document and the names of the variables. Then you add the template in ezyVet and do a test of it.

Use an AI assistant that can open web pages. Some examples are:
  • Microsoft Copilot
  • ChatGPT
  • Google Gemini
Note: An AI assistant can give incorrect information. Always do a test of the template before you use it.

What to give the AI assistant

Give the AI assistant these items in one message:
  • The text in this topic, with a description of the document
  • The rows of the Variables tables of the applicable Twig template variables pages
  • Optional: The source code of a standard template for the same type of document

The description of the document

The description tells the AI assistant:
  • The type of document
  • The record that you print the document from
  • The data to show in each part of the document

This is an example of a description:

an invoice that I print from the invoice record.
At the top of the invoice, show:
- The name of the invoice
- The date of the invoice
- The due date
- The name of the client
- The name of the patient
Then show a table of the line items, with these columns:
- Product name
- Quantity
- Unit price, with tax
- Total, with tax
Below the table, show:
- The subtotal, without tax
- The tax
- The total
- The amount that the client paid
- The amount that the client must pay

The rows of the list and the standard template

Many AI assistants cannot open the links to the list of Twig template variables. Thus, you must paste the rows of the list into the message. For an invoice, you copy the rows of the Variables table of Twig template variables: Invoices and Twig template variables: Invoice line items. For more information, refer to Twig template variables: Full list.

Copy all the columns of each row. The AI assistant uses only the variables in the first column. These are examples of copied rows:

NameClassic template system equivalent?Function
{{ invoice.Date }}{InvoiceDate}Shows the date of the invoice.
{{ invoice.Total }}{InvoiceTotal}Shows the total dollar value of the invoice.
{{ invoice.AnimalName }}NoShows the name of the patient of the invoice.

If a standard template is available, the AI assistant uses it as an example. For more information, refer to Source code of standard Twig templates.

The text to copy into the AI assistant

This is the text that you copy into the AI assistant:

Write an ezyVet document template with Twig template variables for: <describe-the-document-here>

If I did not paste the rows of the ezyVet list under this text, do not write the template. Ask me for the rows.

Use only the variables in the ezyVet list, and follow the rules for each variable type:
- ezyVet Twig template variables: https://docs.ezyvet.com/en/browse-documentation/ezyvet/reference-information/template-variables/template-variables-twig/twig-template-variables-full-list
- Variable types: https://docs.ezyvet.com/en/browse-documentation/ezyvet/reference-information/template-variables/template-variables-twig/twig-template-variables-variable-types
- Source code of standard ezyVet Twig templates: https://docs.ezyvet.com/en/browse-documentation/ezyvet/reference-information/template-variables/source-code-of-standard-twig-templates
- Twig documentation: https://twig.symfony.com/doc/3.x/

Under this text, I pasted the rows of the ezyVet list for the record. I can also paste the source code of a standard ezyVet template. Use only the variable names in the rows. The rows have three columns: the Twig variable, the classic template system variable, and the function. Use only the Twig variables in the first column, in {{ }}. Do not use the classic variables in { }, because they do not work in a Twig template. If the document must show data that is not in the rows, leave it out and write it under "Data not found".
If I pasted a standard template, use it as an example, but do not copy it. Remove the columns and data that the document does not need, the <style> block, and the nested loops.

If you cannot open the ezyVet list, say so. Then ask me to paste the rows of the list that the document needs. Do not guess variable names. Use the variable names exactly as the list or a standard template writes them. Do not change their spelling or add words.

The template is a document template for a printed document or a PDF. Twig does not work in ezyVet email templates. If the document must show patient data, use a template type that has the patient (a contact template has no patient). Use only variables that are available from the record that you print the document from.

Rules for the HTML:
- Do not add <html>, <head>, or <body> tags. Use inline styles.
- Put each {% %} tag inside a paragraph, list item, or table cell. Exception: to show a table row for each item in a list, put {% for %} and {% endfor %} directly between the table rows. Do not put other tags around them. Do not put {% %} tags in HTML comments.
- When the function of the variable shows a date, use the dateformat filter (for example, |dateformat). Use the date filter (for example, |date("d/m/Y")) only if I ask for a different date format.
- Use the moneyformat filter only when the function of the variable shows a price or a total (for example, |moneyformat).
- If a variable that you need is not in the ezyVet list, do not use a different name. Leave it out.
- Make sure that the function of each variable agrees with its label.
- Show the data in the parts of the document and in the sequence that I wrote.

Give your answer in this format, with these five headings. Always give all five sections.

1. Template type
The type to select for the document template (for example, Invoice).

2. Record to print from
The ezyVet record to print the document from (for example, an invoice or a patient record).

3. Variables used
A table with these columns: variable, function from the ezyVet list, label in the template.

4. HTML template
The full HTML for the template content, in one code block, ready to paste into the ezyVet Source code dialog box.

5. Data not found
The data that you could not find in the ezyVet list. If you found all the data, write "None".

In the text, you replace <describe-the-document-here> with a description of the document. Below the text, you paste the rows and the source code that you copied.

The answer from the AI assistant

The AI assistant gives its answer in these sections:
  • Template type
  • Record to print from
  • Variables used
  • HTML template
  • Data not found

The HTML template section has the template that you add in ezyVet. The Data not found section shows the data that is not in the rows that you gave.

How to add the template to ezyVet

You add the template as a document template. For more information, refer to Make a document template (basic procedure). When you add the template:
  • Select Use New Templating Engine
  • In the Template Group box, select the group that the AI assistant gave
  • In the HTML box, select the horizontal ellipsis ( ⋯ ), then select Source code, and paste the HTML

How to test the template

To do a test of the template, you print the document from the record that the AI assistant gave:
Important: The invoice setting changes the printed invoices of all staff members. Before you change the setting, record the name of the template that the setting uses at this time. If your template is not correct, select the recorded template again.

In the printed document, compare the labels with the table of variables that the AI assistant gave. Look for empty values, tables that have no rows, and labels that do not agree with the value. A variable name that is not in the list shows no value. An AI assistant can also select a variable that has a different function.