# What you can build with it

> Real examples of window.estageAI — chatbot, smart forms, summaries, translation, image understanding, document Q&A, and image generation.

Source: https://knowledge.estage.com/ai-assistant/examples/
Part of the ESTAGE knowledge base (https://knowledge.estage.com). Full corpus: https://knowledge.estage.com/llms-full.txt

---
When the [AI Assistant](/ai-assistant/) is on, your site gets a global helper —
**`window.estageAI`** — with methods for every kind of AI task. You usually don't write this
yourself: ask the builder for the feature (*"on form submit, classify the message"*) and it
wires the right call. The examples below show what's possible and the shape of each call.

:::note
Every method is **safe to call**: if the assistant is disabled it quietly returns nothing
instead of erroring, so your page never breaks.
:::

## Chatbot

The classic use — a support/sales chatbot. It streams the reply token-by-token so it types out
live:

```js
const reply = await window.estageAI.chat(messages, {
  onToken: (chunk) => appendToBubble(chunk),  // live typing
});
// messages = [{ role: 'user', content: 'What are your hours?' }, …]
```

This is what *"add an AI chatbot"* wires for you, using the greeting, starter prompts, name,
and accent color from your [Settings](/ai-assistant/).

## Smart forms

Make a plain form intelligent. Two favorites:

**Route a submission into a category** — tag a contact message so it reaches the right inbox:

```js
const category = await window.estageAI.classify(
  message,
  ['Sales', 'Support', 'Billing', 'Other']
);   // → "Support"
```

**Auto-generate a title** — e.g. name a support ticket or a user post from its body:

```js
const title = await window.estageAI.generate(
  `Write a short, clear title for this message:\n\n${message}`
);
```

**Pull structured fields out of free text** — e.g. parse a booking request:

```js
const data = await window.estageAI.extract(
  message,
  ['name', 'email', 'preferred_date', 'party_size']
);   // → { name: 'Sam', email: '…', preferred_date: 'Fri', party_size: '4' }
```

*Realistic scenario:* a "Contact us" form where, on submit, Genesis classifies the message,
generates a title, and shows the visitor a tailored confirmation — all before the email even
sends.

## Summarize & translate

```js
const short = await window.estageAI.summarize(longArticleText);

const spanish = await window.estageAI.translate(text, 'Spanish');
```

*Scenario:* a "TL;DR" button on a long blog post, or a one-click translate on a product
description.

## Image understanding (vision)

Give the AI an image and a question — great for upload forms:

```js
const description = await window.estageAI.vision(
  { base64, mediaType: file.type },   // or an image URL string
  'Describe this photo in one sentence for alt text.'
);
```

*Scenario:* a user uploads a profile photo and you auto-fill its alt text; or a "what's in this
picture?" feature on a gallery.

## Document Q&A (PDF)

Ask questions about an uploaded PDF or text file:

```js
const answer = await window.estageAI.readDocument(
  { base64, mediaType: 'application/pdf' },   // or a URL, or { text }
  'What is the total amount and the due date on this invoice?'
);
```

*Scenario:* a "drop your brief and ask anything" widget, or auto-summarizing an uploaded
contract.

## Image generation

Generate an image from a prompt (needs the **Image generation** toggle on in Settings — it
costs more):

```js
const url = await window.estageAI.image(
  `A friendly cartoon avatar, soft colors, for the name "${name}"`,
  { aspectRatio: '1:1' }
);   // → a hosted image URL you can drop into <img src>
```

*Scenario:* auto-generate an avatar on sign-up, or a cover image for a user-submitted post.

## Reading the config

The widget's settings are available client-side too, so custom UI can match:

```js
const cfg = window.estageAI.config;
// { greeting, suggestions: [...], ui: { name, accent, position }, enabled, imageEnabled }
```

## Method reference

| Method | Does |
| --- | --- |
| `chat(messages, { onToken })` | Streamed conversation reply |
| `ask(prompt)` / `generate(prompt)` | One-shot text answer |
| `classify(text, categories)` | Picks one of your categories |
| `extract(text, fields)` | Returns an object of the requested fields |
| `summarize(text)` | Condenses long text |
| `translate(text, targetLang)` | Translates text |
| `vision(image, prompt)` | Analyzes an image |
| `readDocument(file, prompt)` | Answers about a PDF / text file |
| `image(prompt, { aspectRatio })` | Generates an image (toggle-gated) |

Every call spends the **owner's** credits and is bounded by your monthly cap and per-visitor
rate limit — see [billing](/ai-assistant/#how-billing-works).
