# Integrate with an AI assistant (/docs/ai-assistants)

Our docs are written to be read by AI assistants. Paste this prompt into yours, fill in the brackets, and it can write the whole integration:

```text
Integrate CallHuman into this project.
Docs for AI assistants: https://www.callhuman.es/llms-full.txt
OpenAPI: https://www.callhuman.es/openapi.json

Goal: when <describe the event>, call the person at <phone field>, read <message>,
offer these options: <options, each with an optional reply>, and handle the answer
in a webhook endpoint that verifies the CallHuman-Signature header.
Use the API key from the CALLHUMAN_API_KEY environment variable and the webhook
secret from CALLHUMAN_WEBHOOK_SECRET.
```

## Machine-readable resources [#machine-readable-resources]

| Resource | What it contains |
|---|---|
| [`/llms.txt`](/llms.txt) | Index of every docs page with a one-line description and a link to its Markdown. |
| [`/llms-full.txt`](/llms-full.txt) | All the docs in a single Markdown file. Best for pasting into a chat. |
| `/docs/<page>.md` | Any docs page as Markdown, e.g. [`/docs/webhooks.md`](/docs/webhooks.md). |
| [`/openapi.json`](/openapi.json) | OpenAPI 3.1 spec with descriptions and examples for every field and error. |

Docs pages also answer `Accept: text/markdown` with Markdown, and every page has **Copy Markdown** and **Open in ChatGPT / Claude** buttons.

## What a correct integration looks like [#what-a-correct-integration-looks-like]

Ask your assistant to check its code against this list:

1. `POST https://api.callhuman.es/v1/calls` with `Authorization: Bearer <key>` and a JSON body.
2. `to` in international format (`+34600111222`), `message`, and `options` as objects: `{ "label": "...", "reply": "..." }` — not plain strings.
3. A `webhook_url` endpoint that reads the **raw body**, verifies `CallHuman-Signature` (hex HMAC-SHA256 with the webhook secret) and returns `2xx` quickly.
4. Decide using `status` and `option_label` (or `option_path` for submenus), and find your record with `metadata`.
5. Handle `not_answered`: decide what happens when nobody picks up.
6. Send an `Idempotency-Key` header if the request may be retried.

## Copy-paste starter (Node.js) [#copy-paste-starter-nodejs]

```js
// 1) Create the call
const res = await fetch("https://api.callhuman.es/v1/calls", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.CALLHUMAN_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": `booking-${booking.id}-confirmation`,
  },
  body: JSON.stringify({
    to: booking.phone,
    language: "en",
    message: `Hi! This is La Plaza about your table for ${booking.people} tonight at ${booking.time}.`,
    options: [
      { label: "Confirm", reply: "Perfect, see you tonight!" },
      { label: "Cancel", reply: "No problem, your booking is cancelled." },
    ],
    webhook_url: "https://laplaza.example/hooks/callhuman",
    metadata: { booking_id: booking.id },
  }),
});
if (!res.ok) throw new Error((await res.json()).error.message);
```

Then receive the answer as shown in [Webhooks](/docs/webhooks#verify-the-signature).