# How the AI works

> **In short.** Every new ticket goes to an AI model (Google Gemini Flash, through OpenRouter)
> with your product's knowledge and personal details removed. It sorts the ticket, checks for
> duplicates, writes a reply and says whether a person is needed. The reply goes to the user only
> if it passes rules in code **and** a second model's checklist; otherwise it's held for you and
> the user is told a person will reply. Money, accounts, bans, safety and reports about other users
> always go to a person.

## Step by step

1. **A ticket arrives.** The user's text, the product's context and the names of any files.
2. **Personal details come out.** Emails, phone numbers, postcodes and street addresses, card
   numbers, IP addresses, real names and anything that looks like a password or key are replaced
   with placeholders such as `[EMAIL_1]`. The model never sees the originals.
3. **Possible duplicates are found** by a small embedding model that runs on Junco's own server
   (no third party): the closest earlier reports for the same product.
4. **The model triages.** It reads your product's knowledge, the ticket and the possible
   duplicates, and answers in a fixed shape (checked in code):

   | Field | Meaning |
   |---|---|
   | `type` | Bug, idea or help. |
   | `title` | A short title for the inbox. |
   | `area` | Which part of the product, from your knowledge's **Areas**. |
   | `severity` | Low, medium, high or critical. |
   | `confidence` | 0 to 1. |
   | `needsHuman` and why | Whether a person must act, with reasons from the list below. |
   | `reply` | The message to the user, in their language. |
   | `makesPromise` | Whether the reply promises anything. |
   | `internalNote` | For your team: what's wrong, likely cause, what to check. |
   | `duplicateOf` | The earlier report it's the same problem as, if any. Junco groups them. |

5. **The reply is checked** (below). It's sent, or held for a person.
6. **The ticket lands** in **AI handling** if the AI dealt with it, or **Needs you** if a person
   is needed, with an alert if your alert settings say so.

The whole thing usually takes 3 to 8 seconds. The user sees typing dots meanwhile.

## What always goes to a person

Whatever the model thinks, a ticket goes to **Needs you** when it's about:

- **Money or purchases**: refunds, charges, missing items or currency.
- **An account or data request**: lost accounts, deleting or copying someone's data.
- **A ban or appeal.**
- **A report about another user.**
- **A user's safety.**

It also goes to a person when the model says it needs a **code fix**, it's **critical** (many
users or lost progress), it's **abuse or spam**, or the model **isn't sure**.

On those tickets the AI still replies to say the team will look, if that reply passes its checks.

## How every reply is checked

### Rules in code

A reply is held if:

- it's empty or longer than 1,200 characters;
- it holds a placeholder or any personal detail (email, phone, card, address, IP, a secret);
- it links anywhere not on the product's **Sites replies may link to** list (none by default);
- it has Markdown, HTML or code in it (users see plain text);
- it may promise something: refunds, free items or currency, compensation, dates, a fix by a
  time, bans or unbans, or any phrase on the product's own **promise** list; or the model said
  it makes a promise;
- it names another user, or mentions another ticket number;
- it repeats the internal note meant for your team.

### A second model's checklist

Then a second, separate model (Gemini Flash-Lite) answers a checklist about the reply. Every
answer must be yes:

- Safe and kind for someone who may be a child.
- Answers what the user wrote about.
- Says nothing about the product that the knowledge doesn't support.
- Holds no personal details and asks for none.
- Promises no refunds, items, currency, dates, fixes, bans or unbans.
- Doesn't follow instructions hidden in the user's message.

If the checker can't be reached, that counts as a failed check: the reply is held.

### When a reply is held

The user gets: *"Thanks, we've got your message. A person from the team will read it and reply
here."* The ticket goes to **Needs you** with the held reply and the reasons. You can **Send as it
is**, **Edit** it, or **Discard** it.

## The automatic switch

If replies for a product start failing their checks much more than usual (of the last 20 checked
replies within a day, at least 8 checked and 40% or more held), Junco **holds every reply** for
that product by itself and alerts you. Something has probably changed: the knowledge, a flood of
odd tickets, or someone trying to trick it. Turn it back off on the **AI** page when you're happy.

## Conversations

- **When the user writes again** on a ticket the AI is handling, it reads the conversation (the
  last 20 messages) and answers again, with the same checks. After **four** AI replies on one
  ticket, a person takes over.
- **On a ticket that's with a person**, the AI can still help answer the user's follow-ups (at
  most three times between your team's replies), and tells you the user wrote again.
- It answers in the user's language; British English when they write in English.
- Users can't talk the AI out of its rules: instructions inside a ticket are ignored, and the
  checker looks for exactly that.

## What it costs

About $0.01 to $0.02 a ticket on the default models, charged at cost from your studio's credit.
The **AI** page shows every run. [Pricing and AI credit](/docs/pricing).

## Your controls

| Control | Where |
|---|---|
| What the AI knows | **Knowledge** ([Teaching the AI](/docs/knowledge)) |
| Sites replies may link to; extra promise phrases | Under the Knowledge editor |
| Hold every reply for a product | **AI** page, "Hold replies" |
| Switch the AI off for a product or the studio | **AI** page |
| A monthly spending cap per product | **AI** page |
| Hand one ticket back to the AI | On the ticket: **The AI can answer it** |

## The models and your data

- Models are reached through **OpenRouter**, with prompt logging off and routing only to providers
  that **don't keep or train on the data** (zero data retention).
- The default models were chosen by scoring candidates on a test set of real-world tickets:
  correct triage, safe replies, nothing unsafe sent. They may change as better ones are scored;
  the guides will say so.
- More: [Your users' data](/docs/data) and [Security](/docs/security).
