Learn, inside the product you already have.

Bolt on a general model, and your product gives the answers.

Watch with the full transcript

What you build.

  • A small server route that keeps your key
  • A session for each learner
  • The reply, in your own chat
  • The safety status and the receipt

Your product's look. Learn's teaching.

Open the kit

The kit.

Paste this

Goal: the product in this folder gets Learn inside its own help panel. A learner asks for help and gets a hint from Learn, not the answer, in the product's own look.

Read first: https://developers.foreverlearning.ai/docs/learn/ (the Learn integration guide), and the Learn OpenAPI contract and the runnable examples linked there. Use only what they describe.

Start from: the existing app in this folder (your own product). Keep its stack, its look and its help or chat panel.

Build:
1. A small route in the existing server for the help panel to call. The route holds the Learn key, turns the signed-in user into a pseudonymous learner id, prepares one Learn session per learner (task kind "homework", with the subject your product already knows), and sends each message as a Guided turn.
2. Wire the existing help panel to that route. Show each reply, with both parts: what the tutor says (the conversation part) and the hint to work on (the display part, in Markdown).
3. Under each reply, in the same panel, show the safety status and the receipt: the request id, the turns billed and the charge.
4. Treat a turn as done only when Learn's final done event confirms it. Keep each confirmed receipt (request id, session id, learner id, posture, safety level, billable units, charge) where your product keeps records; in this sample app, append it as one JSON line to receipts.jsonl.

Rules:
- Keep the API key on the server, in the FOREVERLEARNING_API_KEY environment variable. Read the API host from FOREVERLEARNING_BASE_URL. If FOREVERLEARNING_ASSIGNMENT_ID is set, send it as X-Assignment-Id; it can be empty when your key has one assignment. Never send the key to the browser, print it or write it into a file.
- Render each reply's Markdown (headings, lists, bold, code) and its math. Learn writes math between \( and \) inline and between \[ and \] for display math, which often spans several lines. Use a math library, loaded the way your product loads its other code, so the learner never sees raw notation.
- Make the learner id a keyed hash of your own user id, with the secret in LEARNER_ID_SECRET (if it is not set, warn and use a development value). Never use a name or an email.
- Change only what embedding Learn needs. `npm start` must still start the app on $PORT (default 3000).
- Each message is a real turn, at 5¢ per turn that succeeds. Test with two or three messages, no more. Test as one user, keeping the same cookie for all your test messages: a test key admits only a limited number of new learners a day.

Done when:
- you ran `npm start`, asked a question in the existing help panel or through its route, and Learn's hint came back
- the safety status and the receipt show under the reply, in the product's own panel
- receipts.jsonl has one line for each confirmed turn

What you should see

  • Your own chat, teaching
  • The key stays on your server
  • A status and a receipt

Paste it, run it, check it.

Read the integration guide

Watch it teach.

Every reply on screen is real.

See every film

Your product. Learn's teaching.

Inside the product you already have. One API call away.

Start building