# Procedures: step-by-step workflows for your AI agent > Give your agent a step-by-step process to follow whenever a conversation matches the trigger you describe A **Procedure** is a standard operating procedure for one situation. It pairs a trigger, written as a sentence under **When to trigger**, with ordered **Instructions** your agent works through, including the [Actions](/docs/user-guides/chatbot/actions/actions-overview) it calls along the way. Use Procedures for flows where you don't want your agent improvising, such as refunds, missing orders, cancellations and escalations. Procedures run in conversations on every channel your agent answers on, unless you limit them with a **Channel** trigger. You build them in **Build › Procedures**. ## When to use a Procedure | Use | When | | - | - | | **Instructions** | The rule applies to every conversation, such as tone, scope or topics to avoid. | | **An Action on its own** | Your agent needs to do one thing, such as look up an order, and it's fine for it to decide when. | | **A Procedure** | The situation needs several steps in a set order, a check before acting, or a different path depending on the answer. | Reach for a Procedure when the order matters (look up the order before offering a refund), when there are eligibility rules (orders older than 30 days go to your team), or when an Action is sensitive. For sensitive Actions, also turn on [**Only use in Procedures**](/docs/user-guides/chatbot/procedures/how-procedures-run#procedure-only-actions), so the Action only runs as a step inside a Procedure. If one rule covers the case, such as "Share our returns page when customers ask about returns", keep it in your [instructions](/docs/user-guides/chatbot/build). ## Anatomy of a Procedure Every Procedure has three parts: | Field | Purpose | | - | - | | **Name** | A label for the Procedure, such as "Order not received", up to 100 characters. New Procedures start as **Untitled Procedure**. | | **When to trigger** | A sentence describing *when* this Procedure should start: the situation or request that routes the conversation here. Type `/` in it to add trigger chips. | | **Instructions** | The steps your agent follows. Steps can call Actions, send exact messages and branch on conditions. | ![A new Procedure in the editor: the Untitled Procedure name with a Draft badge and Save button, the When to trigger sentence, the Instructions with its steps-remaining count, and the Preview panel.](annotated/03-editor.webp "Name, When to trigger and Instructions.") ### Triggers Describe the situation in **When to trigger** in your own words, for example *The customer says their order hasn't arrived.* To start a Procedure in other ways, select **Add trigger** or type `/` in the sentence and pick a chip. Each chip's settings open as soon as you add it. * **No reply**: start when the customer hasn't answered an AI reply for the time you set. * **Repeat**: start again on a schedule until the customer replies. Add a **No reply** or **API** trigger first. * **Schedule**: start at set times, with no customer message. * **API**: start for one contact from your own systems, or for contacts you select on the **Contacts** page. * **Start when a ticket is opened from a chat** and **Start when a chat's ticket is closed**: start in the conversation when its support ticket opens, or closes and the AI is back in the chat. * **Channel**: only run on the channels you pick. > [!NOTE] > > A Procedure whose triggers are only **No reply**, **API** or ticket events never starts from a customer's message. It starts only when its chip fires. ![The When to trigger sentence with the pointer on the Add trigger button.](annotated/04-add-trigger.webp "Add a trigger chip to the sentence.") ## Steps Steps run **in order**, top to bottom. Write each one in plain language and press Enter for the next. There are three kinds: * **Instruction steps**: something your agent does, such as "Ask the customer for their order number". * **Message steps**: exact words your agent sends, with contact values filled in. Choose **Message** from the `/` menu. * **Conditions**: a decision point with an **If** branch, optional **Else if** branches and an optional **Else**. Choose **Condition** from the `/` menu. Your agent checks the conditions from the top, follows the first one that matches, then carries on after the condition. ![The Instructions editor with a first step asking the customer for their order number and the email they ordered with.](annotated/05-step.webp "Write a step in plain language.") ![The / menu on a new step with Condition (Add If and Else branches) and Message (Send exact words, with contact values).](annotated/07-command-menu.webp "Type / for a Condition or a Message.") > [!NOTE] > > Limits: up to **15** steps per Procedure, counting the steps inside conditions. Each step can be up to **1,000** characters and each condition up to **500**. A condition can have up to **5** branches, **If** and **Else** included, and a condition can't be placed inside another one. The editor shows how many steps you have left. ### Referencing Actions with `@` Inside a step, type `@` to pick an [Action](/docs/user-guides/chatbot/actions/actions-overview) your agent should run at that point, for example **Get order status**. When your agent reaches that step, it calls the Action. To build an Action just for this Procedure, choose **Create new AI Action**. ![The @ menu under a step listing the agent's Actions and Create new AI Action.](annotated/06-action-menu.webp "Type @ to pick an Action.") > [!NOTE] > > Save checks every step. An empty step shows *Step cannot be empty*, and an empty condition shows *Condition is required*. ### Using variables with `{{ }}` Personalize steps, messages and conditions with values filled in when the Procedure runs. Type `{{` in a step to open the picker, which groups the values into: | Group | Examples | What it fills in | | - | - | - | | **Contact attributes** | Name, Email, Phone, External ID, Country | The current contact's saved details | | **Conversation attributes** | Channel, Status, Assignee, Priority | Details of the current conversation | | **Action outputs** | The fields an earlier Action returned | A result from an Action called earlier in this Procedure | ![The {{ menu with Contact attributes such as Name and Email, Conversation attributes, and Action outputs.](annotated/08-value-menu.webp "Type {{ to insert a contact value or an Action result.") > [!NOTE] > > A value only fills in when it's known for the conversation. In a **Message** step, you can give each value a fallback to use when it's missing. In other steps, write the step so your agent can still go on, or ask for the value, when it's missing. ## Start from a template Don't want to start from scratch? Open the **Templates** tab to browse ready-made Procedures, filter them by type, and select **Preview** to read one. **Before you start** lists anything the template needs, such as an integration to connect. Select **Use this template** to open an editable copy, then adjust its trigger and steps to your business. ## Creating a Procedure **1. Open Procedures** Open your agent, select **Build** in the sidebar, then **Procedures**, and select **Create Procedure**. You can also start from a [template](#start-from-a-template). ![The Create Procedure page asking What should Qwry get done for your customers?, with a composer and four suggested processes such as Help a customer resolve a delayed delivery.](annotated/01-procedures-list--open.webp "Create Procedure: describe the process and Qwry drafts it.") **2. Describe the process** Under **What should Qwry get done for your customers?**, describe the process in your own words, or pick a suggestion such as **Help a customer resolve a delayed delivery.** Qwry drafts the name, trigger and steps for you to review. ![The Create Procedure composer filled in with a description of an order-not-received process: look up the order, check tracking, and open a ticket if it's more than 5 days late.](annotated/02-describe.webp "Describe the process in your own words.") **3. Review the trigger and steps** Adjust the name, the **When to trigger** sentence and its chips, and the steps. Add Actions with `@`, values with `{{`, and conditions or messages with `/`. To change things in bulk, ask in **Ask AI to update this Procedure** and review the suggested changes. Try it in the **Preview** panel beside the editor. **4. Save and publish** Select **Save**. Saving puts your changes in your agent's draft: *Draft saved. Published conversations are unchanged.* Customers get the Procedure once you select **Publish** in the top-right corner. After that, the switch in the editor's header shows **Live** or **Paused**, and you can pause the Procedure at any time. > [!NOTE] > > Your plan sets how many Procedures can be live at once: **4** on Free and Starter, **12** on Growth, and unlimited on Enterprise. At the limit, QwryAI shows *Please upgrade your plan to enable more Procedures. You can also pause a live one first.* ## Managing Procedures **My Procedures** shows each Procedure as a card with its trigger sentence, the number of blocks and when it was last saved. Filter by **Live**, **Paused** or **Draft**, or search by name. Each card has a switch to pause or turn it on, and a **⋯** menu with **Edit**, **Duplicate**, **History** (its save history) and **Delete**. ## Examples The examples below show steps in practice. The Action names are examples: type `@` in a step to pick your own agent's Actions. ### Order not received This Procedure checks an order's tracking before promising anything, and sends late orders to your team as a ticket. **When to trigger:** The customer says their order hasn't arrived. **Instructions:** ```text 1. Ask the customer for their order number and the email they ordered with. 2. Use @Get order status to find the order and its tracking. 3. If the order shipped more than 5 days ago and hasn't been delivered: Apologize, and use @Create ticket so the team can chase the carrier. Tell the customer the team will follow up by email. Else: Share the tracking link and the expected delivery date. 4. Thank the customer by name: {{Name}}. ``` Step 3 is a condition with an **If** and an **Else** branch, so every order goes down one of the two paths before step 4. To make sure tickets about late orders only open through this flow, turn on **Only use in Procedures** on the ticket Action. ### Follow up when the customer goes quiet This Procedure uses trigger chips instead of a customer message. **When to trigger:** **No reply** for 30 minutes, then **Repeat** every day, 2 times in total. **Instructions:** ```text 1. Message: Hi {{Name}}, just checking in. Did you find what you were looking for? 2. If the customer replies with a new question: Answer it, then offer to help with anything else. ``` Because its triggers are **No reply** and **Repeat**, this Procedure only starts when the customer stops answering. It stops repeating as soon as they reply. ## Frequently asked questions > [accordion] How many steps can a Procedure have? > > Up to 15, counting the steps inside conditions. A condition can have up to 5 branches, **If** and **Else** included, and conditions can't be nested. > [accordion] Can two Procedures run at the same time? > > No. Your agent follows one Procedure at a time: the one whose trigger best matches what the customer is asking for right now. It can switch to another Procedure on a later message if the customer asks for something else. To handle two things together, combine them into one Procedure with conditions. See [How Procedures run](/docs/user-guides/chatbot/procedures/how-procedures-run). > [accordion] Does a Procedure need to use Actions? > > No. A step can be a plain instruction, such as "Ask the customer for their order number". Add Actions with `@` only where your agent needs to look something up or make a change. > [accordion] Why does my Procedure run on the website but not on WhatsApp? > > Check for a **Channel** chip in **When to trigger**. With one, the Procedure only runs on the channels it lists. Also check that it's **Live** and published. > [accordion] How many Procedures can be live? > > 4 on Free and Starter, 12 on Growth, and unlimited on Enterprise. Pause a live Procedure to turn on another one. ## Next steps > [card] How Procedures run | /docs/user-guides/chatbot/procedures/how-procedures-run | How your agent picks one Procedure, follows it across messages, and keeps Procedure-only Actions on rails.