> For the complete documentation index, see [llms.txt](https://docs.klink.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.klink.cloud/advanced-setup/workflow-automation.md).

# Workflow Automation

Workflows automatically assign, reply to, tag, score, or route conversations. Each rule follows **When (trigger), If (conditions), Do (actions)**.

**Where:** **Workflow** in the left menu (page title "Workflow Automation").

{% hint style="info" %}
For on-demand (manual / custom) workflows, including how agents run them from a conversation or in bulk from the CX Log, see [Manual Workflows Shortcut](https://docs.klink.cloud/advanced-setup/setup-workflow-automation/manual-workflows-shortcut).
{% endhint %}

## What workflows are

A workflow is an automation rule. When a trigger event happens, klink.cloud checks optional conditions, then runs actions in order. Use workflows to:

* Route new chats to the right queue or agent
* Let Kai (Chat AI Agent) answer first
* Send after-hours replies
* Score sentiment and CSAT when a conversation closes
* Nudge silent customers
* Auto-fill case log fields and post AI summary comments for handoffs
* Give agents one-click wrap-up shortcuts (manual workflows)
* Create tickets from conversations (optionally with AI subject and description)

## The workflow list

* **Create:** click **New workflow**.
* **Enable / Disable:** the toggle in each row. Disabled workflows do not run.
* **Priority / order:** drag a row, or use the **Hierarchy** buttons (Move to top / up / down / bottom). Rules at the top are evaluated first when several match the same conversation, so put the most specific rules highest.
* **Duplicate / Delete / Edit:** use the row menu (⋮). Click a workflow's name to edit it.
* **Custom** badge (⚡): marks a manual **When run manually** workflow. See [Manual Workflows Shortcut](https://docs.klink.cloud/advanced-setup/setup-workflow-automation/manual-workflows-shortcut).

## Anatomy of a workflow

Every workflow is built in three steps.

### Step 1: Trigger (When)

Add one or more trigger events. Most combine with **OR** (any one fires the rule); some are exclusive.

| Trigger                                 | What it does                                                            | Extra setup                                |
| --------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------ |
| **When new chat room is open**          | Runs when a customer sends their first message.                         | none                                       |
| **When a chat room is closed**          | Runs every time a conversation is closed.                               | none                                       |
| **When a customer sends a message**     | Runs every time a customer replies.                                     | none                                       |
| **When chat room is on hold**           | Runs on rooms held for a period.                                        | Hold timer (hours, minutes). *Exclusive.*  |
| **When an AI agent transfer chat room** | Runs when an AI agent hands off to a human.                             | none. *Exclusive.*                         |
| **When an AI agent session times out**  | Runs when an AI conversation goes idle past its timeout.                | nothing to set. *Exclusive.*               |
| **When customer didn't response**       | Runs if the customer is silent for a period.                            | Timer (days, hours, minutes). *Exclusive.* |
| **When agent didn't response**          | Runs if the agent is silent for a period.                               | Timer (days, hours, minutes). *Exclusive.* |
| **When run manually**                   | Never runs on its own; an agent starts it from the Run workflow button. | none. *This makes it a custom workflow.*   |

### Step 2: Conditions (If)

Optional. Conditions combine with **AND** / **OR**. Operators include **is / is not**, **contains / does not contain**, **starts with / ends with**, **Empty**, and for business hours **Inside / Outside of business hour**.

| Condition                    | What it filters by                                                                                         |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------- |
| **AI Conditions**            | Detect intent using a plain-English prompt (for example "Customer is asking for a refund or complaining"). |
| **AI Conditions (Advanced)** | Analyze the whole chat transcript with a custom prompt, and branch actions by its output.                  |
| **Hold label**               | The hold-label status.                                                                                     |
| **Contact info**             | Name, Contact label, Phone, Mail.                                                                          |
| **Language**                 | The message language.                                                                                      |
| **AI Language**              | The AI-detected language.                                                                                  |
| **Chat info**                | Assignee.                                                                                                  |
| **Channel info**             | Messenger, LINE, Viber, etc.                                                                               |
| **Message content**          | Keywords in the message.                                                                                   |
| **Business hour**            | Inside / Outside a business-hours schedule.                                                                |

#### How AI Conditions (Advanced) works

This is the recommended path for sentiment and CSAT scoring on the full conversation:

1. **Left side:** an **AI Prompt** with **versions** (v1, v2, v3). Write a prompt that returns a single label (for example `very_satisfied / satisfied / neutral / unsatisfied / very_unsatisfied`), and end it with "Reply with only the label". Add versions to experiment; only the active version runs.
2. **Right side:** **Test on chat history**. Click **Select chat**, preview a real transcript, and click **Run prompt** to see the AI's output so you can tune the prompt before saving.
3. When you use an Advanced condition, the Actions step lets you **branch by the AI's output**.

{% hint style="warning" %}
With the **When run manually** trigger, the **Message content** and **Hold label** conditions are hidden (a manual run has no triggering message or hold status).
{% endhint %}

### Step 3: Actions (Do)

Actions run in sequence when the trigger and conditions are met.

| Action                  | What it does                                                                                                                                                                                                   |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **AI Agent**            | Let a live AI Agent (Kai) handle the conversation.                                                                                                                                                             |
| **Assign Human Agent**  | Route to a specific agent or a **queue**.                                                                                                                                                                      |
| **Send Message**        | Send a text reply: **Fixed Message** (you type it) or **AI Message** (AI-generated).                                                                                                                           |
| **Send Rich Message**   | Send text plus images, videos, or attachments.                                                                                                                                                                 |
| **Add contact label**   | Add labels to the contact.                                                                                                                                                                                     |
| **Add Chat Tags**       | Add tags to the case.                                                                                                                                                                                          |
| **Add Note**            | Add a note to the case log.                                                                                                                                                                                    |
| **Add Comment**         | Post an internal team-only comment (supports @mentions). Use **AI Generated** mode to draft a conversation summary from a prompt.                                                                              |
| **Set Disposition**     | Set the case disposition.                                                                                                                                                                                      |
| **Set Categories**      | Set the case categories (up to 3 levels).                                                                                                                                                                      |
| **Set Type**            | Set the case type.                                                                                                                                                                                             |
| **Set CSAT Score**      | Set a fixed CSAT (Very satisfied to Very unsatisfied).                                                                                                                                                         |
| **AI CSAT Score**       | Let AI read the transcript and score CSAT.                                                                                                                                                                     |
| **Set Sentiment Score** | Set a fixed sentiment (Positive / Neutral / Negative).                                                                                                                                                         |
| **AI Sentiment Score**  | Let AI read the transcript and score sentiment.                                                                                                                                                                |
| **Auto Case Log**       | Let AI read the transcript and fill in **blank** case-log fields. Pair with tags, categories, notes, or comments for fuller enrichment.                                                                        |
| **Create Ticket**       | Create a ticket from the conversation, with optional AI subject and description from the transcript. See [Create Ticket](https://docs.klink.cloud/advanced-setup/workflow-automation/recipe-create-ticket.md). |
| **Send Webhook**        | Send an HTTP request to an external URL (with variables like message, contact, transcript).                                                                                                                    |
| **Close Chat**          | Auto-resolve and close the case (optionally with a disposition).                                                                                                                                               |

#### Show an action in the conversation

Some actions change a case without leaving a line in the conversation. Tick **Show in inbox** next to an action to add a line each time it runs, for example: Workflow "Auto Status" changed Disposition from "Pending" to "Resolved".

* **Where it's available:** Set Disposition, Set Type, Set Categories, Add Chat Tags, Add Note, Set CSAT Score, AI CSAT Score, Set Sentiment Score, AI Sentiment Score, Add contact label, AI Agent, Create Ticket, Send Webhook, and Assign Human Agent when it assigns to a queue.
* **Off by default:** Existing workflows don't add lines until you tick the box.
* **Only real changes:** No line is added when nothing changed. For tags and categories, the line names only what was added.
* **Private details stay hidden:** Note text and webhook addresses are never shown.

#### Branching by AI output

Only available with **AI Conditions (Advanced)**. Choose **Branch by AI output**, add **Output labels** matching what your prompt returns (for example `very_satisfied`, `very_unsatisfied`), and configure the actions for each label plus an **Else** fallback.

Example: `very_satisfied` sets CSAT to Very satisfied; `very_unsatisfied` sets CSAT to Very unsatisfied and adds a comment to alert the team.

## Important rules

* **Queue assignment** (Assign Human Agent, then Queues) can only be used with the **When new chat room is open** trigger.
* **AI Agent** and **Assign Human Agent** cannot both be in the same workflow.
* The **on-hold** trigger only allows **Close Chat**, **Send Message**, **Send Rich Message**, and **Add contact label**.
* Most actions can be added once; **Send Message**, **Send Rich Message**, and **Add contact label** can be added multiple times.

## Custom (manual) workflows

A **custom workflow** uses the **When run manually** trigger. It never fires on its own. An agent runs it on demand from the **Run workflow** (⚡) button on a conversation, or in bulk from the CX Log. Only **active** custom workflows appear in the Run workflow picker.

Full create and run steps: [Manual Workflows Shortcut](https://docs.klink.cloud/advanced-setup/setup-workflow-automation/manual-workflows-shortcut).

## Step-by-step recipes

| Recipe                                             | Guide                                                                                                                                    |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| 1. Auto-assign new chats to a queue                | Route to a queue                                                                                                                         |
| 2. Let Kai answer first                            | Kai first response                                                                                                                       |
| 3. Auto-reply outside business hours               | After-hours auto-reply                                                                                                                   |
| 4. Score sentiment and CSAT on close (recommended) | Sentiment and CSAT on close                                                                                                              |
| 5. Chase a silent customer                         | Silent customer nudge                                                                                                                    |
| 6. One-click wrap-up (custom workflow)             | One-click wrap-up                                                                                                                        |
| 7. Auto Case Log (fill blank case-log fields)      | [Auto Case Log](https://docs.klink.cloud/advanced-setup/workflow-automation/recipe-auto-case-log.md)                                     |
| 8. AI conversation summary comment                 | [AI conversation summary comment](https://docs.klink.cloud/advanced-setup/workflow-automation/recipe-ai-conversation-summary-comment.md) |
| 9. Create Ticket from a conversation               | [Create Ticket](https://docs.klink.cloud/advanced-setup/workflow-automation/recipe-create-ticket.md)                                     |

Also see: AI CSAT scoring workflow (aligns with Recipe 4; replaces the old multi-workflow pattern).
