> ## Documentation Index
> Fetch the complete documentation index at: https://university.triggr-app.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PSA ticket automation (Hawk)

> Watch your HaloPSA, ConnectWise PSA or Autotask tickets and start a Studio workflow when a ticket matches a condition.

Hawk checks your PSA every minute for new tickets (with ConnectWise PSA and Autotask, updated ones too) and starts the workflows linked to a watcher whenever a ticket matches its condition.

<Frame caption="PSA ticket automation: switch Hawk on, test a password reset watcher on imported HaloPSA tickets, link the workflow it starts and read its logs (1:27).">
  <video controls preload="none" playsInline className="w-full aspect-video rounded-xl" poster="/images/videos/studio-hawk.jpg" src="https://mintcdn.com/triggr/GxrCQFDFNLmEMyJ1/images/videos/studio-hawk.mp4?fit=max&auto=format&n=GxrCQFDFNLmEMyJ1&q=85&s=44fcc03194e1729eeaefd7d43be7fa5e" data-path="images/videos/studio-hawk.mp4" />
</Frame>

You need View Hawk to open Settings > Hawk and Edit Hawk to change it, and your PSA's Base Configuration connected: [HaloPSA](/integrations/halopsa), [ConnectWise PSA](/integrations/connectwise-psa) or [Autotask](/integrations/autotask).

## Turn on Hawk

<Steps>
  <Step title="Set your PSA">
    If the status card shows **Set Default PSA**, click it and choose your PSA (the org-wide Default PSA that ticket steps also use). Once it's set, the card shows your PSA instead.

    <Frame>
      <img src="https://mintcdn.com/triggr/_d7ojda9vf8IHE31/images/studio/automation/hawk-disabled.png?fit=max&auto=format&n=_d7ojda9vf8IHE31&q=85&s=3b6499b14c33dce6d36fd02eced1060d" alt="The Hawk page with a Disabled status, a yellow Set Default PSA button, Test Connection and Enable buttons, and a Hawk is disabled panel with an Enable Hawk button." width="2296" height="1004" data-path="images/studio/automation/hawk-disabled.png" />
    </Frame>

    <Frame>
      <img src="https://mintcdn.com/triggr/_d7ojda9vf8IHE31/images/studio/automation/set-default-psa.png?fit=max&auto=format&n=_d7ojda9vf8IHE31&q=85&s=2447c52a6745bec6d880fba7b3dbe329" width="448" alt="The Set Default PSA dialog offering ConnectWise Manage, HaloPSA and Autotask, with a Cancel button." data-path="images/studio/automation/set-default-psa.png" />
    </Frame>
  </Step>

  <Step title="Test the connection">
    Click **Test Connection**. Connection Test Failed shows the PSA's error.

    <Frame>
      <img src="https://mintcdn.com/triggr/_d7ojda9vf8IHE31/images/studio/automation/hawk-test-connection.png?fit=max&auto=format&n=_d7ojda9vf8IHE31&q=85&s=085aa2cf61783a6cc3c3680dd48fb6e4" alt="The Connection Test Successful dialog for HaloPSA showing 5 tickets fetched and a Sample Tickets table with ID, Summary, Client, Contact and Created columns." width="1792" height="966" data-path="images/studio/automation/hawk-test-connection.png" />
    </Frame>
  </Step>

  <Step title="Enable Hawk">
    Click **Enable**. Hawk picks up tickets created from now on; with ConnectWise PSA and Autotask, tickets updated from now on too.
  </Step>

  <Step title="Import some history (optional)">
    Click **Import History**, choose a Time Period and click Import Tickets. Imported tickets are for Run Preview only; they never start workflows, even when they change later.

    <Frame>
      <img src="https://mintcdn.com/triggr/_d7ojda9vf8IHE31/images/studio/automation/hawk-import-history.png?fit=max&auto=format&n=_d7ojda9vf8IHE31&q=85&s=e32d3833a5d9800980304fc92c88a03d" width="448" alt="The Import Historical Tickets dialog explaining that imported tickets will not trigger any watchers, with Time Period set to 24 hours and Cancel and Import Tickets buttons." data-path="images/studio/automation/hawk-import-history.png" />
    </Frame>
  </Step>
