PAMbaseDocs
Guide

Fitness.

Build a fitness app that adapts today's plan to the user's recent training and energy. It reads their memory (durable facts the platform stores) and adjusts the workout with no LLM at all — just a hint string and a date check.

Prerequisites

You have a connection token from the connect flow — the credential issued after the user grants access. It carries these scopes (per-app permissions):

memory:write:health.*, memory:read:health.*, context:read:app.session.start.

Scopes to request

ScopeWhy
memory:write:health.*log workouts and recovery signals
memory:read:health.*read recent training to adapt the plan
context:read:app.session.startfetch the session context bundle

What to write

After a session, remember the workout and how the user felt as durable memories in a health.* scope. To also notify other apps in real time (e.g. a nutrition app), emit a signal — that part isn't memory.

typescript
// Durable training memories:
await pambase.remember({
content: "Completed a 32-minute moderate run.",
kind: "event",
scope: "health.workout",
});
const res = await pambase.remember({
content: "Felt sore and low-energy afterward.",
kind: "emotion",
scope: "health",
});
// res -> { accepted: true, memoryIds: ["mem_…"] }
// Optional real-time nudge to subscribers (not stored as memory):
await pambase.emitSignal({ type: "workout.completed", payload: { activity: "run", durationMin: 32 } });

How to read — Pattern B (no LLM)

Fetch a context bundle for the app.session.start intent (the situation you're reading for), then branch on its suggestions.adaptation hint and the health.* memories — never on identity, which carries no mood.

typescript
const ctx = await pambase.getContext({ intent: "app.session.start" });
// ctx -> { identity: { aiId, name }, memories: [...],
// suggestions: { adaptation: "User logged a hard run yesterday and feels sore." }, ... }
// Explicit non-LLM branching on the hint + memories (NOT on identity):
const lowEnergy = /low energy|tired|sore|exhausted/i.test(ctx.suggestions.adaptation);
const trainedYesterday = ctx.memories.some(
(m) => m.scope?.startsWith("health.") && isRecent(m.occurredAt, 1)
);
const plan = lowEnergy || trainedYesterday
? { type: "recovery", minutes: 20, label: "Easy mobility + walk" }
: { type: "strength", minutes: 45, label: "Full session" };

Proactive (optional)

To remind users to train, subscribe to a webhook — a server-to-server callback — and drive a nudge from your own scheduler.

Adaptive without an LLM

Everything here is a string match and a date check — no model inference. Pattern B gives you a structured bundle plus a ready-made natural-language hint, so adaptive apps stay fast and cheap. Branch on suggestions.adaptation and your health.* memories — not on the identity profile. See reading context.

Next

Reading context · How memory works · Event & scope catalog