Workflow agents
Agents that carry out quote / pro forma, e-invoice draft, payment reminder and lead enrichment work step by step on the server — tools loaded on demand, approvals, a log of every step, retry from where it stopped and nightly learning from your corrections.
A workflow agent carries a job from start to finish: it reads the company's records, calculates price and payment terms, prepares the quote or invoice draft, writes the e-mail draft and opens the follow-up task. Unlike the report-producing ready-made agents, it creates records — and waits for your approval where needed.
Workflow agents live under Automation › Agents › Workflow agents (/ajanlar/akis); the AI agents strip on the company card starts them in one click. They need the AI module (Advanced plan or your own key).
Workflows
| Workflow | What it does | Waits for your approval |
|---|---|---|
| Quote / pro forma | Reviews the opportunity; gets products and contracted prices; calculates price, discount, payment terms and currency with the quote calculator (quote_calc); creates the quote. The quote PDF works as a pro forma |
Opening an opportunity, changing a stage, creating an order |
| Invoice draft | Calculates lines, VAT, discount, payment terms and FX rate from uninvoiced orders; checks totals; opens an e-invoice / e-archive draft | Opening the draft — sending is always yours, from the e-document screen |
| Payment reminder | Finds overdue invoices in the ERP, days overdue and totals; writes a polite but clear e-mail draft; opens a follow-up task in 3 working days | — (nothing is sent; the draft goes to Drafts) |
| Lead enrichment | Reads the company card, contacts, calls, e-mails and the company's website; writes the findings as a note and opens a task for the next step | Updating company fields, adding / updating contacts, opening an opportunity |
The agent never sends e-mail, SMS, WhatsApp or e-invoices; delete, merge and workflow / template tools are never given to it. Quote approval rules (discount limit, floor price) apply to the agent too.
How it works
- Start: pick the workflow and the company; tick the opportunity for a quote or orders for an invoice, and add a note if you like (e.g. 2 t B-20, 10% discount, EUR).
- Runs on the server: the page shows progress step by step; you can close the browser. If a run is interrupted (server restart, lost connection) the scheduler resumes it from where it stopped. You get a notification when it finishes, needs approval or stops.
- Approval: for an action that needs approval the agent pauses and explains why. You can correct the values (e.g. payment days, VAT, lines) and approve, or reject; the agent continues accordingly.
- Result: a short summary and links to what was created (quote, e-invoice draft, e-mail draft, task, note).
Tools are loaded only when needed
The agent doesn't send hundreds of tool schemas with every request. The first request carries only a one-line index of four modules:
| Module | Contents |
|---|---|
crm_records |
company / contact search, company card, contacts, activity, notes, relations, company website |
sales_tools |
opportunities, products and contracted prices, quote calculation and creation, orders, tasks, call logging, e-mail drafts |
invoice_tools |
account balance and overdue invoices, VAT / discount calculation, FX rates, e-invoice draft, payment reminder e-mail |
crm_analytics |
counts and totals, reports, activity search, sales dashboard |
Only the module the model asks for is opened. The first request is usually more than 90% smaller than one carrying every tool schema; the run page shows both sizes and the time to the first response.
Every step is logged
Every model call and tool step is written to the step log: step number, attempt, tool, module, input, output, status (ok · schema error · not allowed · timeout · awaiting approval · rejected), duration and any correction you made on approval. The Steps list on the run page shows them; the API returns them too (below).
Tools run in isolation: if the input doesn't strictly match the schema the tool isn't run and the error goes back to the agent (which corrects and retries); every tool has a time limit (20 s to read, 40 s to write); an error inside a tool is rolled back and never affects anything else in the CRM.
Retry from where it stopped
If a step can't be fixed or the AI doesn't respond, the run is Stopped with the step it stopped at. Retry from where it stopped: successful steps are restored from the log — tools and the model aren't called again, no task or draft is created twice — and only the failed step runs again, with its error message fed back to the agent.
Learned rules
The changes you make to the quotes, e-invoices and e-mail drafts the agent prepared, and your corrections on the approval screen, are reviewed every night (02:00 by default). When the same correction repeats at least 3 times (adjustable: 2–4) and consistently, it becomes a lasting rule:
| Rule | Example | Scope |
|---|---|---|
| Default payment terms | Default payment terms 45 days. | company · workspace |
| Discount cap | Discount cap 12%. | company |
| Default discount | Default discount 5%. | company |
| VAT rate | VAT rate 10%. | product |
| Quote currency | Quote currency USD. | company |
| FX source | Foreign-currency quotes and invoices use the CBRT selling rate. | workspace |
| E-mail style | closing / greeting, length, address added to CC | company · workspace |
| Tool hint | patterns that failed on the first try and worked on the second (e.g. date format) | workspace |
On the next run the relevant company, product and workspace rules and recent correction examples are added to the agent's instructions. The quote calculator and invoice preparation also apply the rules directly; a quote below the discount cap isn't created.
Automation › Agents › Learned rules (/ajanlar/kurallar) lists rules with their evidence, confidence and how often they were used. Admins switch a rule off, reject it (it isn't proposed again with the same value), delete it, add a rule by hand, run learning now with Learn now, and change the settings: apply new rules right away, summarise e-mail style with AI, require approval for every write, minimum repeats and the learning hour. Sales users see active rules.
API
With a Bearer key (REST API):
| Endpoint | Description |
|---|---|
GET /api/v1/agent/runs |
Recent runs and available workflows |
POST /api/v1/agent/runs |
{"workflow": "quote_prepare", "company_id": 402, "opportunity_id": 77, "order_ids": [], "instructions": "…"} → 201 |
GET /api/v1/agent/runs/<run_id>?steps=1 |
Status, metrics, step awaiting approval; with steps=1 the step log (step_index, tool_name, input_json, output_json, status, duration_ms, user_override_json) |
POST /api/v1/agent/runs/<run_id>/approve |
{"approve": true, "input": {…corrected values…}} or {"approve": false, "reason": "…"} |
POST /api/v1/agent/runs/<run_id>/retry |
Retry from where it stopped |
GET /api/v1/agent/skills |
Active learned rules |
Workflow keys: quote_prepare, invoice_draft, collection_reminder, lead_enrich.
Limits
- Up to 18 steps and 26 model calls per run; a 10-minute time limit (a run that hits it can be retried from where it stopped).
- Up to 3 concurrent runs per user.
- The agent runs with the permissions of the person who started it: role, module access and record visibility apply as usual. Sales users see their own runs; admins see all.
- Invoice drafts need e-invoicing set up and billing permission.
- Step logs are kept for 120 days.