</Steps>

## Create a watcher

This example starts a workflow for every new ticket that asks for a password reset.

<Steps>
  <Step title="Write the condition">
    Click **New Watcher**, type a JavaScript condition and click Run Preview; Matching should list the tickets you expect. Click a field under Ticket Fields, or a line of the Selected Ticket Payload, to insert it.

    ```js theme={null}
    _.includes(_.toLower(ticket.summary), "password reset")
    ```

    <Frame>
      <img src="https://mintcdn.com/triggr/_d7ojda9vf8IHE31/images/studio/automation/hawk-watcher-editor.png?fit=max&auto=format&n=_d7ojda9vf8IHE31&q=85&s=32a05e77c3401eaff3babc17d7d71ca2" alt="The New Watcher editor: a Reference panel listing HaloPSA ticket fields and helper functions, a Condition (JavaScript) editor checking whether the lower-cased summary includes password reset, a Live Preview with Matching (2), Not Matching (3) and All (5) tabs and the selected ticket's payload, and Name and Description fields with a Create Watcher button." width="2880" height="1800" data-path="images/studio/automation/hawk-watcher-editor.png" />
    </Frame>
  </Step>

  <Step title="Name it and save">
    Enter a unique **Name** and click **Create Watcher**.
  </Step>

  <Step title="Link a workflow">
    Click the link icon (**Link Workflows**) on the watcher's row, then + next to each workflow it should start. Links save straight away.

    <Frame>
      <img src="https://mintcdn.com/triggr/_d7ojda9vf8IHE31/images/studio/automation/hawk-link-workflows.png?fit=max&auto=format&n=_d7ojda9vf8IHE31&q=85&s=f0a41849a974cccbe73e65ec44619ade" width="512" alt="The Link Workflows dialog for the Password reset requests watcher with one linked workflow and an Add Workflow search listing workflows with plus buttons, and a Done button." data-path="images/studio/automation/hawk-link-workflows.png" />
    </Frame>
  </Step>

  <Step title="Turn the watcher on">
    New watchers start Disabled: click the play icon (**Enable Watcher**) on its row.

    <Frame>
      <img src="https://mintcdn.com/triggr/_d7ojda9vf8IHE31/images/studio/automation/hawk-watchers.png?fit=max&auto=format&n=_d7ojda9vf8IHE31&q=85&s=ce0bb89fc793a59e13b12d402f238e82" alt="The Hawk page showing Enabled with HaloPSA, Last poll: Just now, Test Connection and Disable buttons, the Watchers, Tickets and Analysis tabs, and the Password reset requests watcher with 1 workflow, Enabled status and edit, logs, link, pause and delete icons." width="2296" height="712" data-path="images/studio/automation/hawk-watchers.png" />
    </Frame>
  </Step>
</Steps>

## Write conditions

A condition is one JavaScript expression that's true for tickets to act on. `ticket` is the ticket as your PSA returns it, so field names differ by PSA: copy them from Ticket Fields or from a ticket's Ticket Payload on Tickets.

```js theme={null}
// HaloPSA: one client
ticket.client_name === "Acme Corp"

// ConnectWise PSA: new tickets on one board that mention a password reset
_.get(ticket, "board.name") === "Service Desk" &&
  _.get(ticket, "status.name") === "New" &&
  _.includes(_.toLower(ticket.summary), "password reset")

// Autotask: several keywords in the title
/password|locked out|unlock/i.test(ticket.title || "")
```

Helpers: `_.get(obj, path, default)`, `_.includes`, `_.isEmpty`, `_.toLower` and `_.toUpper`. Prefer them to `ticket.summary.toLowerCase()`, which fails when the field is missing. A condition can't see your Triggr clients; check the client in the workflow.

## What the workflow receives

Each linked workflow starts once per matching ticket, even when Inactive (unlink it or disable the watcher to stop it), with:

