> For the complete documentation index, see [llms.txt](https://developer.vario-software.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.vario-software.de/documentation/scripting/use-cases.md).

# Use Cases

What VARIO Cloud scripting can do for marketing, sales, purchasing and product data — from newsletter sync to AI-generated product texts.

This page shows what VARIO Cloud scripting can do beyond validating fields. Each use case describes the idea, how it is triggered and which services it combines. All of them are built only from services that exist today; the API details are on the linked reference pages.

The use cases combine four building blocks:

| Building block                  | Starts the script                         | Typical use                                                                               |
| ------------------------------- | ----------------------------------------- | ----------------------------------------------------------------------------------------- |
| **Workflow**                    | A record is saved, created or transferred | React immediately to a business event                                                     |
| **Batch run on a selection**    | A user starts a batch action on a list    | Bulk updates, one-off data jobs                                                           |
| **Scheduled script processing** | A cron expression (System → Task-Manager) | Nightly jobs, polling external systems                                                    |
| **HTTP client + secrets**       | Called from any of the above              | Talk to external APIs, see [HTTP & Secrets](/documentation/scripting/http-and-secrets.md) |

***

## Marketing

### Sync Newsletter Contacts on Every Save

Whenever an address is saved and the customer has opted in, the script creates or updates the contact in the newsletter tool, for example Brevo, Mailchimp, CleverReach or HubSpot. When the opt-in is revoked, a second branch unsubscribes the contact.

* **Trigger:** workflow on `account: Nach dem Speichern`
* **Services:** `accountService` to read the address and its e-mail contact, `httpClientService` with the API key as a secret placeholder in a header
* **Setup:** a custom field for the opt-in, the tool's API host on the whitelist, a secret with the API key

### Ask for a Review After the Invoice

When an order is transferred into an invoice, the customer receives an e-mail asking for a review. Text, layout and review link live in a report group; the script only decides when to send it and passes the invoice number as a placeholder.

* **Trigger:** workflow on `document: AFTER_TRANSFER`, limited to customer invoices
* **Services:** `outputHelper` to build a mail output request with the customer as recipient, `accountService.sendNotification()` to send it through the output module **Adress-Listen**, see [Output](/documentation/scripting/output.md)
* **Setup:** a report group in **Adress-Listen**, an e-mail consumer

### Segment Customers by Revenue Every Night

Every customer gets a segment A, B or C based on the net revenue of the last twelve months. Selections, newsletters and campaigns then filter by segment.

* **Trigger:** scheduled script processing on a selection of all customers
* **Services:** `vqlService` for the revenue sum, `accountService` to write the segment into a custom field
* **Setup:** a custom field for the segment; turn on **Workflows ausschalten** so the update does not trigger address workflows

### Pull Leads from a Web Form

Every 15 minutes the script fetches new submissions from a form service and turns them into addresses with an e-mail contact and a CRM deal created from a template. A selection that returns exactly one record serves as a plain timer.

* **Trigger:** scheduled script processing
* **Services:** `httpClientService` with a bearer token secret, `accountService`, `dtoFactory`, `crmDealService.createNewDtoByTemplate()`
* **Setup:** the form service on the whitelist, a secret with its token, a deal template

### Product Feed for Google Shopping or Price Comparison Sites

Every night the script writes the articles of a selection with number, name and price into a CSV or XML feed in the DMS, or pushes the feed to the portal's API. For standard formats, check the built-in automated data exports first.

* **Trigger:** scheduled script processing on an article selection
* **Services:** `ioFactory` writers into a DMS document or a string collector, optionally `httpClientService`, see [Files & Export](/documentation/scripting/files-and-export.md)
* **Setup:** a DMS document type for exports

***

## Sales & CRM

### Post Won Deals to Slack

Every won deal appears in the sales channel with title and volume the moment it is closed.

* **Trigger:** workflow on `crm-deal: Nach dem Speichern`, comparing the closing type with the previous state
* **Services:** `crmDealService`, `httpClientService` with a bot token secret
* **Setup:** `slack.com` on the whitelist; incoming webhooks do not work because secrets are not resolved in URLs

### More Sales Ideas

| Idea                                                      | How                                                                           |
| --------------------------------------------------------- | ----------------------------------------------------------------------------- |
| Assign a sales rep by postcode when an address is created | Workflow on `account: Vor dem Speichern`, `userAndGroupService`               |
| Ask the sales manager to approve high discounts           | Workflow on `document: Nach dem Speichern` with split gateway and user action |
| Create a follow-up task seven days after an offer         | Workflow with a timeout element, `crmTaskService.createNewDtoByTemplate()`    |
| Notify a Teams or chat channel about large orders         | Workflow on `document: Nach dem Speichern`, `httpClientService`               |

***

## Purchasing, Stock & Logistics

| Idea                                                                                    | How                                                                                                                    |
| --------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| Pull purchase prices from a supplier API                                                | Scheduled script processing on an article selection, `httpClientService`, `priceService`                               |
| Adjust purchase and sales prices to current commodity prices (copper, steel, aluminium) | Scheduled script processing on an article selection, `httpClientService`, `priceService`                               |
| Push stock levels to a marketplace or partner                                           | Scheduled script processing on an article selection, `httpClientService`                                               |
| Write an order export in the format of a logistics partner                              | Batch action on documents, XML writer into the DMS, see [Files & Export](/documentation/scripting/files-and-export.md) |

### Import Supplier Images

The script downloads product images from a supplier's media server into the DMS and attaches them to the article, also from servers that need a token or user name and password. See [Downloading Files into the DMS](/documentation/scripting/http-and-secrets.md#downloading-files-into-the-dms).

***

## Product Data

### Generate Product Texts with AI

A language model writes missing product descriptions for a selection of articles. The same approach translates texts, generates SEO keywords, classifies articles into product groups or summarises long supplier data sheets.

* **Trigger:** batch action or scheduled script processing on an article selection
* **Services:** `articleService`, `httpClientService` with the AI provider's API key as a secret placeholder
* **Setup:** the provider's API host on the whitelist; turn on **Workflows ausschalten** so the update does not trigger article workflows

***

## Accounting & Master Data

| Idea                                                    | How                                                                                         |
| ------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| Send overdue dunning letters every morning              | Scheduled script processing on a dunning selection, `dunningService.sendViaMail()`          |
| Mail invoices with a report group per customer language | Workflow on `document: AFTER_TRANSFER`, `documentService.sendViaMail(id, groupIdentifier)`  |
| Block saving when a rule is violated                    | Workflow on `Vor dem Speichern` with an own error message                                   |
| Link incoming DMS files to records after text analysis  | Workflow on `shelf: Dateianalyse abgeschlossen`, `shelfDocumentService.createAttribution()` |

***

## Good Practice

* **Avoid loops.** A workflow that updates the record it was triggered by fires again. Use a guard that detects the change, or run bulk updates as a script processing with **Workflows ausschalten**.
* **Keep secrets in secrets.** Never paste an API key into the script; request data is logged before placeholders are resolved.
* **Handle failures.** 4xx and 5xx responses throw. Catch them where a failure must not stop the business process.
* **Stay within the limits.** A script run is stopped after 5 minutes of JavaScript execution; a single HTTP request may take up to 300 seconds. Split large jobs into batch runs.
* **Log what you do.** `logger.info()` entries appear in the workflow protocol and the import log, which is the first place to look when something goes wrong.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.vario-software.de/documentation/scripting/use-cases.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
