> ## Documentation Index
> Fetch the complete documentation index at: https://docs.omnilinker.pl/llms.txt
> Use this file to discover all available pages before exploring further.

# Custom triggers

> Set up buttons, keyboard shortcuts and barcodes that start automations when a person decides, and press them on an order.

A custom trigger starts automations when a person decides: someone presses its button on the order card, selects
orders in the list and presses it there, uses its keyboard shortcut, or scans its barcode in floor mode. Your own
systems can press it too, through the API.

A custom trigger does nothing by itself. It runs the automations that start with it, so after you set one up, you add
at least one automation for it.

## Set up a custom trigger

You need the **Set up buttons, shortcuts and barcodes** and **See automations** permissions. To add the automations it
runs, you also need **Create and change automations**.

<Steps>
  <Step title="Open Custom triggers">
    Open **Automations** > **Custom triggers**. Your custom triggers are listed on the left, each with how people start
    it and how many automations it runs. Click **New**.
  </Step>

  <Step title="Decide how it looks">
    Under **How it looks**, type the **Name people see**, for example "Packed — print label", and pick an **Icon** and
    a **Colour**. **Preview** shows the button on the **Order card**, in **Floor mode**, and in the **Order list, with
    orders selected**.
  </Step>

  <Step title="Decide how people start it">
    Under **How people start it**, choose where its button shows, give it a shortcut, and decide whether your own
    systems may press it. See [How people start it](#how-people-start-it).
  </Step>

  <Step title="Decide who sees it, and when">
    Under **Who sees it, and when**, limit it to stations, roles and order statuses, and set when a press on many orders
    asks first. See [Who sees it, and when](#who-sees-it-and-when).
  </Step>

  <Step title="Create it">
    Click **Create**. The trigger gets its barcode.
  </Step>

  <Step title="Add what it runs">
    Under **What it runs**, click **Add an automation for this trigger**. The editor opens with this trigger chosen;
    add the conditions and steps and switch the automation on. See
    [Create and edit automations](/automations/create-and-edit).
  </Step>
</Steps>

To change a custom trigger, click it in the list, change what you need and click **Save changes**. **Cancel** puts back
what was saved.

### How people start it

| Way | What to set |
| - | - |
| **A button** | Where the button shows: **On the record's card**, **In the list, for several at once** and **In floor mode**. All three are ticked for a new trigger. The button shows "for the people and records chosen below". |
| **A keyboard shortcut** | Click **Choose keys** and press the keys. See [Shortcut rules](#shortcut-rules). |
| **A barcode** | Every custom trigger has one, a code such as `OL-T-7K3M`, drawn on this page. "Scanning it on an order presses this trigger, with the same rules as the button." See [Barcode](#barcode). |
| **Your own systems** | Tick it to let an integration press the trigger with an API key that has the **Use buttons, shortcuts and barcodes** permission. See [Press it through the API](#press-it-through-the-api). |

Below these, the page says whether other automations press this trigger, with **Run a custom trigger** or under **If
a step fails**.

### Shortcut rules

A shortcut is **Ctrl** or **Alt** with a letter or a digit, with or without **Shift**, or a function key, **F1** to
**F12**. A single letter or digit cannot be a shortcut: a barcode scanner types single keys, and it would press the
trigger in the middle of a scan.

Omnilinker reads the key from where it sits on the keyboard, so **Alt+P** is **Alt+P** on a Polish keyboard too.

Some keys cannot be used: "… can't be used: the browser keeps it, or AltGr types a letter with it."

* the browser's own: **Ctrl+W**, **Ctrl+T**, **Ctrl+N**, **Ctrl+Shift+N**, **Ctrl+Shift+T**, **Ctrl+Shift+W**,
  **Ctrl+Shift+Q**, **Ctrl+F4** and **Alt+F4**;
* **Ctrl+Alt** with a letter or a digit: on Windows, AltGr is Ctrl+Alt, so these type letters such as "ą".

Two custom triggers cannot share a shortcut: the page says "Taken: “…” already uses these keys." A free shortcut shows
"Free. Single letters can't be used: a scanner types them." To change it, click **Change**; to remove it, **Remove**.

### Barcode

The trigger gets its barcode when you create it. Scanning it in floor mode, with an order open, presses the trigger on
that order. A barcode presses the trigger only where its button may show **In floor mode**, and only for the people,
stations and statuses chosen below.

To give a trigger a new barcode, click **New code** and confirm: "Give it a new code? Cards printed with the current
one will stop working." A new code is never one that another trigger has.

Omnilinker does not print a sheet of trigger barcodes for you yet. The setup page shows each trigger's barcode.

### Who sees it, and when

The section reads as a sentence: **Show it at** any station **to people in** any role **when the order is** in any
status. Pick values to narrow it:

* **Stations**: the button shows, and the trigger can be pressed, only on a computer printing at one of these stations.
  See [Choose your station](/devices/choose-station).
* **Roles**: only people in one of these roles see it and can press it. The trigger keeps a role by its name: after you
  rename a role, choose it again here.
* **Statuses**: the order statuses the trigger runs in.

Stations and roles are never overridden. A status is different: "Pressed on a record in another status, it doesn't
fail quietly: it says which status it runs in, and someone allowed to can run it anyway." See
[An order in another status](#an-order-in-another-status).

The shortcut and the barcode follow the same rules as the button.

**On many records at once, ask first when there are more than** a number of orders, 10 by default, from 1 to 500. "Each
record gets its own result; one failure doesn't stop the rest."

### What it runs

**What it runs** lists the automations that start with this trigger, in the order they run, each with its condition
(or **always**), its number of steps, and its state when it is not **On**.

"Every press goes through all of them, in this order. Their conditions decide which ones act, so one button can cover
every case." For example, one **Packed** button can run one automation for parcel-locker orders and another for
courier orders.

A tag shows how last week's presses went: "Last week, every press matched exactly one", or how many presses matched
none and how many matched more than one.

### Delete a custom trigger

Click **Delete** and confirm: "Delete “…”? Its buttons, shortcut and barcode stop working."

You cannot delete a custom trigger while automations start with it, or press it with **Run a custom trigger** or under
**If a step fails**. The message names them; move or delete those automations, or remove the step, first.

## Press a custom trigger

You need the **Use buttons, shortcuts and barcodes** permission. You see only the triggers that are for you: placed
where you are, at your station, and for your role.

### On the order card

The buttons are in the order card's header, each with its shortcut. Click one, or press its shortcut anywhere on the
page except while you type in a field.

A message says "“…” started on 1 record." The **Automations** section of the card shows what ran; see
[The order card's Automations section](/automations/runs-and-activity#the-order-cards-automations-section).

### On the order list

Select orders on **Sales** > **Orders**. The buttons appear in the bar above the list, and their shortcuts work while
orders are selected.

When you select more orders than the trigger's threshold, Omnilinker shows what the press would do before anything
happens: "Run “…” on N records?"

* how many orders each automation will act on, and how many no automation applies to ("no automation applies: nothing
  happens");
* each order that won't run, with why, for example because it is held;
* "They run one at a time, in the order of this list."

Click **Run on N records**, or **Cancel**. "Keep working: each record's card shows what ran as it finishes."

One press runs on at most 500 orders. A press from the list leaves out orders whose automations are held, even when
you select only one.

### An order in another status

A button for statuses other than the order's is greyed out, and its tooltip says "Runs in other statuses: press to see
which". Pressing it says why it didn't run, for example "It runs only in Packing; this one is New."

With the **Run a button on an order whose status it doesn't allow** permission, you are asked "… Run it anyway?" and can
run it.

### A held order

On the order card and in floor mode, a custom trigger pressed on a held order still runs: you are looking at the order
and chose to press it. Automations its steps start by themselves still wait for the hold to be released. See
[Holds](/automations/overview#holds).

## A rule pressing a custom trigger

An automation can press a custom trigger too:

* as a step, with **Run a custom trigger**;
* when it fails for good, under **If a step fails**, with **and press**.

The automations the trigger starts run as they would for a person's press, in the same chain, so the
[loop guard](/automations/overview#loop-protection) counts them. An automation can only press a custom trigger on its
own kind of record.

A common use is a "Needs a person" trigger whose automation tells the team, holds the order and sets a status. Every
automation that can fail presses it under **If a step fails**. The goal **Hand it to a person** sets this up.

## Press it through the API

Tick **Your own systems** on the trigger. Then call it with an API key that has the **Use buttons, shortcuts and
barcodes** permission; see [API keys](/administration/api-keys).

```http theme={null}
POST /api/automation/custom-trigger/{id}/run
Content-Type: application/json

{
  "subjectIds": ["<order-id>"]
}
```

`{id}` is the custom trigger's id. The answer lists each order with `accepted` and, when it didn't run, a `reason`.
A press of an API key is shown on the order card as **through the API**.

The station and role limits apply to the API too: a trigger limited to stations or roles can only be pressed by a key
that meets them. A trigger without **Your own systems** answers "“…” isn't open to API keys."

An API key's press leaves out orders whose automations are held, as a press from the list does: nobody looked at them.

Each call is a new press: a call that timed out may have pressed already. Before you call again, check the order's
**Automations** section, or the answer's `pressedAt`, rather than retrying blindly.

A key that may press a trigger runs it on any order of your organization: the trigger's automations act, whatever else
the key may do. Tick **Your own systems** only on triggers an integration should run.

## Next steps

<CardGroup cols={2}>
  <Card title="Floor mode" icon="scan-barcode" href="/automations/floor-mode">
    Packers scan an order, then press a tile or scan a trigger's barcode.
  </Card>

  <Card title="Runs and activity" icon="activity" href="/automations/runs-and-activity">
    See what each press ran.
  </Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.