* `ctx.params`: the whole ticket, such as `{{ ctx.params.summary }}`.
* `ctx.metadata`: `source` (`hawk`), `watcherId`, `watcherName`, `psaType`, `psaTicketId` and `hawkTicketId`.

The run has no client. Start with **Search For Client** (Property: Variable) on your PSA's mapping variable and the ticket's client ID field, then Set Client By ID with the client it finds:

| PSA | Variable Name | Value |
| - | - | - |
| HaloPSA | `haloId` | `{{ ctx.params.client_id }}` |
| ConnectWise PSA | `connectwiseId` | `{{ ctx.params.company.id }}` |
| Autotask | `autotaskId` | `{{ ctx.params.companyID }}` |

Check the client ID field against a ticket's Ticket Payload on Tickets, and add a Condition after the search so tickets from unmapped clients finish cleanly. For other ways to start workflows, see [Triggers](/studio/workflows/triggers).

## Check what happened

Click the document icon (**View Logs**) on a watcher: each ticket shows Matched, Not Matched or Error, and the IDs of the runs it started, which you find on Executions.

<Frame>
  <img src="https://mintcdn.com/triggr/_d7ojda9vf8IHE31/images/studio/automation/hawk-watcher-logs.png?fit=max&auto=format&n=_d7ojda9vf8IHE31&q=85&s=68cf5a27c8f33fdfed5b8aadb8ad43a1" alt="The Watcher Logs dialog for Password reset requests listing five tickets with Matched or Not Matched status and 1 or 0 workflows triggered, with the first row expanded to show a workflow execution ID." width="1792" height="894" data-path="images/studio/automation/hawk-watcher-logs.png" />
</Frame>

Tickets lists the tickets Hawk has stored; click one for its Ticket Payload.

<Frame>
  <img src="https://mintcdn.com/triggr/_d7ojda9vf8IHE31/images/studio/automation/hawk-ticket-payload.png?fit=max&auto=format&n=_d7ojda9vf8IHE31&q=85&s=9bd630b4c6a154e19b7d37797d40c47f" width="672" alt="A HaloPSA ticket, #48217 Password reset for Sam Taylor, showing its Ticket Payload JSON including id, summary, details, status_id, client_id 12 and client_name Acme Corp." data-path="images/studio/automation/hawk-ticket-payload.png" />
</Frame>

Analysis shows automation ideas from your ticket history, run by the Triggr team on request; you Accept, Dismiss or Mark Implemented each recommendation.

## FAQ

<AccordionGroup>
  <Accordion title="organisation must have defaultPSA set to 'connectwise', 'halo', or 'autotask'">
    Click Set Default PSA, choose your PSA, then click Enable again.
  </Accordion>

  <Accordion title="“Halo integration is missing required configuration” (or ConnectWise or Autotask)">
    Fill in every field of the PSA's Base Configuration, then click Test Connection.
  </Accordion>

  <Accordion title="My watcher matches in the preview but never starts the workflow">
    The watcher must be Enabled with a linked workflow, and Hawk only judges tickets that arrive while it is. Imported tickets never start workflows.
  </Accordion>

  <Accordion title="A ticket was edited to match later, but nothing ran">
    Each watcher judges each ticket once, so match tickets as they look when first logged.
  </Accordion>

  <Accordion title="Hawk switched itself off">
    Hawk turns off after 10 failed checks in a row (the status card shows the last error) or when the Default PSA changes. Fix the cause, check it with Test Connection, then click Enable; it picks up where it left off.
  </Accordion>

  <Accordion title="“condition timed out after 5 seconds” or “failed to evaluate condition”">
    The ticket counts as not matched and its log shows Error. Use `_.get` and `_.toLower` for fields that may be missing, and avoid loops.
  </Accordion>

  <Accordion title="How long does Hawk keep tickets?">
    Seven days after it last fetched them, with their watcher logs.
  </Accordion>

  <Accordion title="Is Settings > Tickets part of Hawk?">
    No. Settings > Tickets sets the email address for the support ticket Triggr raises when a workflow fails.
  </Accordion>
</AccordionGroup>


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