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

# Overview

> Automatic follow-up configuration with AI and official templates

## What is Follow-up?

Follow-up is an automatic re-engagement system that sends messages to leads after a period of inactivity. Each assistant can have its own follow-up configuration.

<CardGroup cols={2}>
  <Card title="AI Follow-up" icon="brain">
    AI generates the message automatically based on conversation context and configured prompt.
  </Card>

  <Card title="Template Follow-up" icon="file-lines">
    For intervals above 24h, uses official WhatsApp Business templates (Meta/Gupshup).
  </Card>
</CardGroup>

## How It Works

<Steps>
  <Step title="Status Trigger">
    Follow-up is activated when a lead changes to one of the statuses configured in `trigger_status_ids`.
  </Step>

  <Step title="Wait Interval">
    The system waits for the defined interval (e.g., 30 minutes, 2 hours, 1 day).
  </Step>

  <Step title="Send Message">
    Depending on interval: generates with AI (\< 24h) or sends official template (>= 24h).
  </Step>

  <Step title="Advance Steps">
    If the lead doesn't respond, advances to the next step until all are completed (max 3 steps).
  </Step>
</Steps>

## Follow-up Config Model

```json theme={null}
{
  "id": "uuid",
  "tenant_id": "uuid",
  "assistant_id": "uuid",
  "trigger_status_ids": ["uuid-status-1", "uuid-status-2"],
  "steps": [
    {
      "interval": "PT30M",
      "prompt": "Send a friendly message asking if the lead needs help"
    },
    {
      "interval": "PT2H",
      "prompt": "Reinforce the product value and offer a demo"
    }
  ],
  "official_steps": [
    {
      "channel_id": "uuid",
      "channel_name": "WhatsApp Business",
      "app_id": "gupshup_app_12345",
      "steps": [
        {
          "interval": "P1D",
          "template_name": "reengagement_v1",
          "template_language": "en",
          "template_params": ["{{LEAD_FIRSTNAME}}", "Leavo"]
        }
      ]
    }
  ],
  "is_active": true,
  "created_at": "2024-01-15T10:00:00Z"
}
```

## Interval Format (ISO 8601)

| Interval       | Format    | Description                |
| -------------- | --------- | -------------------------- |
| 30 minutes     | `PT30M`   | Minimum allowed            |
| 2 hours        | `PT2H`    |                            |
| 1 day 12 hours | `P1DT12H` |                            |
| 1 day          | `P1D`     | Requires official template |
| 1 week         | `P1W`     | Requires official template |

<Warning>
  Steps with interval >= 24 hours **must** have `template_name` configured, since WhatsApp's conversation window requires approved templates.
</Warning>

## Rules

* Maximum **3 steps** per configuration
* Minimum interval of **30 minutes** per step
* One configuration per assistant (unique)
* Each official channel can have its own steps with templates
