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

# Customer support

> Visitors start conversations from your app; you answer from your Result inbox.

```ts theme={"dark"}
import { createClient } from "@resultdev/sdk";

export const backend = createClient({
  baseUrl: process.env.NEXT_PUBLIC_BACKEND_URL!,
  anonKey: process.env.NEXT_PUBLIC_BACKEND_ANON_KEY!,
  support: { handle: "acme" }, // your business @handle on Result, without the @
});
```

Conversations land in your Result support inbox. Both sides get email
notifications, and visitors can reply by email.

## Start a conversation

```ts theme={"dark"}
const { data, error } = await backend.support.startThread({
  email: "visitor@example.com",
  message: "My order never arrived",
  name: "Ada", // optional
});
// data = { id, accessKey }
```

The SDK stores the access key in localStorage, so later calls need only the
thread id. There are no visitor accounts - the per-thread access key is the
whole credential. Keep it if you persist threads yourself.

## Read and reply

```ts theme={"dark"}
const { data: thread } = await backend.support.getThread(id);
// { id, status: "open" | "closed", visitorEmail, visitorName?,
//   createdAt, lastMessageAt, owner: { name, username },
//   messages: [{ id, body, authorType: "visitor" | "owner", createdAt }] }

await backend.support.sendMessage(id, "Any update on this?");
```

Any reply reopens a closed thread. Both methods take an `accessKey` as the
last argument if you stored it yourself.

This is async support, not live chat - poll `getThread` every 15 to 30
seconds while a support view is open.

## This browser's history

```ts theme={"dark"}
const { data: threads } = await backend.support.listThreads(); // [{ id }]
const { data: contact } = await backend.support.getContact();  // last email/name used
```

## Errors and limits

Every method returns `{ data, error }`; `error` is a `ResultError` with
`message`, `statusCode` and an `error` code. Surface `error.message` to
users.

* 5 new conversations per IP per hour
* 30 messages per IP per 10 minutes
