Skip to Content
ExamplesScan recommendation

Scan recommendation

Code  · Template: Scan to recommendation agent · Runs on http://localhost:3010

Add a person, send them through a 30 second face scan, watch the results land on them, and chat with the agent about products that fit.

A person's chat, latest scan and scan history

Waiting for a scanA person with earlier scans
The scan link as a QR code, with its expiryA stage 2 blood pressure reading and two earlier scans

What it shows

  • Getting a scan link from a trigger. Triggering scan-recommendation-scan returns a scanUrl straight away. The app shows it as a link and a QR code. The scan page is hosted by Loops and needs a camera.
  • Waiting without a status endpoint. The app refetches the person until latestScan.scanId changes. After 30 minutes it shows Scan not completed and offers a new link.
  • Telling the agent the results. The agent can’t read the scan, so the first message carries the latest results, and Share my results sends new ones mid-conversation.
  • Spotting a link in a reply. The agent can start a scan itself. The app recognises the scan link in the reply and waits for it like one it started.

The endpoints it uses

EndpointUsed for
POST / on scan-recommendation-scanStarting a scan and getting its link.
POST /chat on scan-recommendationSending one message and getting the reply.
GET /usersThe people list, 50 at a time with Load more.
GET /users/:userIdA person’s latest scan and scan history.

Run it

  1. Deploy the Scan to recommendation agent template. The scan workflow deploys with the agent, so there’s nothing to tick.
  2. Copy the organization id, the scan-recommendation loop id and the scan-recommendation-scan loop id.
  3. In Settings → API tokens, create a token for the whole organization with access set to Run and read.
  4. Copy apps/scan-recommendation/.env.example to .env and fill in LOOPS_API_URL, LOOPS_ORGANIZATION_ID, LOOPS_AGENT_LOOP_ID, LOOPS_SCAN_LOOP_ID and LOOPS_API_TOKEN.
  5. Run bun run dev --filter=scan-recommendation.

Take the scan in a browser that can run the scan engine, such as Chrome, Firefox or an up-to-date Safari. A phone is usually easiest.

Where to look in the code

FileWhat it does
src/lib/loops.tsServer functions for the Loops endpoints, and helpers for scans.
src/lib/people.tsWhat Loops doesn’t store: names, transcripts and open scan links.
src/routes/index.tsxEveryone in Loops, plus people added here who haven’t scanned yet.
src/routes/people.$personId.tsxThe scan panel, latest scan, history and the chat.
Last updated on