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

# Procedures

> Give the agent step-by-step scripts for refunds, cancellations, disputes and other situations it must not improvise.

A **procedure** is a script the agent follows when a situation comes up. Your [instructions](https://wiredesk.ai/docs/persona/instructions.md) describe the business and how to behave; a procedure says exactly what to do, in order, when a customer wants a refund, cancels, disputes a charge or asks for something only your team can do.

Procedures work in website chat, on the phone and by email. They matter most on calls, where an agent that improvises a refund policy is harder to correct than one in a chat window.

## Where it is

**Agents → your agent → Instructions › Procedures.** The **Instructions** page has a **Procedures** card with an **Open procedures** button, and **⌘K** finds it under "procedure", "workflow", "SOP" or "script".

The page lists your procedures, each with its switch and its last 30 days, and the templates to start from. Click a procedure's name to open its editor.

## What a procedure is

| Field | What it's for |
| - | - |
| **Name** | What you call it, such as "Refund request". Each procedure on an agent needs its own name. Up to 80 characters. |
| **When to use** | The situation, in the customer's terms: "They want a refund for an order, or say something they bought is faulty." The agent reads this to decide whether the procedure applies. Up to 500 characters. |
| **Steps** | Up to 15, followed in order. Each step is an instruction or a branch. |

### Instructions and branches

An **instruction** is one thing to do: "Ask for their order number."

A **branch** picks what to do next. It has an **If**, as many **Otherwise, if** conditions as you need, and an optional **Otherwise**, up to five in total. The agent takes the first condition that is true, does only that, and then carries on with the next step. A branch can't contain another branch.

### Calling an action with `@`

Write `@` and an action's name in a step to have the agent call that action at that point, for example `Call @take_message with the order number and the reason.` The **@** button beside each box lists what you can call:

* `@take_message`, which every agent has on every channel.
* `@request_human` in chat and email, and `@transfer_to_human` on calls, when [A person in chat & email](https://wiredesk.ai/docs/actions/request-a-human.md) and [Transfer calls to a person](https://wiredesk.ai/docs/actions/hand-calls-to-you.md) are switched on under **Handoff**.
* Every action you've added under **Actions**, by its name. A [booking action](https://wiredesk.ai/docs/actions/book-meetings.md) is called as `@get_booking_slots` and `@book_meeting`.

An email address such as `support@acme.com` is not read as an action.

### Variables with `{{ }}`

Write a variable in a step, a condition or **When to use**, and the agent sees its value for the conversation it's in. The braces button beside each box inserts one.

| Variable | What it is |
| - | - |
| `{{contact.name}}` | The name the person gave on an earlier lead or message, or the name your website passed for a [signed-in visitor](https://wiredesk.ai/docs/widget/verified-visitors.md). |
| `{{contact.email}}` | Their email address, when they wrote by email or your website passed one for a signed-in visitor. |
| `{{user.name}}` | The name your website passed for a signed-in visitor, in website chat. |
| `{{user.email}}` | The email your website passed for a signed-in visitor, in website chat. |
| `{{agentAvailable}}` | `true` inside your [business hours](https://wiredesk.ai/docs/actions/business-hours.md), `false` outside them. With no hours set, always `true`. |

When a value isn't known, the agent sees "(not known)", so write steps that still work without it: `Their email may be {{contact.email}}; if it is not known, ask for it.`

## Start from a template

The **Templates** card has five starting points:

| Template | What it does |
| - | - |
| **Order return** | Gets the order number, the item and the reason, branches on damaged, late or ordinary returns, and passes the return to your team with `@take_message`. |
| **Cancel subscription** | Asks why once, mentions a cheaper plan only if your knowledge has one, confirms the account email and passes the cancellation on. |
| **Billing dispute** | Takes the date, amount and account email, never promises a refund, and passes it to billing. |
| **Book an appointment** | Offers real open times and books one. Needs **Book meetings** under Actions. |
| **After-hours message** | When `{{agentAvailable}}` is false, takes a proper message instead of promising a person. |

**Use template** makes an editable copy, switched off, and opens it. If the agent already has one with that name, the copy is numbered: "Order return 2".

## Write your own

**1. Add a procedure**

On the Procedures page, click **Add a procedure**.

**2. Name it and say when to use it**

Make **When to use** distinct from your other procedures. When two could apply, the agent picks one.

**3. Add the steps**

Use **Add a step** and **Add a branch**, and the arrows to reorder them. Blank steps are dropped when you save.

**4. Switch it on and save**

Turn on **On** and click **Save**. You'll see "Refund request is on."

You need the Owner or Admin role, as for Actions. An agent can have up to 20 procedures.

### When it won't switch on

A procedure can't be switched on while a step names an action the agent doesn't have, or one that's switched off under Actions, or uses a variable that isn't one of the five above. The editor lists what's wrong under the switch as you type, for example:

* "@lookup\_order isn't one of this agent's actions"
* "@issue\_refund is switched off under Actions"
* `{{order.total}} isn't a variable you can use`

You can still **Save** it, switched off, and finish it later. The list shows "Can't switch on:" with the first problem.

## How procedures run

* **One at a time.** In each reply, the agent follows at most one procedure: the one whose **When to use** best matches what the customer wants now. It can switch to another when the customer clearly moves on.
* **Across the conversation.** When a step needs something from the customer, the agent asks, waits for the answer, and carries on from the same step on the next message, in chat and email as well as on a call.
* **Skipped where an action is missing.** Before a conversation starts, every action a procedure names is checked against the channel, including actions inside branches that might never run. If one isn't available there, the procedure is skipped on that channel. The list says so: "Runs in chat, email. Skipped on calls: @request\_human isn't available there."
* **The customer never hears about it.** The agent doesn't mention procedures, steps or tool names.
* **Preview calls too.** A call on the **Call** tab of **Preview** follows your procedures as a phone call would, but isn't counted.

Outside business hours the agent can't ask for a person, so a procedure that calls `@request_human` is skipped in chat and email until the team is back, and the agent offers to take a message instead. For a scripted after-hours flow, start from the **After-hours message** template, which uses `@take_message`.

## How it has done

Each procedure's page shows its last 30 days:

| Number | What it counts |
| - | - |
| **Triggered** | Conversations the agent started it in. A conversation counts once, however many messages it took. |
| **Pending** | Started, and not yet at the last step. |
| **Resolved** | Reached the end. |

**Runs per day** charts the same numbers, with resolved at the bottom of each bar and pending on top. Days are UTC. Removing a procedure removes its counts; the conversations it ran in are kept.

Each conversation's page in **Conversations** shows the procedures it followed under **Procedures it followed**: which one, and whether it reached the last step. The name opens the procedure.

## Related

* [Writing instructions](https://wiredesk.ai/docs/persona/instructions.md)
* [Actions](https://wiredesk.ai/docs/actions/overview.md)
* [Business hours](https://wiredesk.ai/docs/actions/business-hours.md)
* [Verified visitors](https://wiredesk.ai/docs/widget/verified-visitors.md)


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