Workflows are if-then rules that X-Sitter checks and runs automatically at certain points in the order process. Examples:

- set a shipping method when an order is imported,
- add packaging material from a certain weight,
- print an insert (e.g. a flyer) when packing,
- send an email to the end customer after shipping.

The **workflow logs** show which workflows applied to which order.

![Screenshot: Workflow overview with client filter, active/inactive filter and a list of workflows](/automation/images/workflows-overview.png)

## Before you start

- Your user needs the permissions for **Settings** (*Einstellungen*) and **Workflows** in the WMS menu; creating and editing is a separate permission – ask your administrator.
- At least one client – a workflow always applies to one or more clients – see [Clients](/company/clients.md).
- For **Send Email**: an email template – see [Email templates](/automation/email-templates.md).
- For **Print delivery slip** / **Print invoice**: PDF templates – see [PDF documents](/automation/pdf-documents.md).
- For inserts: a PDF in the media management of your company settings – see [Media](/company/media.md).
- For **Set/override shipping method**: the freight carriers of your warehouse – see [Freight carriers](/warehouse-setup/freight-carriers.md).

## Create a workflow

1. Open **WMS › Settings › Workflows** (*WMS › Einstellungen › Workflows*). Filter with **All clients** (*Alle Mandanten*) and **Active and inactive** / **Only active** / **Only inactive**.
2. Click **Create a new workflow** (*Neuen Workflow anlegen*). The form **Create/Edit Workflow** opens.
3. Fill in the header:
   - **Active** (*Aktiv*),
   - **Always log (even on errors or when the conditions are not met)** (*Immer loggen …*),
   - **Name**, **Description** (*Beschreibung*),
   - **Order** (*Reihenfolge*) – smaller numbers are checked and executed earlier.
4. Choose the **Trigger event** (*Trigger-Ereignis*) – when the workflow is checked (see table below).
5. Under **If (conditions)** (*Wenn (Bedingungen)*) define when the workflow applies.
6. Under **Then (Actions)** (*Dann (Aktionen)*) define what it does.
7. Click **Save** (*Speichern*). You see "The workflow has been created." or "The workflow has been saved."

![Screenshot: Workflow form header with Active, Always log, Name, Order and the trigger event dropdown](/automation/images/workflows-form-header.png)

## Trigger events

| Trigger event | When it fires |
|---|---|
| **When importing/creating an order** (*Beim Import/Anlegen eines Auftrages*) | A new order arrives or is created. |
| **When editing an order** (*Beim Bearbeiten eines Auftrages*) | An order is changed. |
| **When the order status changes** (*Beim Statuswechsel des Auftrages*) | The order status changes. |
| **When picking begins** (*Beim Start der Kommissionierung*) | Picking of the order starts. |
| **After picking is complete** (*Nach Abschluss der Kommissionierung*) | The order is fully picked – see [Picking](/outbound/picking.md). |
| **Packaging process has begun** (*Verpackungs-Prozess begonnen*) | The order is opened at the packing table. |
| **Delivery note created** (*Lieferschein erstellt*) | A delivery note has been created. |
| **Shipping label generated (ShipCloud)** (*Versandsandlabel erzeugt (ShipCloud)*) | A shipping label has been created. |
| **Packaging complete (single package/pallet)** (*Verpackung abgeschlossen (einzelnes Paket/Palette)*) | One package or pallet is finished. |
| **Packaging complete (order complete)** (*Verpackung abgeschlossen (Auftrag vollständig)*) | The whole order is packed – see [Packing](/outbound/packing.md). |
| **Packaging process completed** (*Verpackungs-Prozess beendet*) | The packing process has ended. |
| **Loading complete (single package/pallet)** (*Verladen abgeschlossen (einzelnes Paket/Palette)*) | One package or pallet is loaded. |
| **Loading complete (order fulfilled)** (*Verladen abgeschlossen (Auftrag vollständig)*) | The whole order is loaded – see [Loading](/outbound/loading.md). |

## Conditions (If)

| Condition | Meaning |
|---|---|
| **Company (Owner)** (*Firma (Eigentümer)*) | The clients the workflow applies to. Several can be selected. Required. |
| **Platform(s)** (*Plattform(en)*) | Only orders from these platforms. |
| **Module(s)** (*Modul(e)*) | Only orders from these order modules. |
| **Destination country/countries** (*Zielland/Länder*) | Only orders to these countries. |
| **Comment contains** (*Bemerkung enthält*) | Text that must appear in the order comment. |
| **"Shipping Method (Incoming)" contains** (*Versandart (eingehend) enthält*) | Checks the shipping method sent by the external system. Combined with the action "Set shipping method" you can map external shipping methods to your freight carriers per client – e.g. "customer pickup". |
| **Order data includes** (*Auftragsdaten enthalten*) | Searches the customer order, additional data and both addresses – useful for interface identifiers that arrive in different fields. Separate alternatives with a vertical bar; one match is enough. |
| **Address contains (field + text)** (*Adresse enthält (Feld + Text)*) | Checks whether the selected field of the delivery address contains the text, e.g. a dealer customer number. |
| **Order ID (order_id)** (*Auftrags-ID (order_id)*) | **Starts with** (*Beginnt mit*), **Contains** (*Enthält*) or **Ends with** (*Endet mit*) a value. |
| **Item conditions** (*Artikel-Bedingungen*) | Item rules with a **Rule type** (*Regeltyp*) and a **Value / Search** (*Wert / Suche*), see below. |

