Drafts a new supply-side (supplier) auto-message template (English only) for the operations service. Use when the user asks to create, draft, or write a new automated message template for supply / suppliers / purchases. Requires the ContextualData struct definition and a brief description of the message's purpose.
Draft an English message template body (and subject) for a new supply-side (supplier-facing) automated message in the operations service, using Tera syntax.
Before starting, ensure you have both of the following. If either is missing, ask the user before proceeding:
Query the operations database for the 10 most recent active English supply-side message templates to use as style / tone reference:
SELECT DISTINCT mt.id, mt.designation,
mtlv.id AS version_id, mtlv.subject, mtlv.body
FROM templated_supplier_messages tsm
JOIN message_template_language_versions mtlv
ON mtlv.id = tsm.message_template_language_version_id
JOIN message_templates mt
ON mt.id = mtlv.message_template_id
WHERE mtlv.language_alpha2 = 'EN'
AND mtlv.deactivated_at IS NULL
ORDER BY mtlv.id DESC
LIMIT 10;
Read through these examples to understand the current tone, structure, common patterns (greetings, sign-offs, variable usage), and formatting conventions.
Every supply message template has access to two categories of data:
These variables are inserted into the Tera context for every supply message, regardless of trigger. The base context is built in:
operations/Service/src/supply/messages/templates/mod.rs
The Supplier struct (defined in operations/Service/src/supply/messages/mod.rs)
is inserted at root level. Available top-level Tera variables:
supplier.id — the supplier's retailer ID (SupplierId)supplier.username — the supplier's username (String)supplier.email — the supplier's email (Option<String>)template_language — the language code (e.g. "EN")Self-healing note: If the Supplier struct or build_base_context has moved
or been renamed, search the codebase for fn build_base_context in the supply
messages module to find the current location, then update this skill file
with the correct path so future invocations don't waste time searching.
Accessed in templates as contextual_data.<field>. The structure depends on
what the user provides (see Required inputs).
base_tera/mod.rs)Defined in operations/Service/src/supply/messages/templates/base_tera/mod.rs.
Available in templates via {{ function_name(args) }}:
purchase_identification(lang, purchase) — formats a human-readable purchase
identification string. The purchase argument must be a serialized
PurchaseDataForSupplier object (typically iterated from
contextual_data.purchases_data_for_supplier). Handles submission/shipping
IDs, titles, EAN, and internal reference. Supports all languages.purchases_identification — iterates over
contextual_data.purchases_data_for_supplier and renders each purchase using
purchase_identification(). Use with {% include "purchases_identification" %}
when the message needs to list affected purchases.Write an English template body (and subject line) using Tera syntax that:
{{ }} and {% %}
expression against the available data.{% include "purchases_identification" %} when the message needs to
reference specific purchases (most supply messages do).{% if %}, {% for %}) for optional or
list-based data.consumer_introduction equivalent — address the supplier directly.Before presenting the draft:
{{ }}, {% %} blocks are properly balanced.
All {% if %} have {% endif %}, all {% for %} have {% endfor %}.Show the user: