---
title: "Define customer segments"
description: "Create customer segments and the rules that tag feedback with them, with a preview of each rule before Deck saves it."
url: "/docs/agents/workflows/define-segments"
---

This page is an agent-readable workflow for Deck. Humans can follow along. Coding agents should treat the steps as the source of truth.

# Define customer segments — agent workflow

* **Use it when:** the user asks "set up segments for Enterprise and SMB", "split our feedback by plan", "tag all Zendesk feedback as support" or "show feedback from our key accounts only".
* **Outcome:** the segments that the user approved exist. Each one has rules that tag the right insights, and the user saw a preview of each rule before Deck saved it.
* **Needs:** Deck MCP. Segments must be on for the workspace, and only an organization admin can turn them on. Every member with MCP access can create segments and rules. A CRM field rule needs a connected CRM, and only organization admins connect integrations, in Settings → Integrations.

## 1. Probe Deck MCP

Call `get_user_context`. This must be a real tool call.

* 401 Unauthorized: tell the user to connect Deck MCP in this client (Settings → Connections). Stop.
* No Deck tools: fetch and follow [https://docs.getdeck.io/docs/agents/getting-started/prompts/ai-pm.md](https://docs.getdeck.io/docs/agents/getting-started/prompts/ai-pm.md). Stop this workflow until the tools work.

## 2. Read the current state

Make these calls at the same time:

* `explore_segments` with no parameters: the segments with their insight counts and rule counts.
* `explore_workspace` with `view` set to `settings`: your role and whether segments are on.
* `get_overview`: read `organization.target_audience` for the customer groups.
* `explore_integrations`: the connected sources that rules can match. For Slack channels, call it again with `integration_type` set to `SLACK` and `view` set to `slack_channels`.

When segments are off and you are an organization admin, offer to turn them on with `set_segments_enabled` and `enabled` set to `true`. Get a yes first. A member gets `AUTH_ERROR`: tell the user to ask an organization admin, who can also turn segments on in Settings → Segments. Stop until segments are on.

## 3. Propose the segments and rules

Ask the user which customer groups matter, for example plan tier, company size, region or a list of key accounts. Use the user's words. Do not create a segment that already exists in step 2.

For each segment, plan:

* A name of 1 to 100 characters. Segment names are unique in the organization.
* An optional color as `#RRGGBB` and a description of up to 2000 characters.
* One or more rules. An insight joins the segment when any rule matches.

Each rule has a `rule_type`, an `operator` and a `value`:

| `rule_type`        | Matches                                                                                                     | Example value                        |
| ------------------ | ----------------------------------------------------------------------------------------------------------- | ------------------------------------ |
| `source_type`      | The feedback source: USER\_INTERVIEW, SURVEY, CS\_TICKET, SLACK, CSV or NOTION                              | `SURVEY`                             |
| `integration_type` | The integration: ZENDESK, INTERCOM, SLACK, GONG, POSTHOG, HUBSPOT, SALESFORCE or NOTION                     | `INTERCOM`                           |
| `slack_channel`    | One Slack channel, by name                                                                                  | `#vip-customers`                     |
| `crm_field`        | A CRM field. Also set `source_type` to the CRM record type (for example `hubspot_company`) and `field_name` | `Enterprise`                         |
| `segment`          | Membership of another segment                                                                               | A segment ID from `explore_segments` |

Operators are `equals`, `not_equals`, `contains`, `starts_with`, `ends_with` and `in`. Only `in` takes a list of values.

Show the plan as a table: segment, description, rules. Ask: "Create these segments?" Wait for a yes.

## 4. Preview each rule

Call `explore_segments` with `preview_rule` set to the rule fields. It saves nothing. For a segment that exists, also set `segment_id` inside `preview_rule`, so its current members are not counted.

* Read `preview.insight_ids` (up to 25), `sample_size` and `has_more`.
* Call `explore_insights` with `insight_id` for 2 or 3 sample insights. Check that they belong to the segment.
* When the sample is wrong or empty, change the rule and preview again. `INVALID_SEGMENT_RULE` gives Deck's reason.

## 5. Create the segments and rules

1. `create_segment` with `name` and optional `color` and `description`. Keep the segment ID from the result.
2. `create_segment_rule` with `segment_id`, `rule_type`, `operator` and `value`, plus `source_type` and `field_name` for a `crm_field` rule. When `retroactive_job.queued` is `true`, Deck tags the existing insights in the background.

Use manual assignment only for what rules cannot match:

* `set_feedback_source_segments` with `feedback_id` and up to 20 `segment_ids` replaces the manual segments of every insight from one source. An empty list clears them. Get the `feedback_id` from `list_sources`.
* `confirm_insight_segment` with `insight_id` and `segment_id` turns an AI assignment into a manual one. `explore_insights` with `insight_id` shows the AI assignments.

To change a segment or a rule later, use `update_segment` or `update_segment_rule`.

## 6. Check the result

* Call `explore_segments` with each new `segment_id`. Check its rules and which rules are active.
* Tagging runs in the background. Call `explore_segments` again later, and quote Deck's insight counts.
* Show the top themes of a segment with `explore_themes` and `segment_ids`. To compare two segments, fetch and follow [https://docs.getdeck.io/docs/agents/workflows/segment-comparison.md](https://docs.getdeck.io/docs/agents/workflows/segment-comparison.md).

See [Customer Segments](/docs/features/segments) for how segments work in the Deck web app.

## Rules

* Prefer rules to manual assignment. Rules also tag new feedback.
* Preview every rule before you save it.
* Quote Deck's numbers. Do not compute your own.
* Show the plan and get a yes before you call write tools.
* `archive_segment` and `delete_segment_rule` are sensitive writes. MCP cannot undo them. Get an explicit yes for each call, every time.
* Only organization admins can call `set_segments_enabled`.
* After each write, check for a top-level `error` key. When `idempotency.replayed` is `true`, Deck did not run the write again. See [Write responses and retries](/docs/integrations/mcp#write-responses-and-retries).
* If the user has more than one Deck organization, call `select_organization` first and pass `org_id` on every call.

## Done when

* Each approved segment exists with the approved rules, and the user saw a preview of each rule.
* `explore_segments` shows the rules as active.
* The user knows that Deck tags existing insights in the background, and how to check the counts later.

---

[View full sitemap](/docs/sitemap)
