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

# Abandonment Recovery: Recover Patients at Checkout

> Connect a telehealth platform to Emma so Emma automatically calls patients who drop off at payment and helps them complete their intake.

Emma's Abandonment Recovery workflow automatically contacts patients who drop off during a telehealth checkout. When your forms platform fires an abandonment event, Emma creates a recovery case, calls the patient, identifies what stopped them, and helps them finish — posting the outcome back to your system when the call ends.

<Info>
  Integration method: webhooks via a workflow orchestration relay, with outcomes returned by outbound webhook.
</Info>

## Prerequisites

* An Emma account with the No-Code Automation feature enabled
* Access to your telehealth platform's webhook settings
* An orchestration tool such as n8n (or another platform that can receive and forward webhooks)

## Setup

<Steps>
  <Step title="Enable automation in Emma" icon="toggle-on">
    **Where:** Emma → Integrations → No-Code Automation

    Open the No-Code Automation panel, generate an inbound secret, and optionally add your outbound webhook URL so Emma knows where to POST outcomes. Select **Save & Enable**, then copy your two inbound URLs — you'll need them when you configure the relay and your platform.

    | Setting | Value |
    | - | - |
    | Inbound secret | Generated once. Copy it now — you'll need it for the relay. |
    | Outbound webhook URL (optional) | `https://automation.yourclinic.com/webhook/emma-events` |
    | Inbound URL: abandoned | `https://api.emma.example/api/n8n/webhook/{clinicId}/forms-abandoned` |
    | Inbound URL: completed | `https://api.emma.example/api/n8n/webhook/{clinicId}/forms-completed` |

    <Note>
      `api.emma.example` is a placeholder. Your production base URL and `clinicId` are shown on the Emma Integrations page.
    </Note>
  </Step>

  <Step title="Import the relay template" icon="diagram-project">
    **Where:** your orchestration layer (for example, n8n)

    Most platforms can't add Emma's secret header to their outgoing webhooks, so a relay sits in between. Import Emma's ready-made relay template into your orchestration tool and configure three environment variables:

    ```bash Relay environment variables theme={null}
    EMMA_API_BASE_URL=https://api.emma.example
    EMMA_CLINIC_ID=<your clinic ID from step 1>
    EMMA_N8N_SECRET=<your inbound secret from step 1>
    ```

    Once configured, the relay handles the rest automatically: it receives the platform's POST, identifies the event type (abandoned or completed), normalizes the payload, adds the `x-n8n-secret` header, calls the correct Emma inbound URL, and returns `200 OK` to the platform.
  </Step>

  <Step title="Subscribe to form events" icon="bell">
    **Where:** your telehealth platform's webhook settings

    Subscribe to two events: `forms.abandoned` triggers a new recovery case, and `forms.completed` cancels any pending recovery case so Emma doesn't call a patient who already finished.

    <CodeGroup>
      ```json forms.abandoned theme={null}
      {
        "name": "Emma checkout recovery",
        "module": "forms",
        "event": "forms.abandoned",
        "url": "https://automation.yourclinic.com/webhook/vendor-event"
      }
      ```

      ```json forms.completed theme={null}
      {
        "name": "Emma checkout completed",
        "module": "forms",
        "event": "forms.completed",
        "url": "https://automation.yourclinic.com/webhook/vendor-event"
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="A patient abandons checkout" icon="phone">
    **Where:** automated — no action required

    When a patient drops off, the platform fires `forms.abandoned`, the relay forwards it to Emma, and Emma opens a recovery case. Emma waits briefly to confirm the patient hasn't returned on their own, then places the outbound call.

    | Time | Stage | What happens |
    | - | - | - |
    | T + 0 | Event received | Recovery case created with patient and cart context |
    | T + 0 | Notification | `recovery_case.created` sent to your outbound URL |
    | T + 15 min | Re-check | Skipped if the patient already finished |
    | — | Call | Emma calls the patient: consent, barrier identification, guided resolution |
    | — | End | Outcome recorded and posted back |

    The full request Emma receives from the relay, and the response it returns, look like this:

    <CodeGroup>
      ```http Request to Emma theme={null}
      POST /api/n8n/webhook/{clinicId}/forms-abandoned
      x-n8n-secret: ••••••••
      Content-Type: application/json

      {
        "event": "forms.abandoned",
        "tenant_id": "tenant_7c21...",
        "sent_at": "2026-09-24T14:05:00Z",
        "data": {
          "session_id": "sess_8f2c...",
          "form_id": "form_weightcare_01",
          "form_name": "Weight care intake",
          "last_page_reached": 6,
          "total_pages": 7,
          "completion_percentage": 85,
          "last_activity_at": "2026-09-24T13:40:00Z",
          "draft_age_hours": 1,
          "abandoned_at": "2026-09-24T14:05:00Z",
          "abandoned_at_checkout": true,
          "resume_url": "https://your-platform.example/resume/sess_8f2c...",
          "partial_form_data": {
            "phi_first_name": "Jordan",
            "phi_last_name": "Lee",
            "phi_phone": "+15551234567",
            "selectedProducts": [
              { "productName": "Starter plan", "unitPrice": 199 }
            ]
          }
        }
      }
      ```

      ```json Response · 200 OK theme={null}
      {
        "received": true,
        "recoveryCaseId": "rc_41d0...",
        "sessionId": "sess_8f2c...",
        "patientFirstName": "Jordan",
        "patientLastName": "Lee"
      }
      ```
    </CodeGroup>
  </Step>

  <Step title="The outcome is posted back" icon="rotate-left">
    **Where:** your outbound webhook URL (configured in step 1)

    When the call ends, Emma POSTs the outcome to your outbound webhook URL. Use it to tag the lead in your CRM, notify your team, or update the platform's record for the session.

    ```json POST → your outbound URL theme={null}
    {
      "event": "recovery_case.outcome",
      "clinicId": "clinic_abc123",
      "sentAt": "2026-09-24T14:27:41Z",
      "data": {
        "recoveryCaseId": "rc_41d0...",
        "sessionId": "sess_8f2c...",
        "recoveryStatus": "RECOVERED"
      }
    }
    ```

    The `recoveryStatus` field tells you exactly where things landed:

    | `recoveryStatus` | Meaning |
    | - | - |
    | `RECOVERED` | Patient agreed to finish; resume link sent |
    | `FOLLOW_UP_REQUIRED` | Wants a callback or more time |
    | `PRICING_ESCALATION` | Needs someone from billing |
    | `CLINICAL_ESCALATION` | Needs someone from the care team |
    | `PATIENT_NOT_INTERESTED` | Declined to continue |
    | `PATIENT_NOT_REACHED` | Could not be reached |
    | `ALREADY_COMPLETED` | Finished before Emma called |
  </Step>
</Steps>

<Note>
  All names, phone numbers, and IDs on this page are sample data.
</Note>
