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

# Recover abandoned carts

> Open the chat widget with a pre-filled message when a customer hesitates at checkout.

**APIs involved:** [Chat Widget JS API](/docs/api/chat-widget-js-api/)

Suppose a customer adds items to their cart, hesitates on the checkout page, and leaves without buying. You want to open the chat widget with a pre-filled message before they navigate away.

<Steps>
  <Step title="Set session variables when the cart is populated">
    ```js theme={null}
    LiveChatWidget.call("set_session_variables", {
      cart_value: "149.00",
      items_in_cart: "3",
      page: "checkout"
    });
    ```
  </Step>

  <Step title="Trigger the widget">
    After your own timing rule fires, call [`maximize`](/docs/api/chat-widget-js-api/methods#maximize) with an optional `messageDraft`:

    ```js theme={null}
    LiveChatWidget.call("maximize", { messageDraft: "Need help completing your order?" });
    ```

    `messageDraft` pre-fills the chat input field. If a pre-chat form is configured, the draft is sent automatically when the customer submits it.
  </Step>
</Steps>

When the customer sends their first message, the chat opens in Text. The agent sees `cart_value`, `items_in_cart`, and `page` in the customer details panel — enough context to help without asking the customer to repeat themselves.
