--- name: automation-create description: "Creates a Brevo automation workflow as a draft, in one call, from a trigger and its steps. Use when the user asks for an automation or a workflow in Brevo, for example \"send a welcome email when someone joins my newsletter list\", \"email customers 2 days after their order\" or \"remind contacts on their birthday\". Confirms the account, reads which triggers and steps the account can use, looks up every list, segment, attribute and template ID with Brevo tools, validates the whole workflow, shows the plan, and creates the draft only after a yes. Also edits an existing automation (\"change the delay to 3 days\", \"swap the email\", \"add a step\") by sending its whole new definition, after showing what changes and who is affected. Steps run one after the other; a percentage split can divide contacts between paths, and a go-to step can jump back. Never activates without the user's explicit go-ahead." metadata: version: 1.0.0 status: beta author: brevo --- # Create an automation draft Builds one Brevo automation workflow (its triggers and its steps), checks it against the account, and saves it as a **draft**. It never activates the automation as part of creating it, never invents an ID, and never creates a second automation to fix the first without the user's go-ahead. It also edits an existing automation in place (section 8). | Step | Tool | |---|---| | Name the account and ask the user to confirm it | `accounts_get_account` | | See which trigger and step types the account can use | `automation_get_catalog` | | Get the fields of each type you will use | `automation_get_step_schema` | | Look up IDs: lists, segments, attributes | `lists_get_lists`, `segments_get_segments`, `attributes_get_attributes` | | Look up or save the email templates, check senders | `templates_get_smtp_templates`, `email_editor_create_template`, `senders_get_senders` | | Look up the SMS templates | `transac_templates_get_sms_templates` | | Check the whole workflow, nothing saved | `automation_validate_workflow` | | Create the draft | `automation_create_workflow` | | Report what was created | `automation_get_workflow` | | Find an existing automation's ID from its name | `automation_list_workflows` | | Edit an existing automation (read it with `format: request`, check with `workflow_id`, then save) | `automation_get_workflow`, `automation_validate_workflow`, `automation_update_workflow` | | Activate, only when the user asks | `automation_update_workflow_status` | If one of these tools isn't in your tool list, stop that step and tell the user their Brevo connection doesn't offer it (connection rules below). ## 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. ## 1. Collect the inputs - **Account:** call `accounts_get_account`, name the account and ask the user to confirm it (skip if already confirmed in this conversation). If it fails (for example 424 `missing_plan_data`), tell the user you couldn't read the account details and ask them to confirm they are connected to the right Brevo account; then go on with the automation tools. Don't stop there. - **What starts it:** the trigger in the user's words ("joins my newsletter list", "places an order", "on their birthday"). - **What it does:** the steps in order, with the waits between them ("wait 2 days, then send the welcome email"). - **The emails:** an existing template the user names, or one to write. - **Name:** a short name for the automation; propose one if the user gives none. - **How often a contact goes through it:** by default each contact runs an automation at most once, ever. When the user says every, each, whenever, weekly, yearly, "on every order" or "on every visit", set `reentry` to `{"allowed": true}` (with a `delay` if they give a minimum gap); if the wording doesn't say, ask. - **Optional message settings, only when the user mentions them:** email tags, the frequency cap, a send window (days and hours, or one exact date and time) for an email or SMS, and cc or bcc. Don't ask about them otherwise. For a send window, ask the time zone if the user didn't give it; never assume one. - **Event data in a message, only when the user wants it:** when an email or SMS should show data of an event (`{{ params.* }}` variables, "the deal name", "the order total"), ask which event: the one that started the automation, or the contact's latest event of a given kind (for example the latest deal created). See `event_data` in section 4. Ask for what is missing in one message. Don't ask the user for IDs: you look them up. ## 2. Read what the account can use 1. Call `automation_get_catalog`. Only the types it lists are accepted. If the user's trigger or step is not in it, say so plainly and offer the closest listed type, or to build the rest and let the user add that part in the Brevo editor. For `custom_event` it also lists `event_names`, the custom events the account already receives. A trigger in `unavailable_triggers` exists but needs something first (for `order_created` and `cart_updated`, eCommerce): tell the user its `message`, what to do in Brevo, and never say the trigger doesn't exist. `readiness: no_event_yet` means it works but starts with the account's first such event. 2. Call `automation_get_step_schema` once for each type you will use. Use exactly its field names and allowed values. A field with `x-lookup` names the tool that returns its value. 3. A step in the catalog can list `unavailable_fields`: fields not enabled for this account, refused if sent. For `call_webhook`, check it before using `auth` or `headers`: when they are listed, webhook authentication is not enabled for the account (an account setting, not a plan limit). Tell the user the webhook can only be sent without them and ask before building it that way; don't send them anyway. For `send_sms`, `template_id` is listed when SMS templates are not enabled for the account: write the SMS as `content` instead, after telling the user. **Paths.** Steps run one after the other: each step has `next` (the following step's `id`, or `null` for the last step of a path). Three steps change the flow: - `percentage_split` divides contacts at random between 2 or more paths (an A/B test): each variant has a `percentage` and a `next`, the first step of its path (or `null`). The split's own `next` is `null`. Paths never join again: a step follows at most one other step. - `go_to_step` jumps back to an earlier step (a loop); it ends its path (`next: null`). - `start_another_workflow` moves the contact into another automation. There are no other conditions or splits: if the user asks for one ("if they opened, else...", "wait until they buy"), say it isn't supported here and offer the rest; the user can add the condition in the editor. ## 3. Look up every ID Never write an ID from memory or from the user's wording alone: take it from a tool. The lookups can be large: `attributes_get_attributes` returns every attribute with the full option lists of system attributes (countries, time zones), and `templates_get_smtp_templates` returns each template's HTML. Call each lookup once per conversation, keep only the names, types, options and IDs you need, and don't paste the output into the chat. | Field | Where it comes from | |---|---| | A list (`lists`) | `lists_get_lists`; match the user's words to a list name. If several match, ask which. | | A segment (`segment`) | `segments_get_segments`, the same way | | An attribute (`attribute`); a date attribute for an anniversary | `attributes_get_attributes`; use its name exactly as returned, and its type. A name in another case is accepted only when a single attribute matches it; when several differ only in case it is refused with `invalid_value` listing them, so send the exact name. Brevo default attributes such as `OPT_IN`, `DOUBLE_OPT-IN` or `JOB_TITLE` can be set, as in the editor; only an attribute Brevo maintains itself, such as `_LAST_EMAIL_OPEN_DATE`, is refused with `not_available` (a name starting with `_` alone doesn't make one). For a category, send both `index` (the option's `value` in the attribute's `enumeration`, what is written to the contact) and `value` (that option's `label`), for the same option: a mismatch is refused with `invalid_value`. A custom date is `YYYY-MM-DD`. | | An email (`send_email.template_id`) | `templates_get_smtp_templates` for an existing template, with a small `limit` (5 to 10) and the template's name from the user as a filter where the tool takes one: each template comes with its whole HTML, so a large page doesn't fit in your context. Read only `id`, `name`, `subject` and `sender`, and never repeat the HTML. For a new email, write it with `email-template-write`, check it with `email-template-check`, and save it with `email_editor_create_template` as an `automation_template` (see `email-template-to-dnd`), always with `senderId` and `senderName` of an active sender: the automation sends from that sender, and a template without one warns `template_no_sender` and cannot send. | | A sender | `senders_get_senders`; each email template needs an active sender before the automation can send it. | | A number attribute (`update_contact_attribute` with `type: number`) | `attributes_get_attributes` (its float type). With `set`, send `operation`: `replace` writes `value`, `add` and `subtract` change the contact's current value by `value` (a JSON number, not negative). Ask which one if the user's words don't say ("set to 10" or "add 10 points"). `operation` is refused on any other type. | | A multiple-choice attribute (`type: multiple_choice`) | `attributes_get_attributes`: `value` is a non-empty array of option labels from the attribute's `multiCategoryOptions`, exactly as listed. If the user's words match no option, ask. | | Email `cc` or `bcc` | `{"contact_attribute": ""}`, the exact name of a **text** attribute from `attributes_get_attributes` that holds an email address. Fixed addresses aren't supported: say so if the user gives one, and offer a text attribute or leaving it out. | | An SMS template (`send_sms.template_id`) | `transac_templates_get_sms_templates`, when the user names an existing SMS template; it is copied for the automation and replaces `content` and the US compliance fields. `sender` and `sms_type` are still required. | | Blocklist senders (`blocklist_contact.senders`) | `senders_get_senders`, the sender email addresses. Brevo doesn't check them, so never type one from the user's wording alone. | | A custom event (`event_name`) | One of the `event_names` that `automation_get_catalog` lists for `custom_event`; match the user's words to it. If none matches, say the account hasn't received that event yet. | | Delays, SMS text, webhook URL | The user. Delays are ISO 8601 durations: `P2D` (2 days), `PT3H` (3 hours), `P1W`, `P1M`. A webhook URL must be a public http or https address. | Lists and segments are sent as `{"id": , "name": ""}`, both from the lookup. Never pull contacts into the chat. ## 4. Validate Build the whole body: ```json { "name": "Welcome series", "triggers": [ {"type": "added_to_lists", "lists": [{"id": 12, "name": "Newsletter"}]} ], "steps": [ {"id": "wait", "type": "time_delay", "time_delay": {"duration": "P1D"}, "next": "welcome"}, {"id": "welcome", "type": "send_email", "send_email": {"template_id": 345}, "next": null} ] } ``` - A trigger's fields sit next to its `type`. A step's fields sit in an object named after its type (`"send_email": {...}`). An unknown field is reported as `unknown_field` at its path. - `id` is your own short label (letters, digits, `_`, `-`); Brevo assigns the real step IDs. - At least one step must do something (not only delays), and the last step can't be a delay. - `reentry` is optional: `{"allowed": true, "delay": "P1M"}` lets a contact enter again. Omitted, each contact runs the automation at most once, ever. Set it for recurring intents (every order, every visit, every week, every year). - `anniversary` compares only the day and month of the date attribute, so it matches every year. A yearly email (birthday, signup anniversary) needs `reentry` allowed, or it is sent only the first year. - A schedule `time` is 24-hour `H:MM` or `HH:MM` (`9:00`, `09:00`, `14:30`) with an IANA `timezone` (`Europe/Paris`). `day_of_week` is ISO: 1 = Monday ... 7 = Sunday. - A `contact_match_one_segment` schedule takes exactly the fields its `interval` needs, and any other (an explicit `0` included) is refused with `invalid_value` at `schedule.`: - `daily` (the default): optional `weekdays_only`. - `weekly`: `day_of_week` (1-7). - `monthly`: `repeat_on` (`first_day_of_month`, `last_day_of_month`, `specific_date_of_month` or `specific_day_of_week`). - `yearly`: `month` (1-12) and `repeat_on`. - `repeat_on: specific_date_of_month` adds `date_of_month` (1-31; in a yearly schedule it must exist in `month`: at most 29 in February, 30 in April, June, September and November). `specific_day_of_week` adds `week_of_month` (`first` ... `last`) and `day_of_week`. `first_day_of_month` and `last_day_of_month` add neither. If the user's words don't give a field the interval needs ("monthly" without which day), ask; don't pick one. - A `send_window` (on `send_email` or `send_sms`) is `{"timezone": "Europe/Paris", "days": [{"day": "monday", "from": "09:00", "to": "18:00"}]}` or `{"timezone": ..., "exact_date_time": "2026-12-24T09:00:00+01:00"}`, never both. Times here are two-digit `HH:MM` (`09:00`, not `9:00`), `from` before `to`, each day once; an exact date must be in the future and at most 2 years ahead. - `manual_trigger` has no fields. It starts only for the contacts someone adds by hand in the Brevo app once the automation is active; these tools can't add contacts to it. Tell the user that when you propose it. - `removed_from_lists` takes `lists` like `added_to_lists`; moving a contact from one list to another doesn't start it. - `delete_contact` (`{}`) deletes the contact and its data, which can't be undone. Use it only when the user asked for it, always as the last step (`next: null`), and name it in the plan as a permanent deletion. - `event_data` (on `send_email` or `send_sms`, optional) is what the message's `{{ params.* }}` variables read: `{"mode": "event_triggered_automation"}` for the event that started the run, or `{"mode": "latest_event_instance", "source": "deals", "event_name": "deal_created"}` for the contact's latest event of that kind, whatever started the run (`source` and `event_name` required, an event the account has). Without it, a workflow whose triggers are all events uses the triggering event; other workflows get no event data. `event_triggered_automation`, or a webhook's `include_event_data`, with no event trigger gives the warning `event_data_unavailable`: the variables stay empty, so offer `latest_event_instance` instead. - `start_another_workflow` takes `workflow_id` from `automation_list_workflows` (never this automation itself) and optionally `step_id`, a step id of that automation as `automation_get_workflow` returns it. The target must be active when contacts reach the step, otherwise they skip it (warning `destination_inactive`): tell the user. - `go_to_step` takes `step`, the id or label of the step to jump to (not itself, not another go_to_step). Put a `time_delay` inside the loop: Brevo sends a contact through the same go_to_step at most 5 times, and a loop with no delay runs them back to back (warning `loop_without_delay`). - `percentage_split` takes `variants`: `[{"percentage": 50, "next": "a"}, {"percentage": 50, "next": "b"}]`. Percentages are above 0, at most one decimal, and add up to 100. Two variants work on any plan; more need an Enterprise or Pro plan (up to 10), otherwise `restricted_by_plan`. Ask the user for the split if they didn't give it. - `link_tracking` (on `send_sms`, optional): `true` shortens and tracks the SMS links. - `blocklist_contact` takes `scope`: `transactional` (transactional emails from the `senders` listed; `senders` required), `marketing` (every marketing email; no `senders`) or `both` (`senders` optional). If the user's words don't make the scope clear, ask. - Validation checks templates, custom events, lists, segments and attributes against the account (`list_not_found`, `segment_not_found`, `attribute_not_found`), but not blocklist senders: use only the ids and senders the lookup tools returned. Call `automation_validate_workflow` with the body. Read `valid`, not the status code: - Each item of `errors` has a `path` (for example `steps[1].time_delay.duration`), a `code` and a `message`. Fix every item from the tools, never by guessing, then validate again. - After three tries that are still not valid, stop and show the user the remaining problems in plain words; ask how to go on. - `warnings` don't block the draft (for example an email template with no sender, an inactive one, or `reentry_recommended` for a recurring trigger without re-entry). Tell the user about every one of them, each with its `message`; never drop or merge one. For `reentry_recommended`, set `reentry` if the user wants the automation to repeat for the same contact, or keep it once per contact if that is what they asked. The others to relay and offer a fix for: - `list_name_replaced` / `segment_name_replaced`: a list or segment name you sent differs from the account's; the account's name is stored. Name it as the account has it. - `unicode_needed`: the SMS text has characters outside the GSM alphabet while `unicode` is false; offer `unicode: true` or plain characters. - `us_compliance_off`: `organisation_prefix` or `unsubscribe_instructions` were sent with `manage_us_compliance` false and are not stored; offer to turn it on or drop them. - `event_data_unavailable`: not every trigger is an event, so a webhook's `include_event_data` or the SMS's `{{ params.* }}` variables get no event data for contacts that didn't start from one; tell the user they stay empty. ## 5. Show the plan and get a yes Show, in one message: ``` Create a draft automation: - Name: - Starts when: - Re-entry: > - Then: 1. 2. ... - Emails: