> 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/recipe-sentiment-and-csat-on-close.md).

# Recipe: Sentiment and CSAT on close

Score sentiment and CSAT on the **whole conversation** when it closes. This is the recommended sentiment and CSAT setup.

{% hint style="danger" %}
Use **one** workflow with **AI Conditions (Advanced)** and branching. Do **not** create multiple competing score workflows for the same close event. When several rules match, later runs can **overwrite** earlier scores.
{% endhint %}

## Why this pattern

* Triggering on **When a chat room is closed** lets the AI see the entire transcript.
* **AI Conditions (Advanced)** returns a single label; you **Branch by AI output** to set fixed CSAT and sentiment per label.
* An **Else** branch can fall back to **AI CSAT Score** and **AI Sentiment Score**.

## Steps

1. Go to **Workflow** and click **New workflow**.
2. Name it, for example **Sentiment and CSAT on close**.
3. **Trigger:** **When a chat room is closed**.
4. **Condition:** **AI Conditions (Advanced)**. Write a prompt that classifies the transcript into one label and replies with only that label (for example `very_satisfied`, `satisfied`, `neutral`, `unsatisfied`, `very_unsatisfied`). Use **Test on chat history** against a few real chats before you save.
5. **Action:** choose **Branch by AI output**. Add labels matching your prompt. Under each label set **Set CSAT Score** and **Set Sentiment Score** accordingly. Add an **Else** branch that runs **AI CSAT Score** and **AI Sentiment Score** as a fallback.
6. **Save** and enable the workflow.

### Example branch mapping

Use labels that match your prompt exactly. Map each to the matching **Set CSAT Score** and **Set Sentiment Score** values (CSAT: Very satisfied to Very unsatisfied; Sentiment: Positive / Neutral / Negative).

## Re-score historical cases

1. Open the **CX Log**.
2. Filter and select the cases you want.
3. Use the bulk **Run workflow** action with a **manual** (custom) workflow that runs the same Advanced prompt and branching. See [Manual Workflows Shortcut](https://docs.klink.cloud/advanced-setup/setup-workflow-automation/manual-workflows-shortcut) (Example 2: re-score sentiment).

## Viewing scores

In the **CX Log**, use the **Sentiment score** and **CSAT score** columns and filters. You can also edit scores inline (subject to permission). Summary analytics include CSAT and sentiment on the Analytics Dashboard.

## Related

* AI CSAT scoring workflow (replaces the old five-workflow guide)
* [Setup Workflow Automation](/advanced-setup/workflow-automation.md)
* [Manual Workflows Shortcut](https://docs.klink.cloud/advanced-setup/setup-workflow-automation/manual-workflows-shortcut)
