Skip to Content
ExamplesWellness score

Wellness score

Code  · Template: Insurer wellness score agent · Runs on http://localhost:3014

A mock insurer or employer portal. Add a test member, start a wellness check, watch their face scan come back as a wellness score, and chat with the agent about what it means.

A member's chat, wellness score card, wellness check and history

A check in progressMembers
The scan link as a QR code, waiting for the scanMembers with a check, and drafts without one

What it shows

  • Sending a full payload. The check form posts age, sex and three health answers to wellness-score-scan, which uses them in the risk estimates.
  • A long wait. The run waits up to an hour for the scan. The app refetches the member until wellnessScore.scannedAt changes, and keeps the previous score if the scan isn’t taken.
  • Explaining a score the agent can’t see. The first message carries the member’s answers and latest score, and the agent never ties it to cover, premiums or claims.

The endpoints it uses

EndpointUsed for
POST / on wellness-score-scanStarting a wellness check.
POST /chat on wellness-scoreSending one message and getting the reply.
GET /usersThe member list, 50 at a time with Load more.
GET /users/:userIdA member’s latest score and memory.

The check body:

{ "memberId": "member-10442", "age": 46, "gender": "female", "smoker": false, "hasDiabetes": false, "isTreatedForHypertension": true }

The template’s payload example in the dashboard shows userId, but the workflow reads memberId, and needs age and gender.

Run it

  1. Deploy the Insurer wellness score agent template. There’s nothing to tick and nothing to set under Variables and secrets.
  2. Copy the organization id, the wellness-score loop id and the wellness-score-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/wellness-score/.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=wellness-score.

Take the scan on a phone or laptop with a camera, in Chrome or Safari. WhatsApp’s in-app browser can’t run it.

Where to look in the code

FileWhat it does
src/lib/loops.tsServer functions for the Loops endpoints.
src/lib/members.tsWhat Loops doesn’t store: names, health answers, open checks and transcripts.
src/components.tsxThe score band and blood pressure in words.
src/routes/members.$memberId.tsxA member’s score card, wellness check, history and the chat.
Last updated on