Developer production · Server APIs
The Conversations APIBy ForeverLearning

Build with Conversations · Step 1

Your first practice room

A room, a cast and a Coach, in your own app.

Hand it to your coding assistant.

Where to run it. Open a new, empty folder in your coding assistant, with your key in FOREVERLEARNING_API_KEY, the API host in FOREVERLEARNING_BASE_URL and your assignment in FOREVERLEARNING_ASSIGNMENT_ID, in the environment it runs commands in. Then paste the prompt. The assistant needs to read web pages and run commands.

Paste this
Goal: a practice page where a user rehearses a hard conversation with a character from the Conversations API, and sees the Coach's note beside the scene.

Read first: https://developers.foreverlearning.ai/docs/conversation-practice/ (the Conversations API integration guide), and the OpenAPI contract and the TypeScript example linked there. Use only what they describe.

Start from: an empty folder.

Build, in TypeScript on Node 24 or later:
1. A small server that holds the key and is the only part that calls the Conversations API. Give each new browser a pseudonymous user id, kept in a cookie, and send it as X-User-Id.
2. The first time a user opens the page, read the catalog, find the ready-made room titled "Direct Feedback To A Report", and prepare one session for that user in guided mode, with the first persona the room recommends. Keep the session id on the server for that user, and request the room's opening once for that session.
3. Show the opening. Then send each message the user types as a turn on the same session.
4. Show each reply from its saved conversation_turn event: each entry of the turn's cast (its display_name and text) in its own bubble under that name, and the Coach's note (the turn's coach.text) in a separate panel labeled Coach (show nothing when coach is null or empty). With the reply, show the safety status (its level and response action) apart from the conversation, and the receipt: the request id, the turns billed and the charge.
5. Beside each character's line, show a face for that character from the saved turn's characters (match each to its line by speaker_id, and use its expression_group): a face drawn in code for each of the five expression_group moods, and a neutral face when it is empty. Keep all the face artwork in one clearly named file, with one entry per mood and a comment that says how to put in your own images instead of the drawn ones.
6. Treat a turn as complete only when its done event arrives with the same request id and session id as its metadata event. Then append its receipt as one JSON line to receipts.jsonl on the server: request id, session id, user id, operation, safety level, units, the amount in micro-dollars and the settlement.
7. A package.json whose `npm start` serves the page at http://localhost:$PORT (default 3000), and a README that says how to run it.

Rules:
- Keep the API key on the server, in the FOREVERLEARNING_API_KEY environment variable. Read the API host from FOREVERLEARNING_BASE_URL, and send FOREVERLEARNING_ASSIGNMENT_ID as X-Assignment-Id. Never send the key to the browser, print it or write it into a file.
- Give every POST its own new Idempotency-Key, a UUID. If a turn's outcome is uncertain (the connection ends before done), look it up with GET /v1/requests/<request id>. Never send it again under a new key while its outcome is uncertain.
- If a turn fails (an error event arrives before done), it was not charged and it is final: show a short message in your own words and let the user send a message again. Never show raw error text or JSON.
- Show the characters' words exactly as returned. When a saved turn's structure is "unavailable", show its text without inventing a speaker.
- The faces are the characters' simulated responses in this practice, never a reading of the user. Give each face its mood in words as its accessible label only, never as a caption on the page: the user reads the face.
- Use a pseudonymous user id, never a name or an email. Make a new random id for each new browser; never reuse a fixed test id.
- The opening and each message are billable text turns, at 3¢ per text turn. Test with the opening and two messages, no more, as one user, keeping the same cookie: a key admits only a limited number of new users a day. Don't end the session: closing is a turn too, and the next step covers it.
- Ending is optional: opening the learner's next session closes the open one with one billable closeout (3 cents), the same as calling end yourself. Call end when you want the debrief right away. Do not call end just to start another practice.
- Stop only the processes you started; never stop processes by name.

Done when:
- you ran `npm start`, the page showed the room's opening, you sent a message, and a character answered by name
- a face beside each character's line, and the Coach's note, the safety status and the receipt with the reply, apart from the characters' lines
- receipts.jsonl has one line for each confirmed turn

Paste into your coding assistant.

Check it.

How to check it. Open http://localhost:3000. The room opens, then answer the character. You should see:

  • the character's reply under their name, with their face beside it
  • the Coach's note in its own panel, and the safety status and the receipt with the reply
  • one new line in receipts.jsonl for each turn, the opening included

The full check is in CHECK.md. To compare your result, the finished checkpoint is the 01-first-room folder of conversations-room-starter.

Your first practice room: what you should see

The replies below are quoted word for word from one of our test runs of this kit, an app built from its prompt.

Run npm start and open http://localhost:3000.

The opening

The room opens before you type anything. A character from "Direct Feedback To A Report" speaks first, under their name. The Coach's note sits in its own panel. The opening is a billable text turn, so it has its own receipt.

Jon: You said fifteen minutes. What’s this about?

Coach

What happened: Jon asked directly for the purpose of the meeting.

Why it matters: Naming the issue clearly can reduce uncertainty and keep the conversation focused.

Next move: You could briefly state what happened in the Halvorsen handoff and why you need to discuss it.

Your turn, and the reply

Answer the character. For example:

I wanted to talk about the last two reports. They came in after the deadline, and I'd like to understand what's getting in the way.

The complete reply comes back to your application, checked before anything is shown:

  1. The character's line, in their own bubble, under their name. In a room with more than one person, each speaks in their own bubble.
  2. The Coach's note, in its own panel. The Coach answers with every turn, in English. If the note is empty, the panel shows nothing.

Jon: The deadlines weren't the same situation. Brightline had the data-retention change come in late, and Halvorsen was ready from my end. QA was supposed to catch the schema issue.

Coach

What happened: You named two missed deadlines and asked what was getting in the way; Jon separated the reports and explained his view of each one.

Why it matters: The specific framing gave him room to respond to the facts rather than treating both handoffs as identical.

Next move: You could ask what he understood the handoff responsibility to be for each report.

Every reply is written fresh, so yours will use different words. The character should still answer in character, as the person in the room.

The faces

Beside each character's line, a face drawn in code that follows their mood on that turn: one of five moods, or the neutral face when no expression is reported. The faces are the characters' simulated responses, never a reading of you.

Your own artwork. All the face artwork is in one place: in the finished checkpoint, the block marked YOUR OWN ARTWORK GOES HERE in public/faces.js. Put your images in public/faces/ and write each one's address there, one per mood (and if you like, per expression or per character). Any mood you leave empty keeps the drawn face.

The safety status

With each reply: Safety: clear and action: none for an ordinary practice. The levels a Conversations turn can show are clear, watch and critical, with the action none or support. unknown means the turn was not evaluated, and is never an all-clear. Step 8 shows how your app responds to each.

The receipt

With each reply, from the turn's final done event:

  • 1 text turn · $0.03 · settled: one billable text turn, 3¢.
  • Request: …: the request id. Keep it: it is how you look a turn up (GET /v1/requests/<id>) or ask us about it. Showing a shortened request id is fine if the full id is on the reply too, for example on hover.

In receipts.jsonl on your server, one line for each confirmed turn, the opening included. For example:

{"request_id":"…","session_id":"…","user_id":"user-…","operation":"turn","safety_level":"clear","units":1,"amount_micro_usd":30000,"settlement":"settled"}

And one thing you should not see

The key. Open your browser's developer tools: the page calls only your own server, never the Conversations API, and no page or script contains the key.

The kit.

The repository

A start folder and the finish.

Open the kit

01-first-room in conversations-room-starter

Close and debrief.

Open step 2