**Item rule types**

- Contains at least one item from category X
- Contains only items of type Y
- Contains specific item (SKU)
- Contains part of the product name
- The total number of items is at least N
- Stock of item (SKU) falls below N (value as SKU:N)
- The number of positions is N
- The total weight of the items is at least / no more than N kg
- At least one item weighs at least N kg
- Each item weighs no more than N kg
- Insufficient stock available for the item position

![Screenshot: "If (conditions)" section with client selection, countries and an item rule](/automation/images/workflows-conditions.png)

## Actions (Then)

| Action | What it does |
|---|---|
| **Add packaging/product** (*Verpackung/Produkt hinzufügen*) | Adds packaging material or a product as an additional position. Choose the **Product type** (*Produkttyp*) and the item. |
| **Set/override shipping method** (*Versandart setzen/überschreiben*) | Sets the shipping method (freight carrier) of the order. |
| **Set priorities** (*Priorität setzen*) | Sets the order priority. Default without change is 10; the smaller, the more important. |
| **Allow partial deliveries** (*Teillieferung erlauben*) | Allows partial delivery for the order. |
| **Create a return label from the shipping label** (*Aus dem Versandlabel auch ein Retouren-Label erzeugen*) | Creates a return label together with the shipping label. If the order itself already requests a return label, the packing table creates it and the action is skipped – no second label. |
| **Print settings** (*Druckeinstellungen*) | **Print delivery slip** (*Lieferschein drucken*) with a **Delivery Note Template**, **Print inserts (PDF from Media Management)** (*Beileger drucken*) with the **Number of copies** (1–20), **Print invoice** (*Rechnung drucken*) with an **Invoice Template**. The documents are printed at the packing station. |
| **Run a cron job** (*Cronjob ausführen*) | Calls the selected cron job of the system. X-Sitter passes the company, the order ID, the packing station and – if filled in – the source folder along with the call. |
| **Source Folder (for PDFs)** (*Quell-Ordner (für PDFs)*) | Optional folder in which to search for PDFs. The base is always the folder "remote/". It is passed to the cron job. |
| **Add a comment** (*Bemerkung ergänzen*) | Appends text to the order comment (existing text is kept, a line break is inserted). |
| **Add packing instructions** (*Pack Hinweise ergänzen*) | Appends text to the packing information. |
| **Add packing note** (*Packhinweis ergänzen*) | Appends a short note (max. 128 characters in total), e.g. "Please include a greeting card". It appears in the middle of the screen for 5 seconds when the order is opened at the packing table. |
| **Customize Order** / **Adjust order items** (*Auftrag anpassen* / *Auftragspositionen anpassen*) | Sets selected order or position fields to a **New Value** (*Neuer Wert*) when the conditions match. With an item rule (SKU, name, category) only the matching positions are changed. |
| **Send Email** (*E-Mail senden*) | Sends an email based on an [email template](/automation/email-templates.md) – recipient, subject and text come from the template. **Send only once per order** (*Nur einmal pro Auftrag senden*) is recommended for shipping confirmations, because shipping triggers can fire several times per order. |

![Screenshot: "Then (Actions)" section with print settings, packing note and send email](/automation/images/workflows-actions.png)

## Which workflows run

- Only **active** workflows of your company with the matching trigger, whose client list contains the client of the order, sorted by **Order** (*Reihenfolge*).
- In the order details you can run the workflows again with **Run workflow again** (*Workflow erneut ausführen*). This re-runs the workflows for "Packaging complete (order complete)" – see [Order details](/orders/order-details.md). You see "The workflow has been restarted."
- To stop a workflow, untick **Active**.

## Workflow logs

1. Open **WMS › Settings › Workflow logs** (*WMS › Einstellungen › Workflow-Logs*).
2. Filter by owner (**All owners** – *Alle Eigentümer*), status and **Order** (*Auftrag*).
3. The columns show **Time** (*Zeit*), **Trigger**, **For companies** (*Für Firma*), **Item** (*Artikel*), **Matched**, **Actions**, **Status** and **Message** (*Nachricht*).

Logs are kept for one month.

![Screenshot: Workflow logs with filters and entries showing trigger, matched, actions and status](/automation/images/workflows-logs.png)

## Troubleshooting

**My workflow does not apply.** Check: is it **Active**, is the trigger right, is the client selected in **Company (Owner)**, are the conditions met? With **Always log** you also see checks in the workflow logs where the conditions were not met.

| Message | Cause | Solution |
|---|---|---|
| Please select a name and at least one company. (*Bitte Name und mindestens eine Firma auswählen.*) | Required fields missing. | Enter a name and select a client. |
| The selected email template was not found; the action "Send email" was not saved. (*Die gewählte E-Mail-Vorlage wurde nicht gefunden …*) | Template deleted or belongs to another company. | Choose the template again. |
| Error saving the workflow. (*Fehler beim Speichern des Workflows.*) | Technical error. | Save again. |
| Workflow not found. (*Workflow nicht gefunden.*) | Invalid link. | Open the workflow from the overview. |
| No workflows were found for the selected filters. / No workflows have been created yet. | Empty list. | Adjust the filters or create a workflow. |
