--- name: email-template-write description: "Writes the HTML of a Brevo email. Use when the user asks for a campaign, newsletter, promotion, automation email or transactional template (order confirmation, password reset), including personalization with Brevo's template language - contact attributes such as {{ contact.FIRSTNAME }}, defaults, if/elif/else, and loops over event data or feeds. Picks the template type, gathers a short brief, writes email-safe HTML that follows Brevo's design rules, then hands it to email-template-check before anything is saved." metadata: version: 1.0.0 status: beta author: brevo --- # Write an email template Writes one HTML email that looks good in email clients, follows Brevo's design rules, uses Brevo's template language correctly, and suits the template type (campaign, automation email or transactional template). It saves nothing to a campaign and sends nothing: campaigns go through `email-campaign-create`, drag-and-drop designs through `email-template-to-dnd`. | Step | Tool | |---|---| | Name the account; footer company name and address | `accounts_get_account` | | Brand kit: logo, colours, fonts, social links (optional) | `branding_get_brand` (via `email-brand-kit`) | | Contact attribute names for personalization | `attributes_get_attributes` | | Sender for a transactional template | `senders_get_senders` | | Save a transactional template as HTML (inactive) | `templates_create_smtp_template` | | Read back what was saved | `templates_get_smtp_template` | | Change a saved template (content, subject, sender, activation) | `templates_update_smtp_template` | | Check the sender's domain is authenticated | `domains_get_domains` | Writing the HTML never needs a connection: without one, or without the account, attribute, sender or brand-kit tool, write it in offline mode (step 5, "No connection") and say which checks couldn't run. Saving and previewing need their tools: if one is missing when you reach that step, stop that step, tell the user their Brevo connection doesn't offer it, and give the HTML. ## Brevo connection rules - Every Brevo call goes through the Brevo MCP server's tools. The user's connection carries their authentication (OAuth). **Never ask for an API key, never ask the user to paste a key into the chat, and never put a key in a file or command.** - If a tool returns 401, or 403 about the login or token, ask the user to reconnect Brevo in their agent's settings. - A 403 "required scope not present" (`permission_denied`) means this connection doesn't allow that action; reconnecting won't change it. Say so, skip that step, and carry on with the fallback the skill gives (for a template render: the test send and its outcome check). If the skill gives no fallback for that step, stop the step and tell the user. - If a tool a step needs is missing from your tool list, stop that step and say that the user's Brevo connection doesn't offer it (connections can differ). Don't improvise with other tools. Writing HTML never needs a tool; offer it, and the steps to finish in Brevo. - On a sub-account, pass `subaccount_id` on every call: every Brevo tool takes it per call, and a call without it acts on the main account. - Show a tool's error message as returned, after a plain-language summary. Don't invent a cause the tool didn't give. ## Where this skill comes from - You already have this skill: it is in your context, whether installed, from the plugin, uploaded or fetched with `get_brevo_guide`. Don't call `get_brevo_guide` for it again in this conversation. - To have it without a tool call next time, install it once: the Brevo plugin from `getbrevo/brevo-skills`, `npx skills add getbrevo/brevo-skills`, or, with a shell, the Brevo CLI (`npm i -g @getbrevo/cli`, then `brevo skill install`). `brevo skill check` lists copies that are behind. - Once per conversation, call `list_brevo_guides` with `installed` set to the version in the `metadata` of each Brevo skill you have, if the tool accepts `installed`; otherwise call it with no arguments and compare the versions yourself. For a `stale` one, follow its `update` hint. - If you don't have the skill, call `get_brevo_guide` with its name: it returns the current text. ## Working rules for every step - Follow the steps in order. Don't skip, merge or reorder them, and don't add steps this skill doesn't have. - Use only the tools this skill names, with the arguments it describes. Never invent a tool, a parameter, an ID or an email address; ask the user instead, one question at a time. - Before anything is created, changed or sent, say in plain words what will happen and wait for the user's yes. A yes covers only what you described. - Read each Brevo object once per conversation and reuse it. Re-read only after something changed it. - Report a result only from what the tool returned. If a call failed or returned nothing, say so; never describe it as done. - Reply in the user's language, and keep names, IDs and addresses exactly as Brevo shows them. ## Conversation cache (every email skill) Keep what you read from Brevo in this conversation and reuse it, instead of calling the same tool again. The cache is your own notes in the conversation, never a file. Key every entry by account **and** sub-account ID (none for the main account), and note when you fetched it (`fetchedAt`). Never show or reuse an entry from another account or sub-account. | What | Keep it | Fetch again when | |---|---|---| | Account (company, address, own email), senders, contact attributes | About 10 minutes | Time is up. An attribute in the email isn't in the cached list and the cache is more than about a minute old: fetch the attributes once more before reporting it (the user may have just added it). The user switches account or sub-account, or says they changed it in Brevo | | Sender domains (whether each is authenticated) | Same as senders | Same as senders | | Brand kit | The whole conversation (one read) | The user says they changed it in Brevo, or switches account. After this conversation's own save, update the cache with the approved values; don't read it back | | Templates this conversation created or read | The whole conversation | The user says they edited it in Brevo's editor (fetch it before a preview or test). After this conversation's own update, apply the change to the cache | | Lists and segments | Not cached | Fetch when needed | - **A failed fetch never blocks.** Skip the check that needed it, say so in one line ("I couldn't read your contact attributes, so that check was skipped"), and go on. - **Errors:** a 5xx is retried once, then the user is told it is on Brevo's side. A 404 on a cached template: drop it from the cache and tell the user it no longer exists. A 429 on the brand kit: keep the cached kit and say the hourly limit is reached. - **"What do you have cached?"** List each entry (what, account, when fetched) without secrets. **"Refresh"** clears everything; fetch again as each step needs it. - If you can't tell how much time has passed, fetch the 10-minute items again when the user starts a new email. - Never keep API keys, tokens or passwords in the cache or anywhere in the conversation. **Call budget** for a transactional template (write, check, save, preview, test): about 11 calls with the cache (account, senders, attributes, brand kit, save, 3 sample renders, sender domains, test send, outcome) against about 16 without it (the account read 3 times, attributes and senders twice, and the template read back). Each fix round that re-checks attributes would add one more call without it. ## Quick rules (enough for short and medium emails) - **Layout:** the document skeleton in [email-design-rules.md](references/email-design-rules.md) ยง1; one `
` or heading: there it works and renders at send time. Tags around section rows are lost when the HTML is converted (they don't become display conditions or Dynamic content). - All four padding sides on every section cell (`0px` too: a missing side becomes 15px); `1px` instead of `0px` top and bottom on the section cell of a multi-column section; the hero image alone in its own `padding: 0px` section; heading, text and button of one block in one cell; text margins bottom only (`margin: 0 0 16px`). - No `