# Junco: every guide in one file
Junco's public guides, checked against what Junco does on 2026-11-25. Each starts with a comment
saying where it lives. The index is https://juncodesk.app/llms.txt; the API as OpenAPI is https://desk.juncodesk.app/openapi.json.
# What Junco is
> **In short.** Junco is a support desk for game and app studios with an AI that answers first.
> Users report a bug, suggest a feature or ask for help from a small form inside the product. The
> AI replies in seconds from what the studio has taught it, sorts and groups every report, and
> hands the team only what needs a person. When a fix ships, everyone who reported it is told, in
> the same place they asked. Early access, invite only, no subscription; the AI is charged at cost
> (about a cent or two a ticket).
## The problem it solves
A small team with many users drowns in the same questions and the same bug, reported fifty ways,
across email, Discord, store reviews and DMs. Junco puts one form inside the product, so reports
arrive with the context a developer needs (version, screen, device, a screenshot, a save), and an
AI deals with the repetitive part before anyone has to look.
## How it works
1. **A user reports something** from the form in your product: a website or web game (one script
tag), a phone, console or desktop app (Junco's hosted page or a small HTTP API). They pick
**Report a bug**, **Suggest a feature** or **Get help**, write a line or two, and can attach a
screenshot, a save file and a log. They never make an account.
2. **The AI triages it** within seconds: it gives it a title, the area of the product, a severity
and a confidence; spots whether it's the same problem as earlier reports and groups them;
writes a reply from your product's knowledge; and decides whether a person is needed.
3. **The reply is checked** before the user sees it: by rules in code (no personal details, no
links you haven't allowed, no promises) and by a second AI model with a checklist. A reply
that fails waits for you. Money, accounts, bans, safety and reports about other users always
go to a person, whatever the AI thinks.
4. **You get what needs you.** The desk's inbox shows tickets that need a person under **Needs
you**, with the AI's notes. Urgent ones and surges ("5 people reported this in an hour") send
a phone alert.
5. **You fix it.** With GitHub connected, one tap turns a group of reports into an issue, drafted
by the AI without personal details. Closing the issue tells users the fix is coming.
6. **Users hear it's live.** When you release (a GitHub release, a button, or one line in your
deploy script), every user who reported it is told, in the form where they asked.
## The words Junco uses
| Word | Means |
|---|---|
| **Studio** | Your team's space in Junco. Credit, products and people belong to a studio. |
| **Product** | Anything with its own support form: a game, an app, a website. Each has a **public key** `jk_...`. (The code and API say `game`; same thing.) |
| **User** | Someone using your product who sends a ticket. They have no Junco account. (The API says `player`.) |
| **Ticket** | One report: a **bug**, an **idea** or a **help** request, with its conversation. |
| **Group** | Tickets about the same problem. The first one leads; resolving it resolves them all. |
| **Knowledge** | What the AI knows about your product: plain Markdown you write or have drafted. It answers only from this. |
| **The desk** | Junco's web app where your team works: inbox, tickets, products, alerts. Works on a phone. |
| **Widget** | The script that draws the form inside a web page: `https://desk.juncodesk.app/widget/junco.js`. |
| **Hosted page** | Junco's own support page for a product, `https://desk.juncodesk.app/s/`, for products that can't run the widget. |
| **Signed user token** | A short-lived token your server signs so a signed-in user's tickets follow their account. Optional. |
| **Credit** | Prepaid US dollars the AI spends, at cost. |
| **Release** | Telling users their fix is live. |
## A ticket's stages
| Stage (`stage` in the API) | On the desk | Means |
|---|---|---|
| `ai_handling` | AI handling | The AI answered and is looking after it. |
| `needs_you` | Needs you | A person must act or decide. |
| `waiting_on_player` | Waiting on user | Someone on your team asked the user something. |
| `in_progress` | In progress | A GitHub issue is open for it. |
| `awaiting_release` | Awaiting release | The issue was closed as completed; the user was told the fix is coming. |
| `released` | Released | The fix is out and the user was told. Closed. |
| `resolved` | Resolved | Done. Closed. A reply from the user reopens it. |
## Who it suits
- **Small game and app teams** with lots of users and no support staff, who'd rather fix bugs than
answer the same question all day.
- **Web games and web apps** most of all: one script tag, screenshots and game state included.
- **Teams on GitHub**, who want reports to become issues and users told when fixes ship.
- **Products used by young people**: personal details are stripped before the AI reads anything,
replies are checked for safety, and users can delete everything they've sent.
## What it doesn't do (yet)
- **No email or chat channels.** Users write from the form or the hosted page, and read replies
there. Junco doesn't send users email.
- **No live chat** with typing agents; replies arrive in the form's thread.
- **No native SDK packages.** Unity, Godot, mobile and desktop products use the hosted page or
call the HTTP API (a few dozen lines; see [Apps, engines and desktop](/docs/platforms)).
- **No open sign-up.** Early access is invite only: ask at the form on Junco's website.
- **One region.** Data is stored on Junco's own servers in the United Kingdom.
More in [Is Junco right for you?](/docs/compare)
## Where to go next
- Setting up: [Getting started](/docs/getting-started).
- Adding it to your code (or having your coding AI do it): [For coding AIs](/docs/for-ai-agents)
and [Installing the form](/docs/install).
- Money: [Pricing and AI credit](/docs/pricing).
- Everything in one file, for AI tools: `/llms-full.txt`.
---
# Getting started
> **In short.** Ask for an invite, join with a passkey, add your product, install the form (paste a
> prompt into your coding AI, paste a snippet, or turn on the hosted page), teach the AI about your
> product, and send a test ticket. About 15 minutes for a website or web game. New studios get $2
> of AI credit, enough for around 150 tickets.
Junco is a support desk with an AI that answers first. Your users report a bug, suggest a feature
or ask for help from inside your product. The AI sorts every ticket, answers what it can from what
you've taught it, groups duplicates, and hands you only what needs a person. When you fix
something, the users who reported it are told. More in [What Junco is](/docs/overview).
## 0. Ask for an invite
Junco is in early access and invite only. Use the form on Junco's website: say what you make,
roughly how many users you have, and a link. We'll send an invite link, usually within a few days.
There's nothing to pay to start.
## 1. Join your studio
Open the invite link, enter your name and add a **passkey** (Face ID, a fingerprint or Windows
Hello). There's no password. The link works once, for 7 days. Joining as your studio's admin
means agreeing to the [terms](/legal/terms).
To sign in on another phone or computer, sign in on one that has your passkey and add the new one
under **Settings → Passkeys**, or use a passkey that syncs (iCloud Keychain, Google Password
Manager, 1Password).
## 2. Add your product
**Products → Add a product.** A product is anything with its own support form: a game, an app, a
website. Give it a name, the web addresses it runs on (the form only works there), and say whether
your users sign in. Each product gets a **public key** (`jk_...`), safe to put in your code.
## 3. Install the form
On the product's page, pick one:
- **Ask your AI.** Copy the prompt into Claude Code, Cursor, Copilot or whichever coding AI you
use, inside your project. It has your key and points at the [install guide](/docs/install) and
the steps [for coding AIs](/docs/for-ai-agents). It looks like this:
```prompt
Add the Junco support form to this project. Follow https://desk.juncodesk.app/docs/for-ai-agents.md (plain Markdown) step by step.
Public key: jk_YOUR_PUBLIC_KEY
Junco server: https://desk.juncodesk.app
```
- **Paste a snippet.** A script tag for websites and web games.
- **No code.** Turn on Junco's hosted support page and link to it from your app's menu, your store
listing or your Discord. Phone apps and engines can also use the API:
[Apps, engines and desktop](/docs/platforms).
Send a test ticket. The product's page shows **Connected** as soon as it arrives.
## 4. Teach the AI
The AI answers only from your product's **Knowledge**. Paste your FAQ or README and let the AI turn
it into knowledge, or copy a prompt for your coding AI to write it from your code. Check it, then
save. More in [Teaching the AI](/docs/knowledge).
## 5. Check the AI is ready
New studios start with **$2 of AI credit**, enough for around 150 tickets on the default model.
Top up on the **AI** page when you need to. See [Pricing and AI credit](/docs/pricing).
## 6. And then
- **Connect GitHub** to turn bugs into issues in a tap and tell users when the fix ships.
[GitHub and releases](/docs/github).
- **Invite your team** under **Settings → Team**. Admins set things up (products, GitHub, the
team); members work the inbox. Your plan may set how many people your studio can have.
- **Phone alerts** on the **Alerts** page, for anything urgent the AI hands to you.
[Using the desk](/docs/desk)
The **Get started** page in Junco ticks each step off by itself.
---
# Pricing and AI credit
> **In short.** During early access there is **no subscription** and no fee to use Junco. You pay
> only for the AI, **at cost**: what the AI model charges for each ticket, about **one to two US
> cents**, with nothing added per ticket. New studios get **$2 of credit** to start (roughly 150
> tickets). Top up in packs of $10, $25, $50 or $100, plus 10% to cover card and provider fees.
> When credit runs out the AI pauses; tickets still arrive and nothing is lost.
## What you pay for
| | Price |
|---|---|
| Using Junco: the desk, the form, the hosted page, GitHub, releases, alerts, your whole team | **Free during early access** |
| Tickets, users, products, team members, storage | No per-item charge |
| The AI | **At cost**, from prepaid credit in US dollars |
| Topping up credit | Packs of **$10, $25, $50, $100**, plus a **10% fee** on top (a $10 pack costs $11) |
| Starting credit for a new studio | **$2**, free |
Before early access ends, we'll agree a price with you well ahead of any change. Nothing changes
without notice.
## What a ticket costs
Each AI step is charged exactly what the model charged for it, in dollars:
- **Triage and first reply**: reading the ticket and your knowledge, sorting it and writing a
reply. Most of the cost, because your knowledge is read every time.
- **The reply check**: a second, cheaper model reads the reply against a checklist.
- **Follow-ups**: when the user writes again, the AI reads the conversation and answers again
(at most four AI replies a ticket before a person takes over).
- **Drafts you ask for**: a GitHub issue from a group of reports, or knowledge from your help text.
Usually a cent or two each.
On the default model (Google Gemini Flash, with Flash-Lite as the checker), a typical ticket costs
**about $0.01 to $0.02**, all steps included. Shorter knowledge costs less: it's read for every
ticket.
### Worked examples
| Users' tickets a month | Rough AI cost a month |
|---|---|
| 100 | $1 to $2 |
| 1,000 | $10 to $20 |
| 10,000 | $100 to $200 |
The **AI** page on the desk shows the real figures: spend per product and per month, tickets
answered and how many replies passed their checks.
## Credit
- Credit belongs to the **studio** and is shared by all its products.
- Every AI call comes off the balance as it happens.
- **Buy credit** on the **AI** page, by card.
- **Low credit alert**: set the amount on the AI page; Junco alerts you when the balance drops
below it.
- **When credit runs out**, the AI pauses: new tickets come straight to **Needs you** and nothing
is lost. Top up and it carries on with new tickets.
## Switches and caps
On the **AI** page, admins can:
- **Switch the AI off for the whole studio**: tickets come straight to you.
- **Switch it off for one product.**
- **Hold every reply** for a product, so a person approves each one before it's sent (the AI
still sorts and groups).
- **Set a monthly cap** per product, in dollars (from $0.50). Once a product reaches it, its AI
pauses until the start of next month.
Junco may also hold every reply for a product by itself if replies start failing their checks
much more often than usual (see [How the AI works](/docs/ai)); you turn it back on.
## Questions about money
- **Is there a free plan?** Junco itself is free during early access, and $2 of credit is free.
Without credit you can still use the desk with the AI off.
- **Can I use my own AI key?** Not yet. Each studio's credit is kept on its own key with
OpenRouter, limited to that studio's balance.
- **Refunds of unused credit?** Ask us. A refunded card payment takes its credit back off your
balance (half for a half refund).
- **Currency?** US dollars, because AI models are priced in dollars.
- **Invoices and VAT?** Every card top-up comes with an invoice from Stripe, for your accounts.
For VAT, ask us.
---
# Is Junco right for you?
> **In short.** Junco suits small game and app teams who get lots of reports from users, want an
> AI to answer the repetitive ones safely, and fix things through GitHub. It's less suited to
> teams who need email or live chat support, many channels in one inbox, or a large support team
> with workflows and SLAs.
## Good fits
- **An indie or small studio** with thousands of players and nobody whose job is support.
- **A web game or web app**: one script tag, and reports arrive with a screenshot, the save and
the game state.
- **A team that lives in GitHub**: groups of reports become issues; closing them and releasing
tells every user who reported it.
- **A product with young users**: personal details never reach the AI, replies are checked for
safety, users can delete what they've sent, and there's a plain privacy notice for them.
- **Someone who wants their coding AI to do the install**: Junco gives a prompt, and these guides
are written for it.
## Not a fit (yet)
- **Email or chat as channels.** Junco takes reports from its form and hosted page only, and
replies there. It doesn't read an inbox or send users email.
- **Live chat.** Replies arrive in the thread, not as a live conversation with an agent.
- **Big support teams** wanting macros, SLAs, assignment rules, skills routing or reporting
across many agents.
- **Phone or console apps that want a drop-in SDK**: there's a hosted page and a small API with
code to copy, but no packaged SDKs yet.
- **Data outside the UK**: Junco runs in one region, the United Kingdom.
- **Open sign-up**: early access is by invite.
## Compared with other ways of doing support
| | Junco | General help desks (for example Zendesk, Freshdesk, Help Scout, Intercom) | Discord or forums | GitHub issues for users | Email |
|---|---|---|---|---|---|
| Built for | Users of games and apps, from inside the product | Customer service across email, chat and more | Community | Developers | Anything |
| Context with each report | Version, screen, device, screenshot, save, log | What the user types, plus what you wire up | What the user types | What the user types | What the user types |
| First answer | AI in seconds, checked, held when unsure | Varies by product and plan | Whoever's online | You | You |
| Duplicates | Grouped automatically, "12 users have this" | Usually by hand | Threads pile up | By hand | By hand |
| Privacy for users | Private threads; personal details kept from the AI; delete-it-yourself | Private | Public | Public | Private |
| Tells users when it's fixed | Yes, automatically on release | By hand or with automation | By hand | If they watch the issue | By hand |
| Price | Free in early access; AI at cost (about $0.01 to $0.02 a ticket) | Usually per agent per month | Free | Free | Free |
Crash and error reporting tools (Sentry, Backtrace, Bugsnag and the like) catch crashes
automatically; Junco handles what people tell you. They work well together: put your crash tool's
event id in Junco's `context`.
## How Junco is different
- **AI first, but careful.** The AI answers only from what you've taught it, a second model checks
every reply, and anything about money, accounts, bans, safety or other users goes to a person.
- **Made by a game developer** for their own game first (Vaelis), so the details are game-shaped:
screenshots before the panel covers the game, keys that don't reach the game while typing,
"Save and log".
- **At cost.** You pay what the AI model charges, nothing added per ticket.
- **Docs for AIs.** Every guide is Markdown, with `/llms.txt`, `/llms-full.txt` and an OpenAPI
file, so a coding AI can install it and an assistant can answer questions about it.
---
# Questions
> **In short.** Short answers, each linking to the guide with the details.
## About Junco
**What is Junco?**
A support desk for game and app studios with an AI that answers first. Users report bugs,
suggest features or ask for help from inside your product; the AI answers from what you've taught
it, groups duplicates and hands you what needs a person. [What Junco is](/docs/overview)
**Who makes it?**
Big Beans Studio, an independent studio in the United Kingdom, first for its own browser space
game, Vaelis.
**Is it only for games?**
No. Any product with users: games, apps, websites, tools. The desk says "product" and "user".
**How do I get it?**
It's in early access, invite only. Ask with the form on Junco's website; you'll get an invite
link. [Getting started](/docs/getting-started)
**How much does it cost?**
No subscription during early access. The AI is charged at cost, about $0.01 to $0.02 a ticket,
from prepaid credit; new studios get $2 free. [Pricing and AI credit](/docs/pricing)
## Installing
**How long does it take to install?**
For a website or web game, minutes: one script tag. Paste the product's "Ask your AI" prompt into
your coding AI and it does it. [Installing the form](/docs/install)
**Does it work with React / Next.js / Vue / Svelte / Angular?**
Yes, with a few lines; recipes for each in [Installing the form](/docs/install).
**Unity, Godot, Unreal, iOS, Android, Flutter, React Native?**
Yes, through the hosted page (no code) or the HTTP API, with code to copy.
[Apps, engines and desktop](/docs/platforms)
**Is there an npm package or SDK?**
No. The widget is one script loaded from Junco; other platforms call a small HTTP API.
**Will it clash with my site's styles or my game's controls?**
No. It lives in a closed shadow root, and keys and clicks inside it don't reach your page.
[Widget reference](/docs/widget)
**Do my users need an account?**
No. Junco remembers them by a random id in their browser or app, or your server vouches for
signed-in users with a token. [Signed user tokens](/docs/user-tokens)
## The AI
**Which AI does it use?**
Google Gemini (Flash to write, Flash-Lite to check), through OpenRouter, with zero data retention.
**Can it say something wrong or embarrassing?**
Every reply passes rules in code and a second model's checklist (safe, on topic, true to your
knowledge, no personal details, no promises, no following instructions hidden in the message), or
it's held for you. You can also hold every reply for approval. [How the AI works](/docs/ai)
**What does the AI know about my product?**
Only what you put in its knowledge. Paste your FAQ or README and it drafts it for you.
[Teaching the AI](/docs/knowledge)
**What languages?**
It replies in the user's language.
**Can I turn the AI off?**
Yes, per product or for the whole studio, or set a monthly cap. Tickets then come straight to you.
**What happens when credit runs out?**
The AI pauses; tickets keep arriving and come to you. Nothing is lost.
## Data and privacy
**Where is data stored?**
On Junco's own servers in the United Kingdom.
**Does the AI see my users' personal details?**
No. Emails, phone numbers, addresses, card numbers, names and passwords are replaced with
placeholders first. [Your users' data](/docs/data)
**Can users delete their data?**
Yes, themselves, from the form: "Delete everything I've sent". Admins can also download or delete
a user's data from any of their tickets.
**Is it GDPR-friendly?**
Junco acts as your processor, with a data processing agreement, a sub-processor list, retention
limits and tools for access and deletion requests. [Legal](/legal)
## Working with it
**Does it work on my phone?**
Yes: the desk is built for phones first, with phone alerts. [Using the desk](/docs/desk)
**Does it connect to GitHub?**
Yes, optionally: issues from groups of reports, and releases that tell users.
[GitHub and releases](/docs/github)
**Can I invite my team?**
Yes, as Admins or Members, from Settings → Team.
**Is there an API?**
Yes, for raising and reading tickets as a user, and for releases from deploy scripts.
[API reference](/docs/api), `/openapi.json`.
---
# For coding AIs
> **In short.** This page is written for AI coding agents (Claude Code, Cursor, Copilot, Codex and
> the like) adding Junco to a project. Follow it top to bottom. You need two values from the
> human: the product's **public key** (`jk_...`) and Junco's **server address**
> (`https://desk.juncodesk.app`). For a website or web game, add one script and one `Junco.init` call. For
> anything else, link the hosted page or call the HTTP API. Then send a test ticket.
If you're a person, copy this into your coding AI inside your project, with your product's key in
place of `jk_YOUR_PUBLIC_KEY`. Junco's desk gives you a longer one with your details already filled
in: a product's page, **Install**, **Ask your AI**.
```prompt
Add the Junco support form to this project. Follow https://desk.juncodesk.app/docs/for-ai-agents.md (plain Markdown) step by step.
Public key: jk_YOUR_PUBLIC_KEY
Junco server: https://desk.juncodesk.app
Ask me for anything else that guide says you need. When it's done, send a test ticket and tell me what you changed and anything I need to do myself.
```
## 1. Get what you need from the human
You can't make these yourself; they come from the product's page on Junco's desk. Ask for any you
don't have, in one message:
| Value | Looks like | Needed for | Secret? |
|---|---|---|---|
| Public key | `jk_` + about 20 characters | Everything | **No.** Safe in client code. |
| Junco server | `https://desk.juncodesk.app` | Everything | No |
| The site's web addresses | `https://example.com` | Web: each must be listed on the product in Junco, exactly (scheme, host and port if any; no path), or the form is refused. `https://` only, except `http://localhost:` and `http://127.0.0.1:` for development. Up to 20. | No |
| Do users sign in? | yes / no | Choosing how users are recognised | |
| Signing key | a `.pem` file, Ed25519 private key | Only if users sign in and the human wants tickets to follow accounts | **Yes.** Server only. |
| Release key | `jr_...` | Only for telling users from a deploy script that fixes are live | **Yes.** CI secrets only. |
If the human has no Junco account: Junco is invite only for now; they ask for an invite on
Junco's website. You can still write the code with a placeholder key and tell them.
## 2. Pick the way in
Look at the project and choose one:
| The project is | Do this |
|---|---|
| A website, web app or web game (any framework: plain HTML, React, Next.js, Vue, Nuxt, Svelte, SvelteKit, Angular, Phaser, PixiJS, three.js, Babylon.js, Godot or Unity **web export**) | **The widget.** Section 3. |
| An Electron or Tauri app | If its window loads an `https://` site, the widget (section 3). If it loads local files (`file://`, `app://`, `tauri://`), Junco can't allow that origin: use the hosted page, or the API from the main process (section 4). |
| A phone app (Swift, Kotlin, Flutter, React Native), a desktop or console game, a native Unity/Godot/Unreal build | **The hosted page** (no code: open a URL) or **the API** (your own form). Section 4. |
| A Discord server, store page or docs site | **The hosted page**: a link. Section 4. |
| A backend only | Usually nothing; if it should report problems itself, use the API with a signed token. |
## 3. Websites and web games: the widget
### 3.1 Load and start it once
Add this where the app starts, on every page that should have support. Call `Junco.init` exactly
once per page load; later calls are ignored.
```html
```
In a bundled app (React, Vue, Svelte and so on), load the script at runtime instead of importing
it. There's no npm package. A helper that works everywhere, including with server-side rendering:
```js
// junco.js: load Junco's widget once, in the browser only.
let loading;
export function startJunco(options) {
if (typeof window === "undefined") return Promise.resolve(null); // server-side render: skip
loading ??= new Promise((resolve, reject) => {
const s = document.createElement("script");
s.src = `${options.server}/widget/junco.js`;
s.async = true;
s.onload = () => resolve(window.Junco.init(options));
s.onerror = () => reject(new Error("Couldn't load Junco"));
document.head.append(s);
});
return loading;
}
```
Call `startJunco({...})` from the app's root once mounted: `useEffect(() => { startJunco(...) }, [])`
in React or Next.js (in a `"use client"` component), `onMounted` in Vue, `onMount` in Svelte.
Recipes per framework: [Installing the form](/docs/install).
**Options are read once**, at init. To send what's current when the user opens the form, pass
**functions** that read the current state (`context: () => store.getState()...`), not values.
### 3.2 Put it where users look for help
- If the app has a help, menu, settings or account area, add a **Support** (or **Help**) item
there that calls `Junco.open()`, and pass `button: false` to hide Junco's own round button.
- `Junco.open({ type: "bug" })` opens straight to a bug report (`"idea"`, `"help"` too).
- If there's no sensible place, leave `button` out: Junco shows a small round button in the
bottom right corner.
### 3.3 Send useful context, never personal details
`context` returns a plain object (under 16 KB as JSON) the team sees with the ticket and the AI
reads. Good things to send: app version or build, current screen or route, platform and browser,
screen size, language, relevant settings, the user's current level or place, feature flags,
recent errors. **Never** send passwords, tokens, cookies, emails, phone numbers, addresses or
payment details.
```js
context: () => ({
version: "1.4.2",
screen: router.currentRoute,
device: navigator.userAgent,
viewport: `${innerWidth}x${innerHeight}`,
language: navigator.language,
level: game.level?.id,
}),
```
### 3.4 Screenshots, saves and logs (games especially)
All optional, all callbacks, called when needed; each may return a promise.
```js
screenshot: () => new Promise((resolve) => {
// A canvas game. WebGL needs preserveDrawingBuffer: true, or call this right after a render.
const c = document.querySelector("canvas");
const scale = Math.min(1, 1280 / c.width);
const out = document.createElement("canvas");
out.width = Math.round(c.width * scale);
out.height = Math.round(c.height * scale);
out.getContext("2d").drawImage(c, 0, 0, out.width, out.height);
out.toBlob(resolve, "image/jpeg", 0.8);
}),
save: () => JSON.stringify(game.saveData()), // up to 1 MB
log: () => recentLogLines.join("\n"), // up to 512 KB, text
```
The screenshot is taken when the panel opens, before it covers the screen; the user chooses
whether to attach it. Keep it a JPEG at most 1280 px wide (it must be under 2 MB).
### 3.5 Signed-in users (optional)
Without anything extra, Junco recognises a user by a random id kept in their browser. If the app
has accounts and the human wants tickets to follow the account across devices:
1. On the **server**, add an endpoint (e.g. `GET /api/junco-token`) that returns a token for the
signed-in user, signed with the `.pem` key from an environment variable (`JUNCO_SIGNING_KEY`).
Code for Node, Python, Go, PHP and others: [Signed user tokens](/docs/user-tokens).
2. In the browser: `playerToken: () => fetch("/api/junco-token").then((r) => (r.ok ? r.text() : null))`.
Never put the private key in client code or the repo.
### 3.6 Content Security Policy
If the project sets a CSP (a meta tag, a header in server config, `next.config.js`, `helmet`,
Netlify/Vercel headers), add `https://desk.juncodesk.app` to `script-src` and `connect-src`. Nothing else is
needed: the widget uses no inline scripts, no iframes and no third parties.
### 3.7 Unread badge (optional)
If the app shows notification badges: `onUnread: (n) => setSupportBadge(n)`. Junco calls it with
the number of tickets that have replies the user hasn't read.
## 4. Everything else: hosted page or API
**Hosted page (no code).** The human turns on "Junco's support page" on the product's page in
Junco; then open `https://desk.juncodesk.app/s/jk_YOUR_PUBLIC_KEY` from a Help or Support menu item, in the system
browser or an in-app browser (`SFSafariViewController`, Custom Tabs, `Application.OpenURL`,
`OS.shell_open`, `url_launcher`, `Linking.openURL`). It remembers the user in that browser. It
can't receive game state or signed-in identity; for those, use the API.
**API (your own form).** Four calls: raise a ticket, list tickets, read one, reply. Make a random
id once per install and keep it. Complete examples for Unity, Godot, Swift, Kotlin, Flutter and
React Native: [Apps, engines and desktop](/docs/platforms). Reference: [API](/docs/api) and
`https://desk.juncodesk.app/openapi.json`.
## 5. Check it works
1. Run the app, open the form, send a **bug** report saying "Junco test".
2. You should see the thread with your message and, if the AI is on for the product, its reply
within a few seconds (typing dots while it writes).
3. The product's page in Junco now says **Connected**. Ask the human to check.
From a terminal, the same test without a browser (a random id, no `Origin` header):
```sh
curl -s -X POST https://desk.juncodesk.app/v1/games/jk_YOUR_PUBLIC_KEY/tickets \
-H "Content-Type: application/json" \
-H "X-Junco-Player: $(head -c 24 /dev/urandom | base64 | tr '+/' '-_' | tr -d '=')" \
-d '{"type":"bug","text":"Junco test from the command line"}'
```
If something fails, look the message up in [Troubleshooting](/docs/troubleshooting). The common
ones: `This page isn't allowed to use this game's support` (the page's origin isn't listed on the
product in Junco), a CSP error in the console, `This game needs a player token`.
## 6. Rules
- **Don't** put the signing key (`.pem`) or a release key (`jr_...`) in client code, the repo or
logs. The public key (`jk_...`) is fine anywhere.
- **Don't** put the form in an iframe, restyle it or reach into it: it lives in a closed shadow
root and is built to be left alone.
- **Don't** send personal details in `context`.
- **Don't** copy `junco.js` into the repo unless the project's CSP or offline needs demand it;
loading it from `https://desk.juncodesk.app` keeps it up to date.
- **Do** call `Junco.init` once, with functions for anything that changes.
- **Do** tell the human at the end: what you changed, which web addresses must be listed on the
product in Junco, any secret they must add to the server's environment, and to turn on the
hosted page if you linked to it.
## 7. TypeScript
There's no types package; add this declaration if the project uses TypeScript:
```ts
// junco.d.ts
type JuncoMaybe = T | null | undefined | Promise;
interface JuncoOptions {
game: string;
server?: string;
context?: () => JuncoMaybe>;
screenshot?: () => JuncoMaybe;
save?: () => JuncoMaybe;
log?: () => JuncoMaybe;
playerToken?: () => JuncoMaybe;
handle?: () => JuncoMaybe;
button?: boolean;
onUnread?: (count: number) => void;
}
interface JuncoApi {
version: string;
init(options: JuncoOptions): JuncoApi;
open(options?: { type?: "bug" | "idea" | "help" }): Promise | undefined;
close(): void;
}
declare global {
interface Window { Junco: JuncoApi }
const Junco: JuncoApi;
}
export {};
```
Full details of every option: [Widget reference](/docs/widget).
---
# Installing the form
> **In short.** For websites and web games: load `https://desk.juncodesk.app/widget/junco.js` and call
> `Junco.init({ game: "jk_...", server: "https://desk.juncodesk.app" })` once. It draws its own panel in a closed
> shadow root (about 8 KB gzipped, no dependencies), works in any framework, and only answers on
> the web addresses listed on the product in Junco. Phone apps, engines and desktop software use
> the hosted page or the API: [Apps, engines and desktop](/docs/platforms).
Every product has a **public key** (`jk_...`) on its page in Junco; it's safe to ship in client
code.
## The quickest way: ask your coding AI
Copy this into Claude Code, Cursor, Copilot or whichever coding AI you use, inside your project.
The product's **Install** page in Junco gives you the same prompt with your key, web addresses and
sign-in details already filled in; here they're placeholders.
```prompt
Add the Junco support form to this project. Junco is the support desk I use: users report bugs, suggest features or ask for help, and I answer in Junco.
Read the install guide first: https://desk.juncodesk.app/docs/install.md (plain Markdown).
Details for this project:
- Product: your product
- Public key: jk_YOUR_PUBLIC_KEY (safe to put in client code)
- Junco server: https://desk.juncodesk.app
- Web addresses allowed to use it: none yet (ask me which address the site runs on; I'll add it in Junco)
Do this:
1. Load https://desk.juncodesk.app/widget/junco.js and call Junco.init({ game: "jk_YOUR_PUBLIC_KEY", server: "https://desk.juncodesk.app", ... }) once when the app starts. It draws its own panel inside a shadow root, so our CSS can't break it.
2. Find the app's existing help, menu or settings area and add a "Support" (or "Help") item there that calls Junco.open(). Then pass button: false to hide Junco's own round button. If there's no sensible place, leave Junco's button on.
3. Pass context: () => ({ ... }) with what's useful when something goes wrong: the app's version, the current screen or page, and device details. Never include passwords, tokens, emails or other personal details.
4. If the app draws to a canvas, pass screenshot: () => a Blob of it (JPEG, at most 1280 px wide, under 2 MB).
5. If the project sets a Content-Security-Policy, allow https://desk.juncodesk.app in script-src and connect-src.
6. Users don't need to sign in: Junco keeps a random id in their browser. Don't add any login for it.
7. If the app shows a badge for notifications, pass onUnread: (n) => … to show replies the user hasn't read.
When it's done, run the app, open the form and send a bug report saying "Junco test". Tell me what you changed and anything I need to do myself.
```
The rest of this page is what it reads, if you'd rather do it yourself.
## Plain HTML
```html
```
Put it before `
`. With the Pages Router, do the same
in `pages/_app.jsx`. If you set a Content Security Policy in `next.config.js` or middleware, add
`https://desk.juncodesk.app` to `script-src` and `connect-src`.
### Vue and Nuxt
```js
// Vue: main.js, after app.mount("#app")
import { startJunco } from "./lib/junco";
startJunco({ game: "jk_...", server: "https://desk.juncodesk.app", context: () => ({ page: router.currentRoute.value.fullPath }) });
```
```js
// Nuxt: plugins/junco.client.js (".client" runs it in the browser only)
import { startJunco } from "~/lib/junco";
export default defineNuxtPlugin((nuxtApp) => {
const router = useRouter();
startJunco({ game: "jk_...", server: "https://desk.juncodesk.app", context: () => ({ page: router.currentRoute.value.fullPath }) });
});
```
### Svelte and SvelteKit
```svelte
```
(`onMount` only runs in the browser. In Svelte 4 use `$app/stores` and `get(page)`.)
### Angular
```ts
// app.component.ts
import { AfterViewInit, Component } from "@angular/core";
import { Router } from "@angular/router";
import { startJunco } from "./junco";
@Component({ selector: "app-root", templateUrl: "./app.component.html" })
export class AppComponent implements AfterViewInit {
constructor(private router: Router) {}
ngAfterViewInit() {
startJunco({ game: "jk_...", server: "https://desk.juncodesk.app", context: () => ({ page: this.router.url }) });
}
}
```
With server-side rendering, the `typeof window` check in the helper keeps it in the browser.
### Web games (canvas, WebGL, Phaser, PixiJS, three.js, Babylon.js)
Games get the most from the extra callbacks: a screenshot, the save and recent log lines.
```js
Junco.init({
game: "jk_...",
server: "https://desk.juncodesk.app",
button: false, // open it from the game's own menu
context: () => ({ version: GAME_VERSION, scene: game.scene.key, level: state.level, fps: Math.round(game.loop.actualFps) }),
screenshot: () => canvasShot(game.canvas),
save: () => JSON.stringify(state.save()),
log: () => logBuffer.join("\n"),
handle: () => state.playerName,
onUnread: (n) => menu.setBadge("support", n),
});
pauseMenu.on("support", () => Junco.open());
pauseMenu.on("report-bug", () => Junco.open({ type: "bug" }));
function canvasShot(canvas) {
return new Promise((resolve) => {
const scale = Math.min(1, 1280 / canvas.width);
const out = document.createElement("canvas");
out.width = Math.round(canvas.width * scale);
out.height = Math.round(canvas.height * scale);
out.getContext("2d").drawImage(canvas, 0, 0, out.width, out.height);
out.toBlob(resolve, "image/jpeg", 0.8);
});
}
```
- **WebGL canvases** read back blank unless made with `preserveDrawingBuffer: true` (three.js:
`new WebGLRenderer({ preserveDrawingBuffer: true })`; Phaser: `render: { preserveDrawingBuffer:
true }`), or unless you render a frame just before reading. Without it you get a black image.
- The screenshot is taken when the panel opens, before it covers the game.
- Typing in the panel never reaches the game: keys, clicks and scrolls stay inside it, so
shortcuts don't fire while someone writes a report.
- Unity and Godot **web exports** are web pages: add the script to the export's HTML template and
call `Junco.open()` from the game through JavaScript interop (`Application.ExternalEval` is
gone; in Unity use a `.jslib` plugin; in Godot 4, `JavaScriptBridge.eval("Junco.open()")`).
## Opening it from your own menu
```js
Junco.init({ game: "jk_...", server: "https://desk.juncodesk.app", button: false });
helpButton.addEventListener("click", () => Junco.open()); // the three choices
bugButton.addEventListener("click", () => Junco.open({ type: "bug" })); // straight to one: bug, idea, help
```
Pass `onUnread` to put the number of unread replies on your own button.
## Signed-in users
By default Junco recognises a user by a random id kept in their browser (`localStorage`), per
product. If your users sign in, let your server vouch for them, and their tickets follow their
account to any device: [Signed user tokens](/docs/user-tokens).
## Content Security Policy
If your site sets one, allow `https://desk.juncodesk.app` in `script-src` and `connect-src`. Screenshots are sent
as uploads, so nothing else is needed.
If your policy can't load scripts from another origin, you may copy `junco.js` into your own site
and serve it yourself (it still calls `https://desk.juncodesk.app`, so `connect-src` still needs it). You then
miss updates until you copy it again; `Junco.version` says which you have.
## Phone apps, desktop games and anything else
- **Junco's hosted page.** Turn on "Junco's support page" on the product's page and link to it
(`https://desk.juncodesk.app/s/jk_...`) from your menu, store listing or community.
- **The API.** Build your own form in Unity, Godot, Swift, Kotlin or anything that speaks HTTP.
Both, with complete code: [Apps, engines and desktop](/docs/platforms).
## Check it works
Open the form, send a bug report saying "Junco test", and look at the product's page in Junco: it
says **Connected** when the first ticket arrives. If it doesn't:
- **"This page isn't allowed to use this game's support"**: add the page's exact address on the
product's page.
- **Nothing appears**: look in the browser console for a Content Security Policy error, or a 404
for `junco.js` (check the server address).
- **"This game needs a player token"**: the product only takes signed-in users and no token was
sent.
All the messages: [Troubleshooting](/docs/troubleshooting). Every option: [Widget reference](/docs/widget).
---
# Widget reference
> **In short.** `https://desk.juncodesk.app/widget/junco.js` defines one global, `Junco`, with `init(options)`,
> `open({ type })`, `close()` and `version`. Only `game` is required (pass `server` too unless the
> page is on Junco's own address). Every other option is a function Junco calls when it needs the
> value; each may return a value, `null` or a promise, and may fail without breaking anything.
## `Junco.init(options)`
Starts the widget. Call it once per page load; later calls are ignored and return `Junco`. If the
page's `` doesn't exist yet, it waits for `DOMContentLoaded`. Throws only if `game` is
missing.
| Option | Type | Default | What it's for |
|---|---|---|---|
| `game` | `string` | required | The product's public key, `jk_...`. |
| `server` | `string` | the page's own origin | Junco's address: `https://desk.juncodesk.app`. Always pass it on your own site. |
| `context` | `() => object` | none | What's useful when something goes wrong: version, screen, device, settings. Called each time the panel opens. Up to 16 KB as JSON. No personal details. |
| `screenshot` | `() => Blob` | none | An image of the screen (PNG, JPEG or WebP, under 2 MB). Called when the panel opens, before it covers the page. The user chooses whether to attach it. |
| `save` | `() => Blob \| string` | none | The user's save or state (under 1 MB). A string is sent as JSON text. Asked for only if the user ticks "Save and log". |
| `log` | `() => string` | none | Recent log lines (UTF-8 text, under 512 KB). With "Save and log". |
| `playerToken` | `() => string` | none | A signed token from your server for a signed-in user ([Signed user tokens](/docs/user-tokens)). Called before every request; return `null` for users who aren't signed in. |
| `handle` | `() => string` | none | The user's display name (up to 40 characters), shown to your team. A signed token's `name` wins over it. |
| `button` | `boolean` | `true` | `false` hides Junco's round button; open the panel from your own menu instead. |
| `onUnread` | `(count: number) => void` | none | Called when the number of tickets with replies the user hasn't read changes, for a badge on your own button. |
"Function" options may be `async`. If one throws or rejects, Junco carries on without that value.
## `Junco.open(options?)`
Opens the panel. With no argument it shows the three choices (**Report a bug**, **Suggest a
feature**, **Get help**) and the user's earlier tickets. `Junco.open({ type: "bug" })` goes
straight to one form; `type` is `"bug"`, `"idea"` or `"help"`. Returns a promise, or `undefined`
before `init`.
## `Junco.close()`
Closes the panel. The user can also press **Esc** or the close button; focus goes back to where it
was.
## `Junco.version`
The widget's version, such as `"0.1.6"`.
## What users see
- **Home**: the three choices and their tickets, newest activity first, with a dot on those with
unread replies.
- **A form**: a text box (up to 5,000 characters), a **Screenshot** tick (if `screenshot` gave
one) and **Save and log** (if `save` or `log` is set), and Send.
- **The thread**: their messages, replies from "AI" and "the team" (never staff names, never
internal notes), the ticket's status in words ("Being looked at", "With the developer", "Being
worked on", "Fixed: coming in the next update", "Fixed and live"), typing dots while the AI writes, and a reply box.
- **The footer**: a **Privacy** link to the notice for your product's users, and **Delete
everything I've sent**, which deletes all their tickets, messages and files after a confirm.
## How it behaves
- **Isolated.** It adds one element, ``, to the end of ``, with a closed
shadow root: your CSS can't change it and its CSS can't change your page. It sits above
everything (`z-index: 2147483000`), fixed to the bottom right.
- **Quiet.** Keys, clicks, touches and scrolls inside it don't reach your page, so game controls
and keyboard shortcuts don't fire while someone types.
- **No cookies.** Requests go to `https://desk.juncodesk.app` with `credentials: "omit"`.
- **Who the user is.** With a `playerToken`, the token. Otherwise a random id (32 URL-safe
characters) kept in `localStorage` under `junco:player:`. If storage is blocked
(some private modes), each visit gets a new id and earlier tickets aren't shown.
- **Updates.** It checks for unread replies when it starts, every minute, and when the tab comes
back into view; every 10 seconds while a thread is open; every 1.5 seconds while the AI is
writing (for up to 90 seconds). It does nothing while the tab is hidden.
- **Phones.** The panel is laid out for small screens first (a sheet from the bottom) and stays
above the on-screen keyboard.
- **Size.** About 21 KB, 8 KB gzipped, no dependencies. Served with a 5-minute cache.
- **Accessible.** Keyboard only works throughout; it's labelled for screen readers and respects
reduced motion.
## Example with everything
```js
Junco.init({
game: "jk_...",
server: "https://desk.juncodesk.app",
button: false,
context: () => ({ version: APP_VERSION, screen: router.current, device: navigator.userAgent, language: navigator.language }),
screenshot: () => captureCanvasAsJpeg(),
save: () => JSON.stringify(store.exportSave()),
log: () => logger.recent(200).join("\n"),
playerToken: () => fetch("/api/junco-token").then((r) => (r.ok ? r.text() : null)),
handle: () => session.user?.displayName,
onUnread: (n) => (supportBadge.textContent = n ? String(n) : ""),
});
document.querySelector("#support").addEventListener("click", () => Junco.open());
```
TypeScript declarations: [For coding AIs](/docs/for-ai-agents), section 7.
---
# Apps, engines and desktop
> **In short.** Outside a web page there are two ways in. **The hosted page**: turn it on for the
> product and open `https://desk.juncodesk.app/s/jk_...` from a Help menu; no code. **The API**: build your own
> form with four HTTP calls, sending a random id you make once per install in the
> `X-Junco-Player` header. Native apps send no `Origin` header, so no web address needs listing.
> Complete code below for Unity, Godot, Swift, Kotlin, Flutter and React Native.
## Which to use
| | Hosted page | API |
|---|---|---|
| Code | One line to open a URL | A small client and your own screens |
| Looks like | Junco's page (light and dark), in a browser | Your app |
| Game state, screenshot, save, log | No (device, screen size and language only) | Yes |
| Signed-in users follow their account | No: one browser, one user | Yes, with [signed tokens](/docs/user-tokens) |
| Products that only allow signed-in users | Doesn't work | Works |
| Users see replies | When they open the page again | Where you show them (poll `GET /unread` for a badge) |
Start with the hosted page if you want support working today; move to the API when you want game
state and screenshots.
## The hosted page
1. On the product's page in Junco, turn on **Junco's support page**.
2. Open `https://desk.juncodesk.app/s/jk_YOUR_PUBLIC_KEY` from your Help or Support menu, your store listing, your
Discord or your website.
| Platform | Open it with |
|---|---|
| iOS | `SFSafariViewController` or `UIApplication.shared.open(url)` |
| Android | Custom Tabs (`CustomTabsIntent`) or `Intent.ACTION_VIEW` |
| Unity | `Application.OpenURL(url)` |
| Godot | `OS.shell_open(url)` |
| Unreal | `FPlatformProcess::LaunchURL(*Url, nullptr, nullptr)` |
| Flutter | `launchUrl(Uri.parse(url))` (`url_launcher`) |
| React Native | `Linking.openURL(url)` |
| Electron | `shell.openExternal(url)` |
The page can't be put in an iframe. It remembers the user in that browser, so open it the same
way each time. It needs "Without an account" on for the product.
## The API
Everything is under `https://desk.juncodesk.app/v1/games//`. The full reference is
[API](/docs/api); OpenAPI: `https://desk.juncodesk.app/openapi.json`. The four calls a form needs:
| Call | Does |
|---|---|
| `POST /tickets` with `{"type", "text", "context"}` | Raise a ticket (`type`: `bug`, `idea` or `help`). 201 with the ticket and its messages. |
| `GET /tickets` | The user's tickets, each with `unread`. |
| `GET /tickets/` | One ticket's messages (marks it read). While `aiWorking` is true, ask again every 2 seconds or so. |
| `POST /tickets//messages` with `{"text"}` | The user replies. |
Plus `GET /unread` (`{"count"}`, for a badge) and `DELETE /me` (the user deletes everything
they've sent; offer it in your settings). Errors are `{"error": "..."}` in words you can show the
user.
**The user's id.** Make 24 random bytes, encode them as URL-safe base64 without padding (32
characters) or as hex (48), store it, and send it as `X-Junco-Player` on every call. Losing it
loses access to their old tickets; keep it with the user's other settings. If your users sign in,
send `Authorization: Bearer ` from your server instead ([Signed user tokens](/docs/user-tokens)).
**Screenshots and files.** Send `multipart/form-data` instead of JSON: a `ticket` field holding
the same JSON as text, and up to three files named `screenshot` (PNG, JPEG or WebP, under 2 MB),
`save` (under 1 MB) and `log` (UTF-8 text, under 512 KB).
### Unity (C#)
Works in Unity 2020.3 and later, on every platform, with no packages.
```csharp
using System;
using System.Collections;
using System.Collections.Generic;
using System.Security.Cryptography;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
// Add to a GameObject in your first scene; call from your UI with StartCoroutine(...).
public class JuncoSupport : MonoBehaviour
{
const string Server = "https://desk.juncodesk.app";
const string PublicKey = "jk_YOUR_PUBLIC_KEY";
static string Base => $"{Server}/v1/games/{PublicKey}";
[Serializable] public class Message { public string id; public string @from; public string text; public string at; }
[Serializable] public class Ticket { public int number; public string type; public string status; public string stage; public string title; public bool unread; public bool aiWorking; public Message[] messages; }
[Serializable] class TicketList { public Ticket[] tickets; }
[Serializable] class Unread { public int count; }
[Serializable] class ApiError { public string error; }
[Serializable] class Context { public string version; public string platform; public string device; public string os; public string scene; public string language; }
[Serializable] class NewTicket { public string type; public string text; public Context context; }
[Serializable] class NewReply { public string text; }
static string PlayerId
{
get
{
var id = PlayerPrefs.GetString("junco_player", "");
if (id.Length >= 32) return id;
var bytes = new byte[24];
using (var rng = RandomNumberGenerator.Create()) rng.GetBytes(bytes);
id = Convert.ToBase64String(bytes).Replace('+', '-').Replace('/', '_').TrimEnd('=');
PlayerPrefs.SetString("junco_player", id);
PlayerPrefs.Save();
return id;
}
}
// type: "bug", "idea" or "help". Takes a screenshot first if asked.
public IEnumerator Report(string type, string text, bool withScreenshot, Action done, Action failed)
{
byte[] shot = null;
if (withScreenshot)
{
yield return new WaitForEndOfFrame();
var tex = ScreenCapture.CaptureScreenshotAsTexture();
shot = tex.EncodeToJPG(60);
Destroy(tex);
if (shot.Length > 2_000_000) shot = null; // over Junco's 2 MB limit: send without it
}
var ticket = new NewTicket
{
type = type, text = text,
context = new Context
{
version = Application.version, platform = Application.platform.ToString(),
device = SystemInfo.deviceModel, os = SystemInfo.operatingSystem,
scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name,
language = Application.systemLanguage.ToString(),
},
};
var form = new List { new MultipartFormDataSection("ticket", JsonUtility.ToJson(ticket)) };
if (shot != null) form.Add(new MultipartFormFileSection("screenshot", shot, "screenshot.jpg", "image/jpeg"));
using var req = UnityWebRequest.Post($"{Base}/tickets", form);
yield return Send(req, json => done(JsonUtility.FromJson(json)), failed);
}
public IEnumerator Tickets(Action done, Action failed)
{
using var req = UnityWebRequest.Get($"{Base}/tickets");
yield return Send(req, json => done(JsonUtility.FromJson(json).tickets), failed);
}
public IEnumerator Open(int number, Action done, Action failed)
{
using var req = UnityWebRequest.Get($"{Base}/tickets/{number}");
yield return Send(req, json => done(JsonUtility.FromJson(json)), failed);
}
public IEnumerator Reply(int number, string text, Action done, Action failed)
{
using var req = new UnityWebRequest($"{Base}/tickets/{number}/messages", "POST");
req.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(JsonUtility.ToJson(new NewReply { text = text })));
req.downloadHandler = new DownloadHandlerBuffer();
req.SetRequestHeader("Content-Type", "application/json");
yield return Send(req, json => done(JsonUtility.FromJson(json)), failed);
}
public IEnumerator UnreadCount(Action done)
{
using var req = UnityWebRequest.Get($"{Base}/unread");
yield return Send(req, json => done(JsonUtility.FromJson(json).count), _ => done(0));
}
static IEnumerator Send(UnityWebRequest req, Action ok, Action failed)
{
req.SetRequestHeader("X-Junco-Player", PlayerId);
yield return req.SendWebRequest();
var body = req.downloadHandler?.text ?? "";
if (req.result == UnityWebRequest.Result.Success) { ok(body); yield break; }
var err = body.StartsWith("{") ? JsonUtility.FromJson(body)?.error : null;
failed(err ?? "Couldn't reach support. Try again in a moment.");
}
}
```
`JsonUtility` can't read dictionaries, so `context` is a class: add the fields you want. To show
replies arriving, call `Open` every 2 seconds while `aiWorking` is true. WebGL builds: use the
widget in the page template instead ([Installing the form](/docs/install)).
### Godot 4 (GDScript)
```gdscript
# junco.gd: add as an autoload named Junco. Calls one at a time (HTTPRequest is single-use).
extends Node
const SERVER := "https://desk.juncodesk.app"
const KEY := "jk_YOUR_PUBLIC_KEY"
var _http := HTTPRequest.new()
func _ready() -> void:
add_child(_http)
func player_id() -> String:
var cfg := ConfigFile.new()
cfg.load("user://junco.cfg")
var id: String = cfg.get_value("junco", "player", "")
if id.length() < 32:
id = Crypto.new().generate_random_bytes(24).hex_encode() # 48 hex characters
cfg.set_value("junco", "player", id)
cfg.save("user://junco.cfg")
return id
func _context() -> Dictionary:
return {
"version": ProjectSettings.get_setting("application/config/version", ""),
"os": OS.get_name(),
"device": OS.get_model_name(),
"scene": get_tree().current_scene.scene_file_path if get_tree().current_scene else "",
"language": OS.get_locale(),
}
# Returns the answer as a Dictionary; on failure, {"error": "..."} to show the user.
func _call(path: String, method := HTTPClient.METHOD_GET, body = null) -> Dictionary:
var headers := PackedStringArray(["X-Junco-Player: " + player_id()])
var data := ""
if body != null:
headers.append("Content-Type: application/json")
data = JSON.stringify(body)
var err := _http.request(SERVER + "/v1/games/" + KEY + path, headers, method, data)
if err != OK:
return {"error": "Couldn't reach support."}
var res: Array = await _http.request_completed # [result, code, headers, body]
var parsed = JSON.parse_string(res[3].get_string_from_utf8())
if typeof(parsed) != TYPE_DICTIONARY:
return {"error": "Couldn't reach support."}
return parsed
func report(type: String, text: String) -> Dictionary:
return await _call("/tickets", HTTPClient.METHOD_POST, {"type": type, "text": text, "context": _context()})
func tickets() -> Array:
return (await _call("/tickets")).get("tickets", [])
func open_ticket(number: int) -> Dictionary:
return await _call("/tickets/%d" % number)
func reply(number: int, text: String) -> Dictionary:
return await _call("/tickets/%d/messages" % number, HTTPClient.METHOD_POST, {"text": text})
func unread() -> int:
return int((await _call("/unread")).get("count", 0))
# A report with a screenshot, as multipart/form-data.
func report_with_screenshot(type: String, text: String) -> Dictionary:
var img := get_viewport().get_texture().get_image()
if img.get_width() > 1280:
img.resize(1280, int(img.get_height() * 1280.0 / img.get_width()))
var jpg := img.save_jpg_to_buffer(0.7)
var b := "junco" + str(randi())
var body := PackedByteArray()
body.append_array(("--%s\r\nContent-Disposition: form-data; name=\"ticket\"\r\n\r\n%s\r\n" % [b, JSON.stringify({"type": type, "text": text, "context": _context()})]).to_utf8_buffer())
body.append_array(("--%s\r\nContent-Disposition: form-data; name=\"screenshot\"; filename=\"screenshot.jpg\"\r\nContent-Type: image/jpeg\r\n\r\n" % b).to_utf8_buffer())
body.append_array(jpg)
body.append_array(("\r\n--%s--\r\n" % b).to_utf8_buffer())
var headers := PackedStringArray(["X-Junco-Player: " + player_id(), "Content-Type: multipart/form-data; boundary=" + b])
_http.request_raw(SERVER + "/v1/games/" + KEY + "/tickets", headers, HTTPClient.METHOD_POST, body)
var res: Array = await _http.request_completed
var parsed = JSON.parse_string(res[3].get_string_from_utf8())
return parsed if typeof(parsed) == TYPE_DICTIONARY else {"error": "Couldn't reach support."}
```
Use it with `var t = await Junco.report("bug", text)`; check `t.has("error")`. Web exports: use the
widget in the HTML shell instead.
### iOS (Swift)
```swift
import Foundation
import UIKit
struct JuncoMessage: Decodable { let id: String; let from: String; let text: String; let at: String }
struct JuncoTicket: Decodable {
let number: Int; let type: String; let status: String; let stage: String?
let title: String; let unread: Bool; let messages: [JuncoMessage]?; let aiWorking: Bool?
}
struct JuncoError: Error, Decodable { let error: String }
enum Junco {
static let server = "https://desk.juncodesk.app"
static let key = "jk_YOUR_PUBLIC_KEY"
static var playerId: String {
if let id = UserDefaults.standard.string(forKey: "junco.player"), id.count >= 32 { return id }
var bytes = [UInt8](repeating: 0, count: 24)
_ = SecRandomCopyBytes(kSecRandomDefault, bytes.count, &bytes)
let id = bytes.map { String(format: "%02x", $0) }.joined()
UserDefaults.standard.set(id, forKey: "junco.player")
return id
}
private static func call(_ path: String, method: String = "GET", body: [String: Any]? = nil) async throws -> T {
var req = URLRequest(url: URL(string: "\(server)/v1/games/\(key)\(path)")!)
req.httpMethod = method
req.setValue(playerId, forHTTPHeaderField: "X-Junco-Player")
if let body {
req.httpBody = try JSONSerialization.data(withJSONObject: body)
req.setValue("application/json", forHTTPHeaderField: "Content-Type")
}
let (data, response) = try await URLSession.shared.data(for: req)
let code = (response as? HTTPURLResponse)?.statusCode ?? 0
guard (200..<300).contains(code) else {
throw (try? JSONDecoder().decode(JuncoError.self, from: data)) ?? JuncoError(error: "Couldn't reach support. Try again in a moment.")
}
return try JSONDecoder().decode(T.self, from: data)
}
/// type: "bug", "idea" or "help"
@MainActor static func report(_ type: String, _ text: String, screen: String) async throws -> JuncoTicket {
let info = Bundle.main.infoDictionary ?? [:]
let context: [String: Any] = [
"version": info["CFBundleShortVersionString"] ?? "", "build": info["CFBundleVersion"] ?? "",
"os": "\(UIDevice.current.systemName) \(UIDevice.current.systemVersion)",
"device": UIDevice.current.model, "screen": screen, "language": Locale.preferredLanguages.first ?? "",
]
return try await call("/tickets", method: "POST", body: ["type": type, "text": text, "context": context])
}
struct List: Decodable { let tickets: [JuncoTicket] }
struct Count: Decodable { let count: Int }
static func tickets() async throws -> [JuncoTicket] { try await (call("/tickets") as List).tickets }
static func ticket(_ number: Int) async throws -> JuncoTicket { try await call("/tickets/\(number)") }
static func reply(_ number: Int, _ text: String) async throws -> JuncoTicket { try await call("/tickets/\(number)/messages", method: "POST", body: ["text": text]) }
static func unread() async throws -> Int { try await (call("/unread") as Count).count }
}
```
Errors are `JuncoError`; show `error.error` to the user. A message's `from` is `player` (the user),
`ai` or `staff`.
### Android (Kotlin)
No libraries beyond Kotlin coroutines; `org.json` is part of Android.
```kotlin
import android.content.Context
import android.os.Build
import android.util.Base64
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
import org.json.JSONObject
import java.io.IOException
import java.net.HttpURLConnection
import java.net.URL
import java.security.SecureRandom
object Junco {
private const val SERVER = "https://desk.juncodesk.app"
private const val KEY = "jk_YOUR_PUBLIC_KEY"
private fun playerId(ctx: Context): String {
val prefs = ctx.getSharedPreferences("junco", Context.MODE_PRIVATE)
prefs.getString("player", null)?.takeIf { it.length >= 32 }?.let { return it }
val bytes = ByteArray(24).also { SecureRandom().nextBytes(it) }
val id = Base64.encodeToString(bytes, Base64.URL_SAFE or Base64.NO_PADDING or Base64.NO_WRAP)
prefs.edit().putString("player", id).apply()
return id
}
/** Throws IOException with a message you can show the user. */
private suspend fun call(ctx: Context, path: String, method: String = "GET", body: JSONObject? = null): JSONObject =
withContext(Dispatchers.IO) {
val conn = URL("$SERVER/v1/games/$KEY$path").openConnection() as HttpURLConnection
try {
conn.requestMethod = method
conn.setRequestProperty("X-Junco-Player", playerId(ctx))
if (body != null) {
conn.doOutput = true
conn.setRequestProperty("Content-Type", "application/json")
conn.outputStream.use { it.write(body.toString().toByteArray()) }
}
val ok = conn.responseCode in 200..299
val text = (if (ok) conn.inputStream else conn.errorStream)?.bufferedReader()?.use { it.readText() } ?: "{}"
val json = runCatching { JSONObject(text) }.getOrDefault(JSONObject())
if (!ok) throw IOException(json.optString("error", "Couldn't reach support. Try again in a moment."))
json
} finally {
conn.disconnect()
}
}
/** type: "bug", "idea" or "help" */
suspend fun report(ctx: Context, type: String, text: String, screen: String): JSONObject {
val info = ctx.packageManager.getPackageInfo(ctx.packageName, 0)
val context = JSONObject()
.put("version", info.versionName)
.put("android", Build.VERSION.RELEASE)
.put("device", "${Build.MANUFACTURER} ${Build.MODEL}")
.put("screen", screen)
.put("language", java.util.Locale.getDefault().toLanguageTag())
return call(ctx, "/tickets", "POST", JSONObject().put("type", type).put("text", text).put("context", context))
}
suspend fun tickets(ctx: Context) = call(ctx, "/tickets").getJSONArray("tickets")
suspend fun ticket(ctx: Context, number: Int) = call(ctx, "/tickets/$number")
suspend fun reply(ctx: Context, number: Int, text: String) = call(ctx, "/tickets/$number/messages", "POST", JSONObject().put("text", text))
suspend fun unread(ctx: Context) = call(ctx, "/unread").getInt("count")
}
```
Needs the `INTERNET` permission in your manifest.
### Flutter (Dart)
Uses the `http` and `shared_preferences` packages.
```dart
import 'dart:convert';
import 'dart:math';
import 'package:http/http.dart' as http;
import 'package:shared_preferences/shared_preferences.dart';
class Junco {
static const server = 'https://desk.juncodesk.app';
static const key = 'jk_YOUR_PUBLIC_KEY';
static Future _playerId() async {
final prefs = await SharedPreferences.getInstance();
var id = prefs.getString('junco_player');
if (id == null || id.length < 32) {
final r = Random.secure();
id = List.generate(24, (_) => r.nextInt(256).toRadixString(16).padLeft(2, '0')).join();
await prefs.setString('junco_player', id);
}
return id;
}
/// Throws an Exception whose message you can show the user.
static Future