> For the complete documentation index, see [llms.txt](https://docs.lineverge.com/automail/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.lineverge.com/automail/configurations/workflow-configuration/custom-workflows.md).

# Custom Workflows

Custom workflows are used for background tasks that are not covered by [Sync Workflows](/automail/configurations/workflow-configuration/sync-workflows.md).

To stay consistent with the overall project structure, each custom workflow must be within a py file located in the **project** folder.&#x20;

The py file will start with the generic import of components relevant to Automail (e.g. *custom\_models* to access all models, *custom\_functions* to access all project functions, etc.). Each workflow would then be defined within its own function and called in the main as in the example below.

```python
try:
    from _init import * # DEV env
except ImportError:
    from configurations.workflow_env import * # PROD env

def count_delivery_records():
    print("Delivery records:", custom_models.Delivery.objects.all().count())

if __name__ == '__main__':
    count_delivery_records()
```
