# For developers and coding agents

> What a website needs for Aura's chat: the snippet, security headers, signed-in users, goal events, page actions, heatmaps, and a setup guide per bot.

## Get your bot's own guide

Open the bot in Aura, go to the **Go live** step, and find **Hand it to your developer**. **Copy the guide** or **Download** it as a Markdown file. It's this page, filled in for that bot:

- its snippet and public id, and the sites it may run on;
- the security headers its features need (heatmaps, the icon, the microphone);
- the exact code for each of its goals;
- the pages Aura reads from the site, and any it couldn't read.

**Read your site** first, and Aura reads the home page of one of the bot's allowed sites. The guide then says what that site actually needs:

- the instructions for the platform it seems to run on (WordPress, Shopify, Webflow, Wix, Squarespace, Framer, Next.js, Nuxt, Gatsby or a single-page app);
- whether the snippet is already there;
- exactly which sources its Content-Security-Policy is missing, if any;
- whether its X-Frame-Options or Permissions-Policy headers block heatmaps or the microphone.

Aura reads only the bot's own sites, and only their home page.

Give the file to your developer, or put it in your repository and ask a coding agent (Claude Code, Cursor, GitHub Copilot) to follow it. It tells an agent what to change, to leave changes outside the repository (such as a CDN's headers) to a person, and how to check the result.

## What to change

| Step | Needed when | What |
|---|---|---|
| [The snippet](#the-snippet) | Always | One script tag on every page |
| [Allowed sites](#allowed-sites) | Always | Set in Aura, not in code |
| [Security headers](#security-headers) | The site sends a Content-Security-Policy | Add Aura's addresses |
| [Signed-in users](#signed-in-users) | The site has accounts | Attributes or `setVisitor` |
| [Goal events](#goal-events) | The bot has event goals | `window.Aura.track("name")` |
| [Page actions](#page-actions) | The bot should do things on the page, such as setting filters | `window.Aura.action(...)` |
| [Private pages](#private-pages) | Pages show other people's details | `data-aura-private` on `<html>` |
| [Heatmaps](#heatmaps) | The bot measures pages | Let Aura frame the site |
| [Reading the site](#reading-the-site) | The bot answers from the site's pages | Let Aura's reader in |

## The snippet

```html
<script async src="https://aura.oneinfer.ai/widget.js" data-bot-id="bot_…"></script>
```

Put it once in the layout or template every page shares, just before `</body>`. Keep `async`, keep `data-bot-id` on the tag, and don't bundle or copy `widget.js`: Aura updates it.

- **Single-page apps** (React, Vue, Angular, Svelte): `index.html`. The chat follows route changes on its own.
- **Next.js**: `<Script src="https://aura.oneinfer.ai/widget.js" data-bot-id="bot_…" strategy="afterInteractive" />` from `next/script`, in `app/layout.tsx` or `pages/_app.tsx`.
- **WordPress**: the theme's footer, or a plugin that adds code to every page's footer.
- **Shopify**: `layout/theme.liquid`, before `</body>`.
- **Webflow**: Site settings, Custom code, Footer code.

## Allowed sites

The chat loads only on the sites listed in the bot's **Go live** step under **Allowed origins**: scheme and host, such as `https://www.example.com`. Another domain, `www` or not, or a staging address each need adding there. See [Add the chat to your website](https://aura.oneinfer.ai/docs/install#allow-your-sites).

## Security headers

If the site sends a `Content-Security-Policy`, add these to the directives it already has:

| Directive | Add | Why |
|---|---|---|
| `script-src` | `https://aura.oneinfer.ai` | Loads the chat |
| `connect-src` | `https://aura.oneinfer.ai https://api.oneinfer.ai wss://api.oneinfer.ai` | The chat's settings, answers and live connection |
| `style-src` | `'unsafe-inline'` | The chat's styles are a `<style>` element inside its own shadow root. A site that allows styles by nonce can give the snippet its nonce (`<script nonce="…" …>`) instead: the chat gives it to its styles. |
| `img-src` | `https://api.oneinfer.ai` | The bot's icon, if it has one |
| `frame-ancestors` | `https://aura.oneinfer.ai` | [Heatmaps](#heatmaps) shown inside Aura |

A bot with a microphone also needs the page to allow it, if the site sends a `Permissions-Policy`: `microphone=(self)`.

## Signed-in users

Name signed-in users, so the bot can answer them in context and the team knows who they are:

```html
<script async src="https://aura.oneinfer.ai/widget.js" data-bot-id="bot_…"
  data-visitor-id="USER_ID" data-visitor-name="USER_NAME" data-visitor-email="USER_EMAIL"
  data-visitor-plan="USER_PLAN"></script>
```

Or, in a single-page app, after sign-in and after sign-out:

```js
window.Aura?.setVisitor({ id: user.id, name: user.name, email: user.email, details: { plan: user.plan } });
window.Aura?.setVisitor(null);
```

Any other `data-visitor-*` attribute, or key in `details`, is a detail the bot and team see, such as a plan, company or credits left. See [Tell the bot who is signed in](https://aura.oneinfer.ai/docs/install#tell-the-bot-who-is-signed-in) for what each is used for and the limits.

## Goal events

An event goal counts when the site sends its name. Send it once, right after the action succeeds:

```js
window.Aura?.track("demo_booked");
window.Aura?.track("purchase", { value: 49 });
```

The names are the bot's goals' own, set in Aura under **Analytics**; the bot's guide lists them with their code. Page goals need no code. See [Goals and events](https://aura.oneinfer.ai/docs/insights/goals).

## Page actions

The bot can do things for the visitor on the page they're on: set a search's filters, open a form, go to a page. Register each one with a JavaScript function. The bot uses it when the visitor asks for what it does, in a typed chat or on a call, and the function runs in the visitor's browser, as them. Aura holds no keys to your site.

Sites usually register actions when their own code starts, which can be before Aura's script has loaded. Put this line above the snippet, and those calls wait for it:

```html
<script>window.Aura=window.Aura||{q:[]};['track','setVisitor','action','removeAction'].forEach(function(n){window.Aura[n]=window.Aura[n]||function(){window.Aura.q.push([n,[].slice.call(arguments)])}});</script>
```

Then register each action. `window.Aura?.` keeps the call harmless on a page without that line, if Aura's script never loads. For a search page with filters:

```js
window.Aura?.action("search_leads", {
  label: "Search leads",
  description: "Sets the filters on the lead search page and shows the results. Use it when the visitor describes the people or companies they want.",
  parameters: {
    type: "object",
    properties: {
      job_titles: { type: "array", items: { type: "string" }, description: "Such as VP Sales or Head of RevOps" },
      industries: { type: "array", items: { type: "string", enum: ["Fintech", "Healthcare", "SaaS"] } },
      company_size: { type: "string", enum: ["1-10", "11-50", "51-200", "201-500", "500+"] },
      locations: { type: "array", items: { type: "string" }, description: "Cities or countries" },
    },
  },
  run: async (filters) => {
    const results = await applyFilters(filters); // your page's own code
    return { shown: results.total, first: results.items.slice(0, 5).map((lead) => lead.company) };
  },
});
```

- **description** tells the bot what the action does and when to use it.
- **parameters** is JSON Schema. Name each filter, and list the allowed values with `enum` where there's a fixed set, so the bot picks one of yours. With dozens of filters, list the main ones and take the rest as text your code matches.
- **run** gets the arguments as an object and may be async. Return a short summary of what happened: the bot reads it to tell the visitor. Throw an error, with a message, when it can't.
- **confirm: true** makes the visitor allow it first, on a card in the chat. Use it for anything that changes something: an order, a booking, a message sent.
- **label** is the name the visitor sees on that card.

With the bot's **Let the bot move around your site** setting on (on **Knowledge**, under **Answers**), the widget adds three actions of its own:

- `open_page`: opens one of this site's pages, from `{ url: "/pricing" }`;
- `go_back`;
- `reload_page`.

They change the page once the bot has answered. The chat opens again on the next page, and a call carries on. Register your own action with one of those names, and it replaces Aura's. On a single-page site, an `open_page` that uses your router keeps the page loaded, so nothing needs to carry on:

```js
window.Aura?.action("open_page", {
  label: "Open a page",
  description: "Opens a page of this website. Give its path, such as /pricing.",
  parameters: { type: "object", properties: { url: { type: "string" } }, required: ["url"] },
  run: ({ url }) => {
    const page = new URL(url, location.href);
    if (page.origin !== location.origin) throw new Error("Only this website's pages open here.");
    router.push(page.pathname + page.search + page.hash); // your app's own router
    return "Opened " + page.pathname;
  },
});
```

Register an action on the pages where it works; registering it again replaces it. `window.Aura?.removeAction("search_leads")` takes it away, for example when a single-page app leaves the search page.

Each bot's setup guide (its **Go live** step, **Hand it to your developer**) has a table for the actions agreed with the site's owner. Fill it in before handing the guide over: a developer or coding agent builds one action per row, and skips the part while it says "None yet".

| Limit | |
|---|---|
| Actions on a page | 20 |
| An action's description and parameters | 8,000 characters as JSON |
| Time for the function | 15 seconds |
| Time for the visitor to allow a `confirm` one | 80 seconds |
| What it returns | 6,000 characters (cut, beyond that) |

The bot uses up to 3 rounds of actions for one answer. Its model must take tools, as most do; one that doesn't answers without them.

The function runs as the visitor, so it can do nothing they couldn't do on the page. Check its arguments as you would a form's, and return only what the visitor may see. Team chat shows which actions the bot used, but not their arguments or results.

### When something is missing

Nothing breaks:

- **An action isn't built yet.** The bot is only offered the actions the visitor's page has registered, so it answers without the missing one.
- **Aura's script didn't load** (blocked, or the bot is paused). The line above the snippet keeps `window.Aura` there, so the calls wait and do nothing.
- **The function throws, or takes longer than 15 seconds.** The bot is told it didn't work and tells the visitor. The error doesn't reach the page's console.
- **The visitor left the page meanwhile, or the page removed the action.** The bot is told the page has no such action now.
- **An action breaks a rule** (a name with spaces, no description, over the limits). It isn't registered, and the console shows a warning that starts with "Aura:".
- **"Go back" in a tab that has nowhere to go back to.** The bot is told so, and the page stays.

To check it, ask the bot for something an action does, such as "show me fintech companies in London". The page changes, and the bot says what it found.

## Private pages

On pages that show other people's details, such as an account area or an admin screen, add `data-aura-private` to `<html>`. The chat then sends no page titles or click text, only where clicks land. See [Pages with private data](https://aura.oneinfer.ai/docs/install#pages-with-private-data).

## Heatmaps

Aura shows heatmaps over the site's own pages in a frame. For that, the site must not send `X-Frame-Options: DENY` or `SAMEORIGIN`, and must allow `frame-ancestors https://aura.oneinfer.ai`. Without them, **Open on your site** still shows heatmaps on the site itself. See [Page reports and heatmaps](https://aura.oneinfer.ai/docs/insights/pages-and-heatmaps).

## Reading the site

A bot answers from the site's pages that it's given, and Aura reads them again every week. If the site has bot protection (Cloudflare, a firewall, a "verify you're human" page), let in Aura's reader, which identifies itself as `OneInferAura/1.0 (knowledge reader; +https://aura.oneinfer.ai)`. It reads public pages only.

## Check it works

1. Open the site in a private window. The chat button appears in the corner, except on hidden pages.
2. Ask it something the site answers.
3. In Aura, **Live** lists the visit, and signed in, by name.
4. Do each goal's action: **Insights** counts it under **Goals**.
5. Ask the bot for something each page action does: the page changes.
6. The browser's console shows no errors mentioning `aura.oneinfer.ai` or `api.oneinfer.ai`.

If the button doesn't appear, see [Check it works](https://aura.oneinfer.ai/docs/install#check-it-works).
