> For the complete documentation index, see [llms.txt](https://docs.saleschat.pro/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.saleschat.pro/principles/lead-lifecycle.md).

# Lead Lifecycle

How Saleschat decides which of a customer's leads holds the WhatsApp conversation, and how to plan orgs, WABAs and phone numbers around it.

An enterprise often has several leads for one customer: from different processes, campaigns, locations, or CRMs, or because a dialler created a new lead when the customer came back. WhatsApp allows only one conversation with that customer per business number. The lead lifecycle decides which lead holds that conversation.

Use lifecycle rules to control which lead is active. To decide how many orgs, WABAs, and phone numbers you need, see [Planning Orgs, WABAs & Phone Numbers](https://docs.saleschat.pro/principles/planning-orgs-wabas-and-phone-numbers.md).

{% hint style="info" %}
**Smaller businesses and support teams can skip most of this page.** If you talk to each customer by their phone number, you'll rarely have more than one lead per number. A support team works this way: it identifies the customer by phone number and asks what they need help with, even if they've bought several products or made several transactions. Support has no separate leads to choose between, so the default setup works and you don't need lifecycle rules.
{% endhint %}

## Why only one lead can be active

WhatsApp allows one conversation between one business phone number and one customer phone number. You can't open a second, parallel chat with the same customer from the same number.

Your CRM and dialler don't have that limit. A dialler can hold several leads for the same phone number, assign them to different human agents, and call them in parallel. On WhatsApp, only one of those human agents can be chatting with the customer at a time.

Saleschat handles this at the **lead** level:

* Each lead can have its own chatroom, but only one lead per customer phone number is **active** on each WABA phone number. Only the active lead can send and receive messages.
* When another lead with the same phone number becomes active, the previously active lead becomes **inactive**.
* Attributes and events belong to the lead, the same way the customer's activity on your website and in your CRM belongs to the lead. AI workflows run per lead, not per phone number. A workflow uses only its own lead's attributes, never those of another lead on the same number.

## Lead states

| State        | What it means                                                                                    | Messaging                                                                                                                                                                                      |
| ------------ | ------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Active**   | The lead holds the conversation for its phone number.                                            | Human agents, journeys, and AI workflows can send messages.                                                                                                                                    |
| **Inactive** | Another lead took the conversation, or someone deactivated this lead. It can be activated again. | Campaigns can still send messages to it. See [Campaigns and inactive leads](#campaigns-and-inactive-leads). Customer replies go to the active lead. Any AI workflow running on the lead stops. |
| **Expired**  | The lead is closed for good. Its data and chat history are kept for your org's retention period. | Nothing can be sent, including campaigns. It can't be activated again.                                                                                                                         |

A new lead has no state until its first chatroom is created, for example when a human agent opens a chat or a campaign message is sent to it. Because WhatsApp is the only channel today, a lead's state is the state of its WhatsApp chatroom. That's why the related [webhooks](#webhooks) are named `CHATROOM_*`.

## When the customer sends a message

When an inbound message arrives from a customer phone number, Saleschat routes it like this:

1. If one of the customer's leads is active, the message goes to that lead.
2. If none is active, the message goes to the most recently created inactive lead, and that lead becomes active.
3. If all the customer's leads have expired, the message goes to the most recently expired lead. Saleschat can reply automatically with a message you choose, such as where the customer can get help now. There's no setting for this message in the app yet; ask the Saleschat team to set it up.
4. If the customer has no leads, Saleschat creates a new lead with their phone number as its CRM ID.

Step 4 needs **Allow Inbound Chats** turned on in **Settings** > **Chats**. When it's off, the message isn't delivered.

## Lifecycle rules

Lifecycle rules decide which lead becomes active when something happens to a lead. You set them in **Settings** > **Lead Lifecycle**.

{% hint style="info" %}
Lifecycle rules are on by default for new orgs. Existing orgs need to opt in: ask the Saleschat team to turn them on.
{% endhint %}

Each rule has:

* **Events**: what triggers the rule. Choose **Lead Created** or **Lead assigned or re-assigned**.
* **Apply attribute filter** (optional): which leads the rule applies to, using the [Attribute Matcher](https://docs.saleschat.pro/principles/attribute-matcher.md). For example, only leads where `process` is `issuance`. Without a filter, the rule applies to every lead.
* **Action**:
  * **Activate**: the lead becomes active, and all other leads with the same phone number become inactive.
  * **Deactivate**: the lead becomes inactive. You can activate it later.
  * **Expire**: the lead can't be activated again.
* For **Activate** rules only:
  * **Engagement Check**: when on, the lead becomes active only if the current active lead hasn't had an inbound message (a message from the customer) in the last **Days Since Last Message** days. Outbound messages, whether sent by human agents, journeys, or AI workflows, don't count. If that lead has never had an inbound message, the days count from when it was created. When off, the lead becomes active straight away.
  * **Maximum Lead Age**: the rule only activates leads created in Saleschat within this many days. Use it to avoid mishaps, such as a CRM re-sync that re-assigns a considerably old lead taking over a live conversation.

### How rules are applied

* Rules run only when one of their events happens. Saleschat checks rules from top to bottom and runs the first one that matches the event and the lead. Later rules are skipped. Drag rules to change their order.
* If no rule matches, nothing changes.
* With no rules at all, the first lead created for a phone number stays active.
* New orgs start with one rule, **Latest lead takes the conversation**: every new lead becomes active. It has no attribute filter, so it matches every lead. New rules are added below it, so a rule you add on **Lead Created** never runs until you edit, move, or delete this one.
* When a human agent opens a chat from your CRM, the lead is created if it doesn't exist yet, and then assigned. Rules on **Lead Created** (only when the lead is new) and **Lead assigned or re-assigned** decide whether it becomes active. If no rule activates it and another lead holds the number, the chat doesn't open. Activate the lead by hand, or add an **Activate** rule on **Lead assigned or re-assigned** so that assigning a lead gives it the conversation.

A rule only looks at the lead the event happened to. It can't check the attributes of the lead that's currently active. To protect an ongoing conversation, use **Engagement Check** on the rules that could take it over.

A lead that a rule doesn't activate stays inactive. It doesn't switch on by itself when the quiet period ends. It becomes active only when a later event matches a rule, when the customer messages and no lead is active, or when someone activates it.

### Activate or deactivate a lead by hand

For exceptions, you can change a lead's state yourself:

* On the **Leads** page, open the actions menu on a lead, then confirm:
  * **Activate lead**: the lead becomes active, and every other active lead on the same phone number becomes inactive. Refresh the page to see the new statuses.
  * **Deactivate lead**: the lead and every other lead on the same phone number become inactive, so none of them stays active until a rule, a customer message, or someone activates one. If you don't see this option, ask the Saleschat team to turn it on.
* From your own systems, use the activate, deactivate, and expire endpoints in the [Leads API](https://docs.saleschat.pro/api-documentation/leads.md#lead-lifecycle).

{% hint style="warning" %}
**Deprecated settings.** Lifecycle rules replace these older org settings:

* **On lead creation activate the latest lead**
* The deactivation threshold: deactivate a chatroom after a number of days without messages
* The expiry threshold: expire a lead a number of days after it was created

Recreate these behaviours as lifecycle rules.
{% endhint %}

## Scenarios

### Insurance: issuance takes priority over sales

This scenario is for sales and issuance sharing one WhatsApp number. To give each its own number, see [Planning Orgs, WABAs & Phone Numbers](https://docs.saleschat.pro/principles/planning-orgs-wabas-and-phone-numbers.md).

A customer buys a policy. The sales lead has been talking to them on WhatsApp. Your CRM now creates an issuance lead for the same phone number, and the issuance team should take over. A new sales lead for the same customer must not take the conversation away from issuance.

Send the process as a lead attribute, for example `process`. Delete the default rule, or edit it so it doesn't match sales leads, and create one rule:

| # | Rule                | Events                                     | Attribute filter        | Action                         |
| - | ------------------- | ------------------------------------------ | ----------------------- | ------------------------------ |
| 1 | Issuance takes over | Lead Created, Lead assigned or re-assigned | `process` is `issuance` | Activate, Engagement Check off |

* A new issuance lead always becomes active, and every other lead on the number becomes inactive.
* No rule matches a sales lead, so it never takes the conversation from another lead. If a human agent opens a chat for it from your CRM while another lead holds the number, the chat doesn't open.
* A sales lead still gets the conversation when the number is free: when no lead is active yet, or after the issuance lead is deactivated or expired.

The trade-offs:

* A newer sales lead doesn't take over from an older sales lead either. [Activate it by hand](#activate-or-deactivate-a-lead-by-hand) when it should.
* Deactivate or expire the issuance lead when issuance is done. Otherwise sales leads stay blocked on that number. To do this automatically, send an event such as `policy_issued` to the lead from your CRM, and create an automation on that event that expires the lead.
* If sales leads should take over when the customer has gone quiet, add a second rule for them with **Engagement Check** on. That rule can't tell an issuance lead from a sales lead, so it can also take the conversation from issuance after the quiet period.

### A dialler creates a new lead when the customer returns

Many B2C companies create a new lead when a customer comes back to the website after a gap, say 30 minutes, so the dialler treats it as fresh and puts it back in the calling queue. The dialler may assign these leads to different human agents and call them in parallel. On WhatsApp, only one of them can hold the conversation.

Choose the behaviour that fits how your teams work:

| Approach                      | How                                                                                                     | What happens                                                                                                                        |
| ----------------------------- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Latest lead wins              | Activate on **Lead Created**, Engagement Check off (the default rule).                                  | The newest lead and its human agent take the conversation. The previous human agent's lead becomes inactive, even mid-conversation. |
| Protect the live conversation | Activate on **Lead Created**, Engagement Check on. Add **Maximum Lead Age** if old leads get re-synced. | If the customer has messaged within the set days, the new lead stays inactive and its human agent can call but not chat.            |
| Mix by process                | Order rules so priority processes always take over, and the rest use Engagement Check.                  | High-priority leads take the conversation. Repeat and low-priority leads stay inactive while the customer is engaged.               |

#### Alternative: one Saleschat lead per customer

Some enterprises don't need separate leads on WhatsApp and prefer a simpler setup, where all of a customer's CRM leads map to one Saleschat lead. Give them the same `crm_id`, such as a master customer ID or a hash of the phone number, and send website visits and other activity as events on that lead. With only one lead, nothing switches, and you don't need lifecycle rules.

This suits you when:

* One team or one process handles WhatsApp, even if your dialler creates several leads per customer.
* Your dialler re-creates leads for returning visitors, and you want the customer to stay in one ongoing chat.
* You'd rather not set up and maintain lifecycle rules.

What you give up:

* Attributes from different processes overwrite each other, because the latest value wins. AI workflows see that combined set.
* The lead has one human agent at a time, whichever agent the dialler assigned.
* Lifecycle rules can't prioritise one process over another.
* Reports count one lead across all processes and campaigns.
* Expiring the lead ends WhatsApp conversations for every process.
* Your CRM has to store the shared ID, map its own leads to it, and be able to search by it.

### Campaigns and inactive leads

A process can run several campaigns for the same customer. A campaign's audience is listed either by CRM ID or by phone number, never a mix of both, and each picks a lead differently:

* **By CRM ID**: the campaign sends to the newest lead with that CRM ID that hasn't expired, even if it's inactive. The lead stays inactive. If there's no such lead, that recipient fails with CRM ID not found.
* **By phone number**: the campaign picks the first lead that fits, in this order:

  1. The active lead on the number.
  2. The newest lead that doesn't have a chatroom yet.
  3. The newest inactive lead. The lead stays inactive.

  If every lead on the number has expired, or there are none, the campaign creates a new lead with the phone number as its CRM ID.

A journey (a campaign, an automation, or an inbound rule) can start an AI workflow on a lead. The workflow needs the lead's subscription, and only one workflow can hold it at a time. While a workflow holds the subscription, nothing else can message the lead: campaigns and automations skip it, no new workflow can start, and human agents can't send messages.

To hand the conversation to a person, a user with the Admin role or above stops the AI: open the AI agent, go to **Analytics** > **Sessions**, and select **Stop session** on the active AI session. Human agents with the Manager or Member role can't stop an AI workflow.

The customer's reply goes to the active lead. To move the conversation to the campaign's lead, [activate it by hand](#activate-or-deactivate-a-lead-by-hand).

### Several locations or CRMs

Call centres in different locations may use the same CRM or different ones, and each process may have its own CRM.

* Each CRM, including each separate instance of the same CRM, needs its own Saleschat org. See [Planning Orgs, WABAs & Phone Numbers](https://docs.saleschat.pro/principles/planning-orgs-wabas-and-phone-numbers.md).
* Locations that work in the same CRM share an org. A `crm_id` must be unique across the org, and the same customer can have leads from several locations on the same phone number. Lifecycle rules decide which one is active.

### Affiliate chatrooms

Affiliate chatrooms are group chats with back office staff or partners. An affiliate chatroom and a lead on the same customer phone number conflict, because both need the one WhatsApp conversation with that number. Keep affiliate phone numbers separate from lead phone numbers. Ideally, run affiliate chatrooms on a separate WABA, so they never compete with leads for a number. See [Planning Orgs, WABAs & Phone Numbers](https://docs.saleschat.pro/principles/planning-orgs-wabas-and-phone-numbers.md#how-to-decide).

## Plan your orgs, WABAs, and phone numbers

The one-active-lead limit applies per WABA phone number, so more numbers allow more parallel conversations with the same customer. To decide how many orgs, WABAs, and phone numbers you need, see [Planning Orgs, WABAs & Phone Numbers](https://docs.saleschat.pro/principles/planning-orgs-wabas-and-phone-numbers.md).

## Webhooks

Saleschat sends `CHATROOM_ACTIVATED`, `CHATROOM_DEACTIVATED`, and `CHATROOM_EXPIRED` webhooks when a lead changes state, so your CRM can keep its own records in step. See [Webhooks](https://docs.saleschat.pro/getting-started/webhooks.md).
