AI package: structure of the file
In short
The AI package is a Markdown file with which any AI can change a template or build a new one. It contains the task, the description of the template format, the template with the list of its building blocks, on request sample data, selected images and a directory of all reachable tables. By default, the AI answers with a change list (JSON Patch, RFC 6902); the designer checks it when it is uploaded and applies it as a single undo step. It delivers a whole template only on explicit request.
What it is for
The AI assistant works in Microsoft 365 Copilot and reads everything from Dynamics itself. The AI package is the way for every other AI: it gets no access to Dynamics, but everything it needs in one file. How users create the package is described in Working with an external AI.
Structure of the file
The sections appear in this order:
- Task for the AI: what the file is for, how the AI should answer (by default exactly one change list in the format JSON Patch as a
.jsonfile, otherwise as exactly one JSON code block; the whole template only on explicit request), what a change list looks like (kinds, paths per RFC 6901,teststeps) and what it must observe, including: The examples in the format are in English, and labels and texts in the template are written by the AI in the language of the template (culture) or of the user. Where the request goes is the sentence “The user will tell you in a moment what to change or build.” - Template format: the whole description from the chapter Template format.
- The current template: the JSON of the open template, as “Save” writes it, but without sample record and without internal notes of the designer (keys that begin with
_). - Building blocks in this template, only if the template contains building block objects: for each building block object its name, binding, prefix and its variables, plus what the AI may change on a building block object (see Building blocks: Building blocks and AI).
- Sample data, only with the check mark “Include sample data”: a record of the primary source and the records attached to it through the relationships of the template. The keys are the paths of the placeholders (
nameunderKundeis{{Kunde.name}}). Lists show at most three rows, further sources their first three; empty fields are missing, long texts are shortened, images and files are only noted. Results of rules are not included. - Images: the images of the image library that are checked in the window, with short name, name, format and size in pixels, plus how the AI inserts an image and how it supplies a new one.
- E-invoice, only with the check mark “Include the e-invoice standard”: the checked standards (identifier, version, output, document forms), whether the template already has the e-invoice turned on, the other standards of the environment, then per section the details in one line (identifier · name · type · required), the lists with their details, the common codes of the code lists, for the Dynamics invoice the suggestion table as JSON and, at the end, the description from Own standards for the e-invoice. If several standards are checked, there is a section “Standard” for each checked standard, with its output, its details and its common codes. What all of them have in common appears only once: the explanation of the lines, the description of own standards, the suggestion table if it is the same for all, and a code list that an earlier section already contains in the same form (it then says “as in …”). The AI assigns the template to exactly one of these standards. The explanation file itself is not included.
- Table directory: all tables that the template can reach through its data sources, down to the sixth level, each exactly once; those used by the template first. First an overview, then, per table under “### Table <name> · <display name>”, the fields with display name and type, the option values as code and label and the relationships (N:1 and 1:N) with navigation name and lookup column.
- Once more at the end: the answer rule in one paragraph, because an AI often retains the end of a long file better than the beginning.
Field types in the directory
For each type, the directory names the value for type in fields:
| Type | type |
|---|---|
| Text | string |
| Number | number |
| Currency | money |
| Date | date |
| Yes/No | boolean |
| Choice, multi-select | optionset |
| Lookup | lookup |
| Image | image |
| File | file |
A lookup appears as the field _<column>_value and as a relationship. A condition compares option values through <field>_code, for example statecode_code == 3.
Name, language, size
- The file name is the name of the template, converted as for the PDF (see Full preview and PDF: The file name), with
-ki.mdat the end, with an English interface-ai.md; “Auftragsbestätigung” becomesauftragsbestaetigung-ki.md. With an English interface, the task, the format and all own texts of the file are in English, so that the AI answers in English. - The table directory makes the file large: It contains every table that the template reaches down to the sixth level, with all option values. Measured in a test environment with 2,360 tables: roughly 12 to 13.5 MB. After downloading, the designer names the size and the number of tables.
- The e-invoice section, by contrast, is small: measured with the suggestion table, roughly 84 KB for ZUGFeRD 2.5.2 (EXTENDED), roughly 52 KB for XRechnung 3.0 and roughly 100 KB for both together, because the shared parts appear in it only once.
Caution
With sample data, the file contains real values from Dynamics, including personal data. The check mark is therefore always off. Who users may give the file to is described under Working with an external AI: The settings in the “AI package” window.
The way back
- The AI delivers a change list (JSON Patch) as a
.jsonfile or as a code block in its answer. If, on request, it has written an own standard for the e-invoice, it is in the same file:{ "aenderungen": [ … ], "standards": [ { "dateiname": "….xsd", "inhalt": "<xs:schema …" } ] }. After a confirmation prompt, the designer uploads it before the changes; an identical existing one (the content is compared) is not uploaded again, and if the upload fails, it applies nothing. - The user uploads it with “Upload AI changes”, as a file or as pasted text (see Working with an external AI: Taking over the AI’s answer). Both go the same way: The designer looks for the list in the text, also between sentences and in code blocks; if it finds several, it reports that and applies none.
- Applying and checking is done by the core of Smart Templates, the same place as for the AI assistant: all or nothing, at most 500 steps, then the same check as for the import (see Template format: What the check reports on import). The open template goes along with it; that is why it also works for a template that has not been saved yet.
- For an image that the AI supplies in
daten, the designer uses the same image from the image library if it is already there (the content is compared); otherwise it creates it there. After that, the image object contains only the short name. When an image is not applied and the spot stays empty is described under Managing templates: Images included. - The result goes into the open template as one undo step; “Save” makes it effective. If the core rejects it, the designer shows the error list, and the template stays unchanged. The user can give the list back to the AI; the task tells it that it should then correct exactly these spots and deliver the change list again.
If the user explicitly asks for a whole template, they open it as before through “Import” (see Managing templates: Importing). It opens as a new template that has not been saved yet; with “Duplicate” the user stores it in Dynamics (see Managing templates: After opening).
The same check also runs for changes by the AI assistant; it sits in the core of Smart Templates, not in the browser.
Good to know
Like the AI assistant, the external AI also delivers by default only its changes as JSON Patch; the same place in the core applies them (action st_VorlageAendern for the AI assistant, see Actions and APIs). An AI that copies out a whole template can falsify uninvolved spots in the process; the check catches formal errors, but not silently changed texts. Therefore compare a whole template especially carefully with the full preview.