# Automate the Helpdesk with triggers > Rules that run the moment a ticket is created or updated: set its status, route it, tag it, or tell someone about it A trigger is a rule for your Helpdesk tickets. Each time a ticket is **created** or **updated**, QwryAI checks it against the trigger's conditions and, if they match, runs the trigger's actions: set a status or priority, assign a team or an agent, add or remove tags, add an internal note, or send an email, a Slack message or a webhook. Triggers belong to one AI agent and act on that agent's tickets. Think of each one as **When** this ticket matches, **Then** do these things. Triggers run **in order, top to bottom**, and **every trigger that matches runs**. You can stack them: one routes billing questions, another raises the priority of refund requests, and both apply to the same ticket in the order you set. You manage them under **Settings › Helpdesk › Triggers**. For tickets where nothing happens, such as a customer who stopped replying, use [Automations](/docs/user-guides/chatbot/help-desk/automations), which check open tickets once an hour. ![The Triggers settings page with the Route to default team trigger and a paused Tag refund requests trigger, each with its On create badge, its description, its conditions and actions count, a switch, and edit and delete buttons.](annotated/01-triggers-list.webp "Settings › Helpdesk › Triggers.") > [!NOTE] > > Triggers act on tickets in QwryAI's own Helpdesk. Tickets that live in another helpdesk, such as Zendesk, are handled there. ## How a trigger works Every trigger has four parts: > [card] Name and description | /docs/user-guides/chatbot/help-desk/triggers | A **Name** and an optional **Description**, so your team knows what the rule does and why. > [card] When | /docs/user-guides/chatbot/help-desk/triggers | The conditions a ticket must meet, in two groups: **Match ALL of** and **Match ANY of**. > [card] Then | /docs/user-guides/chatbot/help-desk/triggers | The actions to run, in order, when the ticket matches. A trigger needs at least one. > [card] Active | /docs/user-guides/chatbot/help-desk/triggers | The switch at the bottom of the panel, and on the trigger's row. Paused triggers keep their settings but don't run. ### Example: flag refund requests | Part | Setting | | - | - | | **Name** | Tag refund requests | | **Match ALL of** | Ticket is **Created** | | **Match ANY of** | Subject contains any of `refund`, `charged twice` | | **Then** | Add tags `refund-request`; Set priority **High**; Add internal note "Check the payment in Stripe before replying." | ## How triggers run When a ticket is created or updated, QwryAI goes through your active triggers once, from the top of the list to the bottom: **1. Start at the top** The first active trigger is checked against the ticket. **2. Run each trigger that matches** If it matches, its actions run before the next trigger is checked. **3. Pass the changed ticket down** The next trigger sees the ticket as the previous one left it. A trigger that sets the priority to **High** lets a later trigger match on priority **High** in the same pass. **4. Stop at the bottom** Each trigger is checked once per create or update. > [!TIP] > > Put the triggers that change a ticket, such as routing and tagging, above the ones that react to those changes, such as notifications. ## The default team trigger Every agent starts with a trigger called **Route to default team**: *When a new ticket still has no team, assign it to your default team.* It runs on **Ticket is Created** when **Team is any of No team**, and its action is **Assign team › Default team (current)**, which always follows whichever team is your default at the time. You can edit, reorder, pause or delete it like any other trigger. ## Creating a trigger **1. Open Triggers** Go to **Settings › Helpdesk › Triggers** and select **New trigger**. ![The New trigger panel with the Name and Description fields, the When section with a Ticket is Created condition under Match ALL of and an empty Match ANY of group, and the Active switch, Cancel and Create trigger at the bottom.](annotated/02-new-trigger.webp "A new trigger starts with Ticket is Created.") **2. Name your trigger** Type a **Name** that says what the trigger does, such as `Tag refund requests`, and add a **Description** if your team will want the reason later. Names must be unique among an agent's triggers. ![The Name field filled in with Tag refund requests and the Description field explaining that the trigger flags refund and double-charge requests so billing sees them first.](annotated/03-name.webp "Name it after what it does.") **3. Set the conditions under When** A new trigger starts with **Ticket is Created** under **Match ALL of**. Change it to **Updated**, or remove it to run on both. Then select **Add condition** in either group and pick the field. ![A new condition under Match ANY of with its field list open and the pointer on Subject.](annotated/04a-field.webp "Pick the field for the new condition.") Pick the operator, such as **contains any of**, and type the value. For a list, separate the words with commas. ![The Subject condition under Match ANY of with its operator list open and the pointer on contains any of.](annotated/04b-operator.webp "Choose contains any of.") ![The When section with Ticket is Created under Match ALL of, and Subject contains any of refund, charged twice under Match ANY of.](annotated/04-conditions.webp "Every condition under ALL must match; at least one under ANY.") **4. Add the actions under Then** A new trigger starts with one action. Pick its **Action type**, such as **Add tags**, and fill in its details. Select **Add action** for more; they run in the order listed. ![The Then section with action 1's type list open and the pointer on Add tags.](annotated/05a-tags.webp "Change the first action to Add tags.") ![Add tags refund-request as action 1, and a second action with its type list open and the pointer on Set priority.](annotated/05b-priority.webp "Add a second action and set it to Set priority.") ![The Then section with three numbered actions: Add tags refund-request, Set priority High, and Add internal note with the text Check the payment in Stripe before replying.](annotated/05-actions.webp "Actions run top to bottom.") **5. Choose Active, then create it** Leave **Active** on to start using the trigger straight away, or turn it off to save it paused. Select **Create trigger**. ![The bottom of the New trigger panel with the Active switch turned off, Cancel, and the pointer on Create trigger.](annotated/06-create.webp "Save it active or paused.") ## Conditions Conditions sit in two groups: * **Match ALL of:** *Every condition must match.* * **Match ANY of:** *At least one must match. Optional.* A ticket matches when everything under **Match ALL of** is true and, if **Match ANY of** has conditions, at least one of those is true too. > [!TIP] > > The panel reminds you: *Add a "Ticket is Created/Updated" condition to scope when this trigger runs; without one it runs on both.* ### When does a trigger run? | How it's set up | When it runs | | - | - | | **Ticket is Created** | Once, when the ticket is created | | **Ticket is Updated** | Every time the ticket changes, including a new message | | **New message is From customer** or **From agent** | Every time a message arrives from that side | | A **changed** condition, such as **Status category changed to Closed** | Every time that change happens | | None of the above | Once per ticket, the first time it matches on a create or an update | The list shows each trigger's timing as a badge: **On create**, **On update** or **On create or update**. A trigger that runs once per ticket starts over when you change its conditions, so it can act again on tickets it already handled. ### Ticket condition fields | Field | What it checks | Operators | | - | - | - | | **Ticket** | Whether the ticket was just **Created** or **Updated** | `is` | | **New message** | Whether this update added a message **From customer** or **From agent** | `is` | | **Status category** | **New**, **On you**, **On hold**, **On customer**, **Closed** or **Cancelled** | `is any of`, `is none of`, and the changed operators | | **Status** | One of your [ticket statuses](/docs/user-guides/chatbot/help-desk/ticket-statuses) | `is any of`, `is none of`, and the changed operators | | **Channel** | Where the ticket came from, such as **Chat**, **Email**, **WhatsApp**, **Instagram**, **Facebook**, **Help page**, **API** or **Manual** | `is any of`, `is none of` | | **Ticket type** | **Ticket**, **Live chat**, **Outbound** or **Consultation** | `is any of`, `is none of` | | **Assignee** | Who has the ticket, including **Unassigned** | `is any of`, `is none of`, and the changed operators | | **Team** | Which team has the ticket, including **No team** | `is any of`, `is none of`, and the changed operators | | **Priority** | **Urgent**, **High**, **Medium** or **Low** | `is any of`, `is none of`, and the changed operators | | **Last message** | Who wrote the latest message: **Customer**, **Agent**, **AI** or **No messages yet** | `is any of`, `is none of` | | **Agent has replied** | Whether a teammate has replied to the customer | `is` **True** or **False** | | **Tags** | The ticket's [tags](/docs/user-guides/chatbot/help-desk/tags) | `contains any of`, `contains none of` | | **Subject** | Words in the ticket subject | `contains`, `contains any of`, `does not contain`, `is`, `is not` | | **Description** | Words in the ticket description | `contains`, `contains any of`, `does not contain`, `is`, `is not` | The changed operators are `changed`, `not changed`, `changed to`, `not changed to`, `changed from` and `not changed from`. Text matching ignores upper and lower case. For `contains any of`, separate the words with commas. ### Contact condition fields | Field | What it checks | Operators | | - | - | - | | **Name**, **Email**, **Phone number**, **External ID** | The requester's details on the ticket | `contains`, `contains any of`, `does not contain`, `is`, `is not`, `is set`, `is not set` | ### Routing condition fields | Field | What it checks | Operators | | - | - | - | | **Recipient address** | Which of your support addresses an email ticket was sent to | `is any of`, `domain is any of`, `contains any of` | For `domain is any of`, enter a bare domain, like `company.com`. ## Actions | Action | What it does | | - | - | | **Set status** | Moves the ticket to one of your ticket statuses. | | **Set status category** | Moves the ticket to a category's default status. | | **Assign team** | Assigns a team, or **Default team (current)**. If nobody has the ticket yet, the team's assignment method picks a member. | | **Assign agent** | Assigns a specific teammate. | | **Unassign** | *Removes the ticket's assignee. Its team stays.* | | **Set priority** | Sets **Urgent**, **High**, **Medium** or **Low**. | | **Add internal note** | Adds a note only your team sees. | | **Add tags** | Adds tags; tags already on the ticket stay. | | **Remove tags** | Removes the listed tags. | | **Set tags** | Replaces the ticket's tags with exactly these. | | **Remove all tags** | *Removes every tag from the ticket.* | | **Send email** | Emails the requester, the assigned agent, a team, a teammate or any address. See [Send email](#send-email). | | **Send Slack message** | Posts to a Slack channel. See [Send Slack message](#send-slack-message). | | **Start Slack thread** | Posts one card per ticket in a Slack channel whose thread replies reach the customer. See [Slack ticket threads](/docs/user-guides/chatbot/help-desk/slack-ticket-threads). | | **Send webhook** | Sends the ticket to one of your saved webhooks. See [Send webhook](#send-webhook). | Status changes don't apply to a ticket that's already closed or cancelled. ### Send webhook **Send webhook** posts the ticket to an endpoint you saved under **Settings › Webhooks**. Pick it from the **Webhook** list; if you have none yet, the hint says *Create a webhook in Settings → Webhooks*. ![The Send webhook action with its webhook list reading No webhooks yet and the hint Create a webhook in Settings → Webhooks.](annotated/07-webhook.webp "Webhooks come from Settings › Webhooks.") The request body names the event, `helpdesk.trigger`, and carries the ticket and the rule that sent it. It's signed with the webhook's secret in the `x-qwryai-signature` header, the same as your other webhooks. ```json { "eventType": "helpdesk.trigger", "chatbotId": "…", "payload": { "ticketId": "TKT-13", "rule": { "id": "…", "name": "Tag refund requests" }, "ticket": { "id": "TKT-13", "subject": "Charged twice for my subscription", "status": "open", "statusId": "…", "priority": "high", "channel": "email", "ticketType": "ticket", "teamId": null, "assigneeId": null, "tags": ["refund-request"], "requester": { "name": "Priya Shah", "email": "priya.shah@example.com" }, "conversationId": null, "url": "https://www.qwryai.com/…/tickets?ticketId=TKT-13" } } } ``` ### Send email **Send email** sends a plain email built from the ticket. ![The Send email action with the recipient set to Requester and the Subject and body fields, whose placeholder lists {{ticket.id}}, {{ticket.subject}} and {{ticket.requester_name}}.](annotated/08-email.webp "Pick a recipient, then write the subject and body.") #### Recipient | Recipient | Who gets it | | - | - | | **Requester** | The customer on the ticket | | **Assigned agent** | The teammate who has the ticket; skipped when it's unassigned | | **Specific team** | Every member of the team you pick | | **Specific agent** | The teammate you pick | | **Custom address** | Any full email address you type | Emails to anyone other than the requester end with a link to the ticket. #### Subject and body Both accept these placeholders: | Placeholder | Becomes | | - | - | | `{{ticket.id}}` | The ticket number, such as `TKT-13` | | `{{ticket.subject}}` | The ticket subject | | `{{ticket.requester_name}}` | The customer's name | | `{{ticket.requester_email}}` | The customer's email | | `{{ticket.status}}` | The ticket's status category | | `{{ticket.priority}}` | The ticket's priority | > [!TIP] > > To alert a teammate when they're given a ticket, use **Assignee changed** with **Send email** to **Assigned agent**. > [!WARNING] > > A trigger on **Ticket is Updated** with no other conditions runs on every change, including each message. Narrow it down before you add **Send email** to the requester, or customers will get an email for every update. ### Send Slack message **Send Slack message** posts to a channel in the Slack workspace connected under **Integrations**. Type the channel, such as `#support`, and the message; the same placeholders work, and a link to the ticket is added at the end. ![The Send Slack message action with the #support channel placeholder, the note that public channels are joined automatically and private ones need /invite @QwryAI, and the message field.](annotated/09-slack.webp "A link to the ticket is added to every message.") > [!NOTE] > > *Public channels are joined automatically. For a private channel, run /invite @QwryAI in it first.* ## Checking what a trigger did Each time a trigger runs on a ticket, the ticket's conversation shows a line such as *Trigger Tag refund requests ran*. Changes it made, such as a new priority or tags, appear in the ticket's history, and notes it added show with the other internal notes. ## Managing triggers ### Ordering Drag a trigger by its handle to move it up or down; the number beside each one is its place in the run order. With the keyboard, focus the handle and press the up or down arrow. ### Activate or pause Use the switch on a trigger's row. A paused trigger shows **Paused** and doesn't run until you switch it back on. ![The Tag refund requests row showing the Paused badge next to its On create badge, its description, and the pointer on its switch, which is off.](annotated/10-paused.webp "Paused triggers keep their settings.") ### Edit or delete Select the pencil to edit a trigger, or the bin to delete it. Deleting asks you to confirm: *This trigger stops running. Changes it already made to tickets stay.* ### Needs attention A trigger that points at something that no longer exists, such as a deleted team, an archived status, a removed teammate or a deleted webhook, shows a **Needs attention** badge with the reason, for example *References a team that no longer exists. Edit this rule to fix it.* ## Good to know * Only teammates who can manage Helpdesk settings can create, edit, reorder or delete triggers; others see them read-only. * Changes made by triggers and automations don't start the triggers again. Only teammates, customers and the system do. * Triggers don't time anything. For "no reply after 24 hours", use [Automations](/docs/user-guides/chatbot/help-desk/automations). ### Limits | Limit | Value | | - | - | | Triggers per AI agent | 100 | | Conditions per group | 30 | | Actions per trigger | 20 | | Values in one list condition | 100 | | Words in one `contains any of` condition | 50 | | Name | 100 characters | | Description | 280 characters | | Tags in one tag action | 20 | | Email subject / body | 200 / 10,000 characters | | Slack message | 3,000 characters | ## Frequently asked questions > [accordion] Can a trigger fire when a ticket has had no reply for 24 hours? > > No. Triggers only run when a ticket is created or updated. Use an [automation](/docs/user-guides/chatbot/help-desk/automations) with **Time since last customer message** instead. > [accordion] How do I run a trigger when a customer replies? > > Add **New message is From customer** under **Match ALL of**. > [accordion] Can triggers use priority and tags as conditions? > > Yes. Use **Priority** and **Tags**. Custom fields aren't available as trigger conditions. > [accordion] How do I email an agent when a ticket is assigned to them? > > Add **Assignee changed** under **Match ALL of**, then **Send email** with **Assigned agent** as the recipient. > [accordion] How do I tag every ticket from one company's email domain? > > Add **Ticket is Created** and **Email contains** the domain, such as `@acme.com`, then **Add tags**. > [accordion] Do triggers run on tickets created by a takeover? > > A takeover ticket is created already assigned to you, so routing on **Ticket is Created** usually has nothing to do. Triggers on **Ticket is Updated** run as the ticket changes. > [accordion] Can two triggers loop forever? > > No. Each create or update runs the list once, top to bottom, so one trigger's change can't start the list again. ## Next steps > [card] Automations | /docs/user-guides/chatbot/help-desk/automations | Act on tickets that have waited too long. > [card] Slack ticket threads | /docs/user-guides/chatbot/help-desk/slack-ticket-threads | Reply to tickets from a Slack thread. > [card] Tags | /docs/user-guides/chatbot/help-desk/tags | Organise tickets so triggers and views can find them.