> For the complete documentation index, see [llms.txt](https://docs.pyck.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.pyck.cloud/basics/workflows.md).

# Workflows

Audience: Logistics Manager

## What Are Workflows?

Workflows in pyck are automated processes that help customize and control warehouse operations. Think of workflows as a series of predefined steps that automatically execute when certain events happen in your warehouse.

## How Workflows Work

1. **Event Triggers**: Workflows start when specific events occur in your warehouse system. For example:
   * A new order arrives
   * Inventory falls below a threshold
   * A shipment is received
   * A picking task is completed
2. **Automated Actions**: Once triggered, workflows follow a predefined sequence of activities without requiring manual intervention.
3. **Customization**: Each warehouse can have its own set of workflows tailored to its specific processes and requirements.

## Benefits of Using Workflows

* **Consistency**: Ensure warehouse processes follow the same steps every time
* **Efficiency**: Automate repetitive tasks to save time and reduce errors
* **Adaptability**: Easily modify your warehouse processes without changing the core system
* **Visibility**: Track and monitor process execution across your facility
* **Durability**: Workflows continue running even if there are system failures
* **Reliability**: Tasks are automatically retried if they fail, ensuring completion

## Common Workflow Examples

* **Receiving Process**: Automatically update inventory when goods arrive and notify relevant departments
* **Order Fulfillment**: Guide picking, packing, and shipping activities in the most efficient sequence
* **Inventory Management**: Trigger reordering when stock levels drop below defined thresholds
* **Quality Control**: Route items through inspection processes based on predefined rules

## Dynamic App Behavior

One of the most powerful features of pyck workflows is their ability to change the behavior of mobile apps and devices used in your warehouse. This means:

* **Adaptive User Interfaces**: Workflows can modify what screens and options appear on warehouse devices
* **Context-Aware Instructions**: Workers receive different instructions based on the specific circumstances
* **Real-Time Updates**: Apps can adapt immediately to changing conditions in the warehouse
* **Custom Process Flows**: Create unique step-by-step guides for different products, customers, or situations

For example, a picking workflow could change a mobile app to show different picking instructions based on the item type, storage location, or even the experience level of the warehouse worker. The technical details of how this works will be covered in separate documentation, but the important thing to understand is that workflows give you the power to customize app behavior through your business processes.

## How to Implement Workflows

pyck uses Business Process Model and Notation (BPMN) as a common language between logistics managers and technical teams. This visual approach allows you to:

1. **Design processes visually**: Create flowcharts showing the steps in your warehouse operations
2. **Communicate effectively**: Share your process requirements with technical teams using standard notation
3. **Review implementations**: Ensure the technical implementation matches your operational needs

Your technical team will convert these BPMN models into actual code using Temporal.io, a powerful workflow engine that ensures reliability and durability. The workflow code can be written in various programming languages to match your organization's technology stack.

## Reference Implementation

For a practical example of how workflows are implemented in pyck, your technical team can refer to our reference implementation at: <https://github.com/pyck-ai/pyck-customer-template>

This template provides examples of common warehouse workflows that can be customized to your specific requirements.

## Activating or Deactivating a Workflow

### What is the `Active` flag?

* **Purpose:** A simple on/off switch to enable or disable a workflow.
* **Where to set it:** When you create or update a workflow definition include the `active` field.

#### How it works?

* When `active` is `true`, the system will consider this workflow for triggering.
* When `active` is `false`, the workflow remains in the catalog but will never be launched, even if an event matches its filter.

## Filtering Events with `FilterRule`

### What is the `FilterRule` ?

* **Purpose:** A conditional expression that decides whether an incoming event should trigger the workflow.
* **Syntax:** Uses FEEL (Friendly Enough Expression Language), which supports logical operators, comparisons, and built-in functions.

### How to write a rule

1. Reference event fields by name: if your event data includes a field `name`, use `name` in the expression.
2. Built-in functions: such as `starts with(text, prefix)`, `contains(text, substring)`, numeric comparisons (`>`, `<`, `=`, etc.).
3. Logical operators: combine conditions with `and`, `or`, `not`.

### Example: Trigger only when item names start with "item"

* **Workflow name:** `TemporalWorkflowPrintItem_ItemCreate`
* **Filter rule:** `starts with(name, "item")`

#### What happens at runtime:

1. A client runs the `CreateInventoryItem` mutation
2. The system emits an event `InventoryItem.create` with this `eventData`.
3. Workflow-service checks all active workflows listening to create-item events.
4. For `TemporalWorkflowPrintItem_ItemCreate`, it evaluates `starts with(name, "item")`:
   * If `name = "item_123"`, expression is **true** -> the workflow is launched.
   * If `name = "product_456"`, expression is **false** -> the workflow is skipped.

With **Active** and **FilterRule**, users have full control over when and how the workflows are triggered.


---

# 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://docs.pyck.cloud/basics/workflows.